From 9ac030fd16ef8b459c8e3c70f595535e22b6ec6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Sat, 18 Jul 2020 16:05:16 +0200 Subject: [PATCH] Instantiate the Compose classes in their own file --- gestioncof/autocomplete.py | 4 ++-- gestioncof/views.py | 4 ++-- kfet/autocomplete.py | 6 ++++++ kfet/views.py | 6 +++--- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/gestioncof/autocomplete.py b/gestioncof/autocomplete.py index 9dae05db..9570acb5 100644 --- a/gestioncof/autocomplete.py +++ b/gestioncof/autocomplete.py @@ -47,7 +47,7 @@ class COFLDAPSearch(autocomplete.LDAPSearch): return reverse("clipper-registration", args=(clipper.clipper, clipper.fullname)) -class COFSearch(autocomplete.Compose): +class COFAutocomplete(autocomplete.Compose): search_units = [ ("members", COFMemberSearch()), ("others", COFOthersSearch()), @@ -55,4 +55,4 @@ class COFSearch(autocomplete.Compose): ] -cof_search = COFSearch() +cof_autocomplete = COFAutocomplete() diff --git a/gestioncof/views.py b/gestioncof/views.py index e399c05f..c80eda6c 100644 --- a/gestioncof/views.py +++ b/gestioncof/views.py @@ -25,7 +25,7 @@ from django_cas_ng.views import LogoutView as CasLogoutView from icalendar import Calendar, Event as Vevent from bda.models import Spectacle, Tirage -from gestioncof.autocomplete import COFSearch +from gestioncof.autocomplete import cof_autocomplete from gestioncof.decorators import BuroRequiredMixin, buro_required, cof_required from gestioncof.forms import ( CalendarForm, @@ -950,4 +950,4 @@ class UserAutocompleteView(BuroRequiredMixin, Select2QuerySetView): class RegistrationAutocompleteView(BuroRequiredMixin, AutocompleteView): template_name = "gestioncof/search_results.html" - search_composer = COFSearch() + search_composer = cof_autocomplete diff --git a/kfet/autocomplete.py b/kfet/autocomplete.py index ac2c0b8e..326c2796 100644 --- a/kfet/autocomplete.py +++ b/kfet/autocomplete.py @@ -80,5 +80,11 @@ class KfetAutocomplete(autocomplete.Compose): ] +kfet_autocomplete = KfetAutocomplete() + + class KfetAccountOnlyAutocomplete(autocomplete.Compose): search_units = [("kfet", KfetAccountSearch())] + + +kfet_account_only_autocomplete = KfetAccountOnlyAutocomplete() diff --git a/kfet/views.py b/kfet/views.py index 1f78c60d..0f77d6f1 100644 --- a/kfet/views.py +++ b/kfet/views.py @@ -27,7 +27,7 @@ from django.views.generic.edit import CreateView, DeleteView, UpdateView from gestioncof.models import CofProfile from kfet import KFET_DELETED_TRIGRAMME, consumers from kfet.auth.decorators import kfet_password_auth -from kfet.autocomplete import KfetAccountOnlyAutocomplete, KfetAutocomplete +from kfet.autocomplete import kfet_account_only_autocomplete, kfet_autocomplete from kfet.config import kfet_config from kfet.decorators import teamkfet_required from kfet.forms import ( @@ -2597,9 +2597,9 @@ class ArticleStatSales(ScaleMixin, JSONDetailView): class AccountCreateAutocompleteView(PermissionRequiredMixin, AutocompleteView): permission_required = "kfet.is_team" - search_composer = KfetAutocomplete() + search_composer = kfet_autocomplete class AccountSearchAutocompleteView(PermissionRequiredMixin, AutocompleteView): permission_required = "kfet.is_team" - search_composer = KfetAccountOnlyAutocomplete() + search_composer = kfet_account_only_autocomplete