Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AE UTBM
Sith
Commits
352b8f0b
Commit
352b8f0b
authored
Dec 18, 2016
by
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
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
core/models.py
View file @
352b8f0b
...
...
@@ -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
:
...
...
sas/views.py
View file @
352b8f0b
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment