Commit 352b8f0b authored by Skia's avatar Skia
Browse files

Add recursive option to apply rights in the SAS

parent dd2be2a3
Pipeline #536 passed with stage
in 2 minutes and 27 seconds
......@@ -612,6 +612,15 @@ class SithFile(models.Model):
if copy_rights:
self.copy_rights()
def apply_rights_recursively(self, only_folders=False):
print(self)
children = self.children.all()
if only_folders:
children = children.filter(is_folder=True)
for c in children:
c.copy_rights()
c.apply_rights_recursively(only_folders)
def copy_rights(self):
"""Copy, if possible, the rights of the parent folder"""
if self.parent is not None:
......
......@@ -162,7 +162,8 @@ class AlbumView(CanViewMixin, DetailView, FormMixin):
def post(self, request, *args, **kwargs):
self.object = self.get_object()
self.object.generate_thumbnail()
if not self.object.file:
self.object.generate_thumbnail()
self.form = self.get_form()
if 'clipboard' not in request.session.keys():
request.session['clipboard'] = []
......@@ -232,6 +233,7 @@ class AlbumEditForm(forms.ModelForm):
fields=['name', 'file', 'parent', 'edit_groups']
parent = make_ajax_field(Album, 'parent', 'files', help_text="")
edit_groups = make_ajax_field(Album, 'edit_groups', 'groups', help_text="")
recursive = forms.BooleanField(label=_("Apply rights recursively"), required=False)
class PictureEditView(CanEditMixin, UpdateView):
model=Picture
......@@ -245,3 +247,8 @@ class AlbumEditView(CanEditMixin, UpdateView):
template_name='core/edit.jinja'
pk_url_kwarg = "album_id"
def form_valid(self, form):
ret = super(AlbumEditView, self).form_valid(form)
if form.cleaned_data['recursive']:
self.object.apply_rights_recursively(True)
return ret
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment