kadenios/petitions/mixins.py

18 lines
502 B
Python

from django.contrib.auth.mixins import PermissionRequiredMixin
from django.urls import reverse
class AdminOnlyMixin(PermissionRequiredMixin):
"""Restreint l'accès aux admins"""
permission_required = "petitions.is_admin"
class CreatorOnlyMixin(AdminOnlyMixin):
"""Restreint l'accès au créateurice de l'élection"""
def get_next_url(self):
return reverse("kadenios")
def get_queryset(self):
return super().get_queryset().filter(created_by=self.request.user)