Restrict bds views to the staff

This commit is contained in:
Martin Pépin 2020-06-07 21:01:54 +02:00
parent de2a013a16
commit 1767259efd
No known key found for this signature in database
GPG key ID: E7520278B1774448
2 changed files with 8 additions and 2 deletions

5
bds/mixins.py Normal file
View file

@ -0,0 +1,5 @@
from django.contrib.auth.mixins import PermissionRequiredMixin
class StaffRequiredMixin(PermissionRequiredMixin):
permission_required = "bds:is_team"

View file

@ -2,9 +2,10 @@ from django.http import Http404
from django.views.generic import TemplateView
from bds.autocomplete import bds_search
from bds.mixins import StaffRequiredMixin
class AutocompleteView(TemplateView):
class AutocompleteView(StaffRequiredMixin, TemplateView):
template_name = "bds/search_results.html"
def get_context_data(self, *args, **kwargs):
@ -19,5 +20,5 @@ class AutocompleteView(TemplateView):
return ctx
class Home(TemplateView):
class Home(StaffRequiredMixin, TemplateView):
template_name = "bds/home.html"