mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Improve pedagogy permissions
This commit is contained in:
@ -895,13 +895,16 @@ Welcome to the wiki page!
|
||||
|
||||
subscribers = Group.objects.create(name="Subscribers")
|
||||
subscribers.permissions.add(
|
||||
*list(perms.filter(codename__in=["add_news", "add_uvcommentreport"]))
|
||||
*list(perms.filter(codename__in=["add_news", "add_uvcomment"]))
|
||||
)
|
||||
old_subscribers = Group.objects.create(name="Old subscribers")
|
||||
old_subscribers.permissions.add(
|
||||
*list(
|
||||
perms.filter(
|
||||
codename__in=[
|
||||
"view_uv",
|
||||
"view_uvcomment",
|
||||
"add_uvcommentreport",
|
||||
"view_user",
|
||||
"view_picture",
|
||||
"view_album",
|
||||
@ -973,9 +976,9 @@ Welcome to the wiki page!
|
||||
)
|
||||
pedagogy_admin.permissions.add(
|
||||
*list(
|
||||
perms.filter(content_type__app_label="pedagogy").values_list(
|
||||
"pk", flat=True
|
||||
)
|
||||
perms.filter(content_type__app_label="pedagogy")
|
||||
.exclude(codename__in=["change_uvcomment"])
|
||||
.values_list("pk", flat=True)
|
||||
)
|
||||
)
|
||||
self.reset_index("core", "auth")
|
||||
|
@ -28,8 +28,7 @@ from django.http import (
|
||||
HttpResponseServerError,
|
||||
)
|
||||
from django.shortcuts import render
|
||||
from django.utils.functional import cached_property
|
||||
from django.views.generic.detail import SingleObjectMixin
|
||||
from django.views.generic.detail import BaseDetailView
|
||||
from django.views.generic.edit import FormView
|
||||
from sentry_sdk import last_event_id
|
||||
|
||||
@ -54,17 +53,12 @@ def internal_servor_error(request):
|
||||
return HttpResponseServerError(render(request, "core/500.jinja"))
|
||||
|
||||
|
||||
class DetailFormView(SingleObjectMixin, FormView):
|
||||
class DetailFormView(FormView, BaseDetailView):
|
||||
"""Class that allow both a detail view and a form view."""
|
||||
|
||||
def get_object(self):
|
||||
"""Get current group from id in url."""
|
||||
return self.cached_object
|
||||
|
||||
@cached_property
|
||||
def cached_object(self):
|
||||
"""Optimisation on group retrieval."""
|
||||
return super().get_object()
|
||||
def post(self, request, *args, **kwargs):
|
||||
self.object = self.get_object()
|
||||
return super().post(request, *args, **kwargs)
|
||||
|
||||
|
||||
# F403: those star-imports would be hellish to refactor
|
||||
|
@ -66,7 +66,6 @@ from core.views.forms import (
|
||||
)
|
||||
from core.views.mixins import QuickNotifMixin, TabedViewMixin
|
||||
from counter.models import Refilling, Selling
|
||||
from counter.views.student_card import StudentCardFormView
|
||||
from eboutic.models import Invoice
|
||||
from subscription.models import Subscription
|
||||
from trombi.views import UserTrombiForm
|
||||
@ -566,6 +565,8 @@ class UserPreferencesView(UserTabsMixin, CanEditMixin, UpdateView):
|
||||
if not hasattr(self.object, "trombi_user"):
|
||||
kwargs["trombi_form"] = UserTrombiForm()
|
||||
if hasattr(self.object, "customer"):
|
||||
from counter.views.student_card import StudentCardFormView
|
||||
|
||||
kwargs["student_card_fragment"] = StudentCardFormView.get_template_data(
|
||||
self.object.customer
|
||||
).render(self.request)
|
||||
|
Reference in New Issue
Block a user