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
b619619b
Commit
b619619b
authored
Nov 19, 2016
by
Skia
🤘
Browse files
Improve moderation tool in SAS
parent
e681cc65
Changes
4
Hide whitespace changes
Inline
Side-by-side
core/templates/core/user_tools.jinja
View file @
b619619b
...
...
@@ -58,13 +58,16 @@
{%
-
endfor
%}
</ul>
{%
if
user.is_in_group
(
settings.SITH_GROUPS
[
'communication-admin'
][
'id'
])
%}
<hr>
<h4>
{%
trans
%}
Communication
{%
endtrans
%}
</h4>
<ul>
{%
if
user.is_in_group
(
settings.SITH_GROUPS
[
'communication-admin'
][
'id'
])
%}
<li><a
href=
"
{{
url
(
'core:file_moderation'
)
}}
"
>
{%
trans
%}
Moderate files
{%
endtrans
%}
</a></li>
{%
endif
%}
{%
if
user.is_in_group
(
settings.SITH_SAS_ADMIN_GROUP_ID
)
%}
<li><a
href=
"
{{
url
(
'sas:moderation'
)
}}
"
>
{%
trans
%}
Moderate pictures
{%
endtrans
%}
</a></li>
{%
endif
%}
</ul>
{%
endif
%}
<hr>
...
...
core/urls.py
View file @
b619619b
...
...
@@ -51,7 +51,7 @@ urlpatterns = [
url
(
r
'^file/(?P<file_id>[0-9]+)/prop/(?P<popup>popup)?$'
,
FileEditPropView
.
as_view
(),
name
=
'file_prop'
),
url
(
r
'^file/(?P<file_id>[0-9]+)/delete/(?P<popup>popup)?$'
,
FileDeleteView
.
as_view
(),
name
=
'file_delete'
),
url
(
r
'^file/moderation$'
,
FileModerationView
.
as_view
(),
name
=
'file_moderation'
),
url
(
r
'^file/(?P<file_id>[0-9]+)/moderate
?
$'
,
FileModerateView
.
as_view
(),
name
=
'file_moderate'
),
url
(
r
'^file/(?P<file_id>[0-9]+)/moderate$'
,
FileModerateView
.
as_view
(),
name
=
'file_moderate'
),
url
(
r
'^file/(?P<file_id>[0-9]+)/download$'
,
send_file
,
name
=
'download'
),
# Page views
...
...
sas/templates/sas/moderation.jinja
View file @
b619619b
...
...
@@ -7,6 +7,7 @@
{%
block
content
%}
<h3>
{%
trans
%}
SAS moderation
{%
endtrans
%}
</h3>
<div>
<form
action=
""
method=
"get"
enctype=
"multipart/form-data"
>
{%
for
p
in
pictures
%}
<div
style=
"margin: 2px; padding: 2px; border: solid 1px red; text-align: center"
>
{%
if
p.is_folder
%}
...
...
@@ -22,9 +23,17 @@
{%
trans
%}
Owner:
{%
endtrans
%}{{
p.owner.get_display_name
()
}}
<br/>
{%
trans
%}
Date:
{%
endtrans
%}{{
p.date
|
date
(
DATE_FORMAT
)
}}
{{
p.date
|
time
(
TIME_FORMAT
)
}}
<br/>
</p>
<p><a
href=
"
{{
url
(
'core:file_moderate'
,
file_id
=
p.id
)
}}
?next=
{{
url
(
'sas:moderation'
)
}}
"
>
{%
trans
%}
Moderate
{%
endtrans
%}
</a>
-
<a
href=
"
{{
url
(
'core:file_delete'
,
file_id
=
p.id
)
}}
?next=
{{
url
(
'sas:moderation'
)
}}
"
>
{%
trans
%}
Delete
{%
endtrans
%}
</a></p>
<p>
<input
type=
"radio"
name=
"action_
{{
p.id
}}
"
id=
"m_
{{
p.id
}}
"
value=
"moderate"
/>
<a
href=
"
{{
url
(
'core:file_moderate'
,
file_id
=
p.id
)
}}
?next=
{{
url
(
'sas:moderation'
)
}}
"
>
{%
trans
%}
Moderate
{%
endtrans
%}
</a>
</p>
<p>
<input
type=
"radio"
name=
"action_
{{
p.id
}}
"
id=
"m_
{{
p.id
}}
"
value=
"delete"
/>
<a
href=
"
{{
url
(
'core:file_delete'
,
file_id
=
p.id
)
}}
?next=
{{
url
(
'sas:moderation'
)
}}
"
>
{%
trans
%}
Delete
{%
endtrans
%}
</a>
</p>
</div>
{%
endfor
%}
<p><input
type=
"submit"
value=
"
{%
trans
%}
Go
{%
endtrans
%}
"
/></p>
</form>
</div>
{%
endblock
%}
sas/views.py
View file @
b619619b
...
...
@@ -6,6 +6,7 @@ from django.utils.translation import ugettext as _
from
django.utils
import
timezone
from
django.conf
import
settings
from
django
import
forms
from
django.core.exceptions
import
PermissionDenied
from
ajax_select.fields
import
AutoCompleteSelectField
,
AutoCompleteSelectMultipleField
...
...
@@ -109,9 +110,24 @@ class AlbumView(CanViewMixin, DetailView, FormMixin):
class
ModerationView
(
TemplateView
):
template_name
=
"sas/moderation.jinja"
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
if
request
.
user
.
is_in_group
(
settings
.
SITH_SAS_ADMIN_GROUP_ID
):
for
k
,
v
in
request
.
GET
.
items
():
if
k
[:
7
]
==
"action_"
:
try
:
pict
=
Picture
.
objects
.
filter
(
id
=
int
(
k
[
7
:])).
first
()
if
v
==
"delete"
:
pict
.
delete
()
elif
v
==
"moderate"
:
pict
.
is_moderated
=
True
pict
.
save
()
except
:
pass
return
super
(
ModerationView
,
self
).
get
(
request
,
*
args
,
**
kwargs
)
raise
PermissionDenied
def
get_context_data
(
self
,
**
kwargs
):
kwargs
=
super
(
ModerationView
,
self
).
get_context_data
(
**
kwargs
)
kwargs
[
'pictures'
]
=
[
p
for
p
in
Picture
.
objects
.
filter
(
is_moderated
=
False
).
all
(
)
if
p
.
is_in_sas
]
kwargs
[
'pictures'
]
=
[
p
for
p
in
Picture
.
objects
.
filter
(
is_moderated
=
False
).
order_by
(
'id'
)
if
p
.
is_in_sas
]
return
kwargs
Write
Preview
Supports
Markdown
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