Add recursive option to file props form

This commit is contained in:
Skia 2017-01-12 20:55:31 +01:00
parent 9efd85d99b
commit 5a305354cb
2 changed files with 8 additions and 1 deletions

View File

@ -120,7 +120,7 @@ class FileEditPropForm(forms.ModelForm):
parent = make_ajax_field(SithFile, 'parent', 'files', help_text="") parent = make_ajax_field(SithFile, 'parent', 'files', help_text="")
edit_groups = make_ajax_field(SithFile, 'edit_groups', 'groups', help_text="") edit_groups = make_ajax_field(SithFile, 'edit_groups', 'groups', help_text="")
view_groups = make_ajax_field(SithFile, 'view_groups', 'groups', help_text="") view_groups = make_ajax_field(SithFile, 'view_groups', 'groups', help_text="")
recursive = forms.BooleanField(label=_("Apply rights recursively"), required=False)
class FileEditPropView(CanEditPropMixin, UpdateView): class FileEditPropView(CanEditPropMixin, UpdateView):
model = SithFile model = SithFile
@ -134,6 +134,12 @@ class FileEditPropView(CanEditPropMixin, UpdateView):
form.fields['parent'].queryset = SithFile.objects.filter(is_folder=True) form.fields['parent'].queryset = SithFile.objects.filter(is_folder=True)
return form return form
def form_valid(self, form):
ret = super(FileEditPropView, self).form_valid(form)
if form.cleaned_data['recursive']:
self.object.apply_rights_recursively()
return ret
def get_success_url(self): def get_success_url(self):
return reverse('core:file_detail', kwargs={'file_id': self.object.id, 'popup': self.kwargs['popup'] or ""}) return reverse('core:file_detail', kwargs={'file_id': self.object.id, 'popup': self.kwargs['popup'] or ""})

View File

@ -273,3 +273,4 @@ class AlbumEditView(CanEditMixin, UpdateView):
if form.cleaned_data['recursive']: if form.cleaned_data['recursive']:
self.object.apply_rights_recursively(True) self.object.apply_rights_recursively(True)
return ret return ret