mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
minidlna: Minor refactor of media directory handling
Tests performed: - Functional tests work as expected. - Updating the media directory works newly updated media directory is show. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
3255a7e658
commit
5cd1289198
@ -93,3 +93,13 @@ def setup(helper, old_version=None):
|
|||||||
helper.call('post', actions.superuser_run, 'minidlna', ['setup'])
|
helper.call('post', actions.superuser_run, 'minidlna', ['setup'])
|
||||||
if not old_version:
|
if not old_version:
|
||||||
helper.call('post', app.enable)
|
helper.call('post', app.enable)
|
||||||
|
|
||||||
|
|
||||||
|
def get_media_dir():
|
||||||
|
"""Return the currently set media directory."""
|
||||||
|
return actions.superuser_run('minidlna', ['get-media-dir'])
|
||||||
|
|
||||||
|
|
||||||
|
def set_media_dir(media_dir):
|
||||||
|
"""Set the media directory from which files will be scanned for sharing."""
|
||||||
|
actions.superuser_run('minidlna', ['set-media-dir', '--dir', media_dir])
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import os
|
|||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
from plinth import actions
|
from plinth.modules import minidlna
|
||||||
from plinth.views import AppView
|
from plinth.views import AppView
|
||||||
|
|
||||||
from .forms import MiniDLNAServerForm
|
from .forms import MiniDLNAServerForm
|
||||||
@ -20,9 +20,7 @@ class MiniDLNAAppView(AppView):
|
|||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
"""Initial form value as found in the minidlna.conf"""
|
"""Initial form value as found in the minidlna.conf"""
|
||||||
initial = super().get_initial()
|
initial = super().get_initial()
|
||||||
initial.update({
|
initial.update({'media_dir': minidlna.get_media_dir()})
|
||||||
'media_dir': actions.superuser_run('minidlna', ['get-media-dir']),
|
|
||||||
})
|
|
||||||
|
|
||||||
return initial
|
return initial
|
||||||
|
|
||||||
@ -36,9 +34,7 @@ class MiniDLNAAppView(AppView):
|
|||||||
messages.error(self.request,
|
messages.error(self.request,
|
||||||
_('Specified directory does not exist.'))
|
_('Specified directory does not exist.'))
|
||||||
else:
|
else:
|
||||||
actions.superuser_run(
|
minidlna.set_media_dir(new_config['media_dir'])
|
||||||
'minidlna',
|
|
||||||
['set-media-dir', '--dir', new_config['media_dir']])
|
|
||||||
messages.success(self.request, _('Updated media directory'))
|
messages.success(self.request, _('Updated media directory'))
|
||||||
|
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user