mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Refactor group settings
This commit is contained in:
@ -24,7 +24,7 @@ class Picture(SithFile):
|
||||
return False
|
||||
|
||||
def can_be_edited_by(self, user):
|
||||
return user.is_in_group(settings.SITH_SAS_ADMIN_GROUP_ID)
|
||||
return user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID)
|
||||
|
||||
def can_be_viewed_by(self, user):
|
||||
return self.can_be_edited_by(user) or (self.is_in_sas and self.is_moderated and
|
||||
@ -87,7 +87,7 @@ class Album(SithFile):
|
||||
proxy = True
|
||||
|
||||
def can_be_edited_by(self, user):
|
||||
return user.is_in_group(settings.SITH_SAS_ADMIN_GROUP_ID)
|
||||
return user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID)
|
||||
|
||||
def can_be_viewed_by(self, user):
|
||||
print(self.is_in_sas)
|
||||
|
@ -24,7 +24,7 @@
|
||||
{{ a.name }}
|
||||
</div>
|
||||
</a>
|
||||
{% elif user.is_in_group(settings.SITH_SAS_ADMIN_GROUP_ID) %}
|
||||
{% elif user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID) %}
|
||||
<div style="display: inline-block; border: solid 1px red; text-align: center">
|
||||
<p><a href="{{ url('core:file_moderate', file_id=a.id) }}?next={{ url('sas:moderation') }}">Moderate</a> or <a href="">Delete</a></p>
|
||||
<a href="{{ url("sas:album", album_id=a.id) }}">{{ a.name }}</a>
|
||||
@ -32,7 +32,7 @@
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% if user.is_in_group(settings.SITH_SAS_ADMIN_GROUP_ID) %}
|
||||
{% if user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID) %}
|
||||
<form action="" method="post" enctype="multipart/form-data">
|
||||
{% csrf_token %}
|
||||
{{ form.non_field_errors() }}
|
||||
|
@ -62,7 +62,7 @@
|
||||
{% for r in picture.people.all() %}
|
||||
<li>
|
||||
<a href="{{ r.user.get_absolute_url() }}">{{ r.user.get_short_name() }}</a>
|
||||
{% if user == r.user or user.is_in_group(settings.SITH_SAS_ADMIN_GROUP_ID) %}
|
||||
{% if user == r.user or user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID) %}
|
||||
<a href="?remove_user={{ r.user.id }}">{% trans %}Delete{% endtrans %}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
|
10
sas/views.py
10
sas/views.py
@ -49,7 +49,7 @@ class SASForm(forms.Form):
|
||||
except Exception as e:
|
||||
self.add_error(None, _("Error uploading file %(file_name)s: %(msg)s") % {'file_name': f, 'msg': repr(e)})
|
||||
if notif:
|
||||
for u in RealGroup.objects.filter(id=settings.SITH_SAS_ADMIN_GROUP_ID).first().users.all():
|
||||
for u in RealGroup.objects.filter(id=settings.SITH_GROUP_SAS_ADMIN_ID).first().users.all():
|
||||
if not u.notifications.filter(type="SAS_MODERATION").exists():
|
||||
Notification(user=u, url=reverse("sas:moderation"), type="SAS_MODERATION").save()
|
||||
|
||||
@ -70,7 +70,7 @@ class SASMainView(FormView):
|
||||
parent = SithFile.objects.filter(id=settings.SITH_SAS_ROOT_DIR_ID).first()
|
||||
files = request.FILES.getlist('images')
|
||||
root = User.objects.filter(username="root").first()
|
||||
if request.user.is_authenticated() and request.user.is_in_group(settings.SITH_SAS_ADMIN_GROUP_ID):
|
||||
if request.user.is_authenticated() and request.user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID):
|
||||
if self.form.is_valid():
|
||||
self.form.process(parent=parent, owner=root, files=files, automodere=True)
|
||||
if self.form.is_valid():
|
||||
@ -103,7 +103,7 @@ class PictureView(CanViewMixin, DetailView, FormMixin):
|
||||
if 'remove_user' in request.GET.keys():
|
||||
try:
|
||||
user = User.objects.filter(id=int(request.GET['remove_user'])).first()
|
||||
if user.id == request.user.id or request.user.is_in_group(settings.SITH_SAS_ADMIN_GROUP_ID):
|
||||
if user.id == request.user.id or request.user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID):
|
||||
r = PeoplePictureRelation.objects.filter(user=user, picture=self.object).delete()
|
||||
except: pass
|
||||
if 'ask_removal' in request.GET.keys():
|
||||
@ -164,7 +164,7 @@ class AlbumView(CanViewMixin, DetailView, FormMixin):
|
||||
if request.user.is_authenticated() and request.user.is_in_group('ae-membres'):
|
||||
if self.form.is_valid():
|
||||
self.form.process(parent=parent, owner=request.user, files=files,
|
||||
automodere=request.user.is_in_group(settings.SITH_SAS_ADMIN_GROUP_ID))
|
||||
automodere=request.user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID))
|
||||
if self.form.is_valid():
|
||||
return super(AlbumView, self).form_valid(self.form)
|
||||
else:
|
||||
@ -185,7 +185,7 @@ 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):
|
||||
if request.user.is_in_group(settings.SITH_GROUP_SAS_ADMIN_ID):
|
||||
for k,v in request.GET.items():
|
||||
if k[:2] == "a_":
|
||||
try:
|
||||
|
Reference in New Issue
Block a user