Commit dc571836 authored by Sli's avatar Sli

Fixed issues with department and sex form

parent 86d62f12
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
{{ form.phone.errors }} {{ form.phone.errors }}
<label for="{{ form.phone.id_for_label }}">{{ form.phone.label }}</label> <label for="{{ form.phone.id_for_label }}">{{ form.phone.label }}</label>
{{ form.phone }} {{ form.phone }}
{{ form.sex.as_hidden() }}
<p><input type="submit" value="{% trans %}Search{% endtrans %}" /></p> <p><input type="submit" value="{% trans %}Search{% endtrans %}" /></p>
</p> </p>
</form> </form>
...@@ -65,6 +66,7 @@ ...@@ -65,6 +66,7 @@
<p> <p>
{{ form.quick.errors }} {{ form.quick.errors }}
<label for="{{ form.quick.id_for_label }}">{{ form.quick.label }}</label> <label for="{{ form.quick.id_for_label }}">{{ form.quick.label }}</label>
{{ form.sex.as_hidden() }}
{{ form.quick }} {{ form.quick }}
<p><input type="submit" value="{% trans %}Search{% endtrans %}" /></p> <p><input type="submit" value="{% trans %}Search{% endtrans %}" /></p>
</p> </p>
......
...@@ -134,8 +134,11 @@ class SearchFormListView(WasSuscribed, SingleObjectMixin, ListView): ...@@ -134,8 +134,11 @@ class SearchFormListView(WasSuscribed, SingleObjectMixin, ListView):
if self.search_type == SearchType.REVERSE: if self.search_type == SearchType.REVERSE:
q = q.filter(phone=self.valid_form['phone']).all() q = q.filter(phone=self.valid_form['phone']).all()
elif self.search_type == SearchType.QUICK: elif self.search_type == SearchType.QUICK:
q = search_user(self.valid_form['quick']) if self.valid_form['quick'].strip():
if not self.can_see_hidden: 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] q = [user for user in q if user.is_subscriber_viewable]
else: else:
search_dict = {} search_dict = {}
...@@ -182,7 +185,10 @@ class SearchFormView(WasSuscribed, FormView): ...@@ -182,7 +185,10 @@ class SearchFormView(WasSuscribed, FormView):
return view(request, *args, **kwargs) return view(request, *args, **kwargs)
def get_initial(self): 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): class SearchNormalFormView(SearchFormView):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment