|
|
|
|
@ -3,6 +3,7 @@ from django.contrib import messages |
|
|
|
|
from django.contrib.auth.mixins import PermissionRequiredMixin, LoginRequiredMixin |
|
|
|
|
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger |
|
|
|
|
from django.core.urlresolvers import reverse, reverse_lazy |
|
|
|
|
from django.db.models import Q |
|
|
|
|
from django.http import HttpResponseForbidden, HttpResponseRedirect, HttpResponse, Http404 |
|
|
|
|
from django.shortcuts import render, get_object_or_404, redirect |
|
|
|
|
from django.views.generic import ListView, DetailView, CreateView, View, UpdateView, TemplateView, FormView |
|
|
|
|
@ -10,6 +11,7 @@ from django.views.generic.base import ContextMixin |
|
|
|
|
from pprint import pprint, pformat |
|
|
|
|
import json |
|
|
|
|
import pydash as _ |
|
|
|
|
import re |
|
|
|
|
|
|
|
|
|
from .mixins import LastAccessMixin |
|
|
|
|
from .models import Project, ProjectFile, Portfolio, Candidate, Answer, Realty, Order |
|
|
|
|
@ -43,6 +45,7 @@ class ProjectFilterView(BaseMixin, View): |
|
|
|
|
projects = Project.objects |
|
|
|
|
|
|
|
|
|
if form.is_valid() and realty_form.is_valid(): |
|
|
|
|
keywords = form.cleaned_data.get('keywords') |
|
|
|
|
cro = form.cleaned_data.get('cro') |
|
|
|
|
work_type = form.cleaned_data.get('work_type') |
|
|
|
|
specialization = form.cleaned_data.get('specialization') |
|
|
|
|
@ -51,6 +54,12 @@ class ProjectFilterView(BaseMixin, View): |
|
|
|
|
construction_type = realty_form.cleaned_data.get('construction_type') |
|
|
|
|
location = realty_form.cleaned_data.get('location') |
|
|
|
|
|
|
|
|
|
if keywords: |
|
|
|
|
keywords = tuple(filter(None, re.split(r'\s|,|;', keywords))) |
|
|
|
|
|
|
|
|
|
for k in keywords: |
|
|
|
|
projects = projects.filter(Q(name__icontains=k) | Q(text__icontains=k)) |
|
|
|
|
|
|
|
|
|
projects = projects.filter(cro=cro) |
|
|
|
|
|
|
|
|
|
if work_type: |
|
|
|
|
@ -122,6 +131,8 @@ class ProjectFilterView(BaseMixin, View): |
|
|
|
|
except EmptyPage: |
|
|
|
|
projects = paginator.page(paginator.num_pages) |
|
|
|
|
|
|
|
|
|
# import code; code.interact(local=dict(globals(), **locals())) |
|
|
|
|
|
|
|
|
|
context.update({ |
|
|
|
|
'form': form, |
|
|
|
|
'realty_form': realty_form, |
|
|
|
|
|