kadenios/faqs/mixins.py

15 lines
379 B
Python
Raw Permalink Normal View History

2021-06-15 11:41:04 +02:00
from django.contrib.auth.mixins import PermissionRequiredMixin
class AdminOnlyMixin(PermissionRequiredMixin):
"""Restreint l'accès aux admins"""
permission_required = "faqs.is_author"
class CreatorOnlyMixin(AdminOnlyMixin):
"""Restreint l'accès à l'auteur"""
def get_queryset(self):
return super().get_queryset().filter(author=self.request.user)