From dc571836ae2a484626ad4d2a435869e5d56ca745 Mon Sep 17 00:00:00 2001 From: klmp200 Date: Sun, 23 Jul 2017 16:50:45 +0200 Subject: [PATCH] Fixed issues with department and sex form --- matmat/templates/matmat/search_form.jinja | 2 ++ matmat/views.py | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/matmat/templates/matmat/search_form.jinja b/matmat/templates/matmat/search_form.jinja index dbadcebc..148a0469 100644 --- a/matmat/templates/matmat/search_form.jinja +++ b/matmat/templates/matmat/search_form.jinja @@ -56,6 +56,7 @@ {{ form.phone.errors }} {{ form.phone }} + {{ form.sex.as_hidden() }}

@@ -65,6 +66,7 @@

{{ form.quick.errors }} + {{ form.sex.as_hidden() }} {{ form.quick }}

diff --git a/matmat/views.py b/matmat/views.py index 384bc504..b6422ae0 100644 --- a/matmat/views.py +++ b/matmat/views.py @@ -134,8 +134,11 @@ class SearchFormListView(WasSuscribed, SingleObjectMixin, ListView): if self.search_type == SearchType.REVERSE: q = q.filter(phone=self.valid_form['phone']).all() elif self.search_type == SearchType.QUICK: - q = search_user(self.valid_form['quick']) - if not self.can_see_hidden: + if self.valid_form['quick'].strip(): + q = search_user(self.valid_form['quick']) + else: + q = [] + if not self.can_see_hidden and len(q) > 0: q = [user for user in q if user.is_subscriber_viewable] else: search_dict = {} @@ -182,7 +185,10 @@ class SearchFormView(WasSuscribed, FormView): return view(request, *args, **kwargs) def get_initial(self): - return self.session.get('matmat_search_form', {}) + init = self.session.get('matmat_search_form', {}) + if not init: + init['department'] = '' + return init class SearchNormalFormView(SearchFormView):