Commit 349475cd authored by Sli's avatar Sli

Functionnal search engine

parent 39616874
...@@ -91,7 +91,6 @@ class SearchFormListView(WasSuscribed, SingleObjectMixin, ListView): ...@@ -91,7 +91,6 @@ class SearchFormListView(WasSuscribed, SingleObjectMixin, ListView):
self.session = request.session self.session = request.session
self.last_search = self.session.get('matmat_search_result', str([])) self.last_search = self.session.get('matmat_search_result', str([]))
self.last_search = literal_eval(self.last_search) self.last_search = literal_eval(self.last_search)
print(self.last_search)
if 'valid_form' in kwargs.keys(): if 'valid_form' in kwargs.keys():
self.valid_form = kwargs['valid_form'] self.valid_form = kwargs['valid_form']
else: else:
...@@ -119,7 +118,11 @@ class SearchFormListView(WasSuscribed, SingleObjectMixin, ListView): ...@@ -119,7 +118,11 @@ class SearchFormListView(WasSuscribed, SingleObjectMixin, ListView):
if self.reverse: if self.reverse:
q = q.filter(phone=self.valid_form['phone']).all() q = q.filter(phone=self.valid_form['phone']).all()
else: else:
q = q.all() search_dict = {}
for key, value in self.valid_form.items():
if key != 'phone' and not (value == '' or value is None or value == 'INDIFFERENT'):
search_dict[key + "__icontains"] = value
q = q.filter(**search_dict).all()
else: else:
q = q.filter(pk__in=self.last_search).all() q = q.filter(pk__in=self.last_search).all()
self.result_exists = q.exists() self.result_exists = q.exists()
......
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