From dceaf9d60fd2e284aac92b59bcc085bca6e3e308 Mon Sep 17 00:00:00 2001 From: chirac Date: Sat, 2 Jan 2021 23:35:56 +0100 Subject: [PATCH] Add an unlogged view for registration view --- re2o/views.py | 7 ++++++- topologie/views_autocomplete.py | 4 ++-- users/views_autocomplete.py | 4 ++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/re2o/views.py b/re2o/views.py index ea22e97c..f5c6e476 100644 --- a/re2o/views.py +++ b/re2o/views.py @@ -173,7 +173,7 @@ def handler404(request): return render(request, "errors/404.html", status=404) -class AutocompleteViewMixin(LoginRequiredMixin, autocomplete.Select2QuerySetView): +class AutocompleteUnloggedViewMixin(autocomplete.Select2QuerySetView): obj_type = None # This MUST be overridden by child class query_set = None query_filter = "name__icontains" # Override this if necessary @@ -193,3 +193,8 @@ class AutocompleteViewMixin(LoginRequiredMixin, autocomplete.Select2QuerySetView self.query_set = self.query_set.filter(**{self.query_filter: self.q}) return self.query_set + + +class AutocompleteViewMixin(LoginRequiredMixin, AutocompleteUnloggedViewMixin): + pass + diff --git a/topologie/views_autocomplete.py b/topologie/views_autocomplete.py index e1069b18..5972da6d 100644 --- a/topologie/views_autocomplete.py +++ b/topologie/views_autocomplete.py @@ -36,10 +36,10 @@ from django.db.models.functions import Concat from .models import Room, Dormitory, Building, Switch, PortProfile, Port, SwitchBay -from re2o.views import AutocompleteViewMixin +from re2o.views import AutocompleteViewMixin, AutocompleteUnloggedViewMixin -class RoomAutocomplete(AutocompleteViewMixin): +class RoomAutocomplete(AutocompleteUnloggedViewMixin): obj_type = Room # Precision on search to add annotations so search behaves more like users expect it to diff --git a/users/views_autocomplete.py b/users/views_autocomplete.py index e202ec4d..219fe2bb 100644 --- a/users/views_autocomplete.py +++ b/users/views_autocomplete.py @@ -33,13 +33,13 @@ from __future__ import unicode_literals from .models import User, School, Adherent, Club, ListShell -from re2o.views import AutocompleteViewMixin +from re2o.views import AutocompleteViewMixin, AutocompleteUnloggedViewMixin from django.db.models import Q, Value, CharField from django.db.models.functions import Concat -class SchoolAutocomplete(AutocompleteViewMixin): +class SchoolAutocomplete(AutocompleteUnloggedViewMixin): obj_type = School