forked from DGNum/gestioCOF
Autocompletion: more idiomatic permission handling
This commit is contained in:
parent
9a90f19502
commit
f2b1962e1c
2 changed files with 5 additions and 11 deletions
|
@ -108,12 +108,12 @@ if "gestioncof" in settings.INSTALLED_APPS:
|
|||
# Autocompletion
|
||||
path(
|
||||
"autocomplete/registration",
|
||||
gestioncof_views.registration_autocomplete,
|
||||
gestioncof_views.RegistrationAutocompleteView.as_view(),
|
||||
name="cof.registration.autocomplete",
|
||||
),
|
||||
path(
|
||||
"user/autocomplete",
|
||||
gestioncof_views.user_autocomplete,
|
||||
gestioncof_views.UserAutocompleteView.as_view(),
|
||||
name="cof-user-autocomplete",
|
||||
),
|
||||
# Liens utiles du COF et du BdA
|
||||
|
|
|
@ -26,7 +26,7 @@ from icalendar import Calendar, Event as Vevent
|
|||
|
||||
from bda.models import Spectacle, Tirage
|
||||
from gestioncof.autocomplete import COFSearch
|
||||
from gestioncof.decorators import buro_required, cof_required
|
||||
from gestioncof.decorators import BuroRequiredMixin, buro_required, cof_required
|
||||
from gestioncof.forms import (
|
||||
CalendarForm,
|
||||
ClubsForm,
|
||||
|
@ -943,15 +943,12 @@ class ConfigUpdate(FormView):
|
|||
##
|
||||
|
||||
|
||||
class UserAutocomplete(Select2QuerySetView):
|
||||
class UserAutocompleteView(BuroRequiredMixin, Select2QuerySetView):
|
||||
model = User
|
||||
search_fields = ("username", "first_name", "last_name")
|
||||
|
||||
|
||||
user_autocomplete = buro_required(UserAutocomplete.as_view())
|
||||
|
||||
|
||||
class AutocompleteView(TemplateView):
|
||||
class RegistrationAutocompleteView(BuroRequiredMixin, TemplateView):
|
||||
template_name = "gestioncof/search_results.html"
|
||||
|
||||
def get_context_data(self, *args, **kwargs):
|
||||
|
@ -962,6 +959,3 @@ class AutocompleteView(TemplateView):
|
|||
ctx["q"] = q
|
||||
ctx.update(COFSearch().search(q.split()))
|
||||
return ctx
|
||||
|
||||
|
||||
registration_autocomplete = buro_required(AutocompleteView.as_view())
|
||||
|
|
Loading…
Reference in a new issue