remotes/origin/setup
ArturBaybulatov 10 years ago
parent 0d2396c48e
commit 5cff5daf60
  1. 2
      archilance/management/commands/generate_projects.py
  2. 3
      archilance/mixins.py
  3. 1
      archilance/settings/base.py
  4. 129
      assets/index.js
  5. 0
      common/templates/templatetags/inspect_.html
  6. 12
      common/templatetags/common_tags.py
  7. 62
      projects/forms.py
  8. 26
      projects/templates/customer_project_create.html
  9. 259
      projects/templates/project_filter.html
  10. 179
      projects/templates/project_list.html
  11. 8
      projects/urls.py
  12. 84
      projects/views.py
  13. 4
      templates/partials/base.html
  14. 4
      templates/partials/header.html

@ -47,7 +47,7 @@ class Command(BaseCommand):
# ('id', 'Relation? False', 'Null? False', 'Blank? True', 'Hidden? False'),
# ('price_and_term_required', 'Relation? False', 'Null? False', 'Blank? True', 'Hidden? False'),
# ('text', 'Relation? False', 'Null? False', 'Blank? True', 'Hidden? False'),

@ -1,3 +1,4 @@
from django.conf import settings
from django.contrib.sites.models import Site
from django.views.generic.base import ContextMixin
@ -16,6 +17,8 @@ class BaseMixin(ContextMixin):
c['domain'] = Site.objects.get_current().domain
c['TEMPLATE_DEBUG'] = settings.TEMPLATE_DEBUG
return c

@ -12,6 +12,7 @@ SECRET_KEY = 'vb6@b9zj7^f!^+x*e8=e!oundyu1!e*&0i(3gu2xwo4%fx4h&n'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True # Show debug info in templates. See `projects/templates/project_filter.html`
ALLOWED_HOSTS = []

@ -3,7 +3,7 @@ var $specSelects = $('.-spec-select')
var specSelectOptions = {
language: 'ru',
//minimumInputLength: 1, // Commented out to immediately load remote data
placeholder: '', // Required by `allowClear`
placeholder: 'Выберите специализацию', // Required by `allowClear`
allowClear: true,
ajax: {
@ -52,8 +52,7 @@ if (chosenSpecId)
updateSpecializationWidgets(chosenSpecId)
$specSelects.on('change', function($evt) {
var specId = $evt.added.id
updateSpecializationWidgets(specId)
updateSpecializationWidgets($evt.added ? $evt.added.id : null)
})
@ -94,7 +93,7 @@ var $locationSelects = $('.-location-select')
var locationSelectOptions = {
language: 'ru',
placeholder: '', // Required by `allowClear`
placeholder: 'Выберите местоположение', // Required by `allowClear`
allowClear: true,
}
@ -119,8 +118,7 @@ getLocationTree(null).then(function(locs) {
$locationSelects.on('change', function($evt) {
var locId = $evt.added.id
updateLocationWidgets(locId)
updateLocationWidgets($evt.added ? $evt.added.id : null)
})
@ -244,67 +242,70 @@ function getSpecializationTree(specId) {
var specs = {
specLevel1: null, specLevel2: null, specLevel3: null, specLevel4: null,
}
return $.ajax({url: '/api/specializations/' + specId + '/', method: 'GET', dataType: 'json'})
.then(function(spec) {
if (spec.level === 1) {
return _.merge(specs, {specLevel1: spec})
} else if (spec.level === 2) {
var specLevel2 = spec
return $.ajax({url: '/api/specializations/' + specLevel2.parent.id + '/', method: 'GET', dataType: 'json'})
.then(function(spec) {
var specLevel1 = spec
return _.merge(specs, {
specLevel1: specLevel1,
specLevel2: specLevel2,
if (specId === null) {
return $.when(specs)
} else {
return $.ajax({url: '/api/specializations/' + specId + '/', method: 'GET', dataType: 'json'})
.then(function(spec) {
if (spec.level === 1) {
return _.merge(specs, {specLevel1: spec})
} else if (spec.level === 2) {
var specLevel2 = spec
return $.ajax({url: '/api/specializations/' + specLevel2.parent.id + '/', method: 'GET', dataType: 'json'})
.then(function(spec) {
var specLevel1 = spec
return _.merge(specs, {
specLevel1: specLevel1,
specLevel2: specLevel2,
})
})
})
} else if (spec.level === 3) {
var specLevel3 = spec
return $.ajax({url: '/api/specializations/' + specLevel3.parent.id + '/', method: 'GET', dataType: 'json'})
.then(function(spec) {
var specLevel2 = spec
return $.ajax({url: '/api/specializations/' + specLevel2.parent.id + '/', method: 'GET', dataType: 'json'})
.then(function(spec) {
var specLevel1 = spec
return _.merge(specs, {
specLevel1: specLevel1,
specLevel2: specLevel2,
specLevel3: specLevel3,
} else if (spec.level === 3) {
var specLevel3 = spec
return $.ajax({url: '/api/specializations/' + specLevel3.parent.id + '/', method: 'GET', dataType: 'json'})
.then(function(spec) {
var specLevel2 = spec
return $.ajax({url: '/api/specializations/' + specLevel2.parent.id + '/', method: 'GET', dataType: 'json'})
.then(function(spec) {
var specLevel1 = spec
return _.merge(specs, {
specLevel1: specLevel1,
specLevel2: specLevel2,
specLevel3: specLevel3,
})
})
})
})
} else if (spec.level === 4) {
var specLevel4 = spec
return $.ajax({url: '/api/specializations/' + specLevel4.parent.id + '/', method: 'GET', dataType: 'json'})
.then(function(spec) {
var specLevel3 = spec
return $.ajax({url: '/api/specializations/' + specLevel3.parent.id + '/', method: 'GET', dataType: 'json'})
.then(function(spec) {
var specLevel2 = spec
return $.ajax({url: '/api/specializations/' + specLevel2.parent.id + '/', method: 'GET', dataType: 'json'})
.then(function(spec) {
var specLevel1 = spec
return _.merge(specs, {
specLevel1: specLevel1,
specLevel2: specLevel2,
specLevel3: specLevel3,
specLevel4: specLevel4,
})
} else if (spec.level === 4) {
var specLevel4 = spec
return $.ajax({url: '/api/specializations/' + specLevel4.parent.id + '/', method: 'GET', dataType: 'json'})
.then(function(spec) {
var specLevel3 = spec
return $.ajax({url: '/api/specializations/' + specLevel3.parent.id + '/', method: 'GET', dataType: 'json'})
.then(function(spec) {
var specLevel2 = spec
return $.ajax({url: '/api/specializations/' + specLevel2.parent.id + '/', method: 'GET', dataType: 'json'})
.then(function(spec) {
var specLevel1 = spec
return _.merge(specs, {
specLevel1: specLevel1,
specLevel2: specLevel2,
specLevel3: specLevel3,
specLevel4: specLevel4,
})
})
})
})
})
}
})
})
})
}
})
}
}

@ -5,14 +5,14 @@ import os
register = template.Library()
@register.inclusion_tag('templatetags/inspect.html', takes_context=True)
def inspect(context, obj):
return {'obj': pformat(obj.__dict__)}
# @register.inclusion_tag('templatetags/inspect.html', takes_context=True)
# def inspect(context, obj):
# return {'obj': pformat(obj.__dict__)}
@register.inclusion_tag('templatetags/inspect.html', takes_context=True)
def inspect2(context, obj):
return {'obj': pformat(dir(obj))}
@register.filter('inspect')
def inspect(obj):
return pformat(obj.__dict__)
@register.simple_tag

@ -2,6 +2,8 @@ from django import forms
from django.db.models import Q
from django.forms.models import inlineformset_factory
from mptt.forms import TreeNodeChoiceField
from pprint import pprint, pformat
import itertools
from .models import Project, ProjectFile, Portfolio, Answer, Realty, PortfolioPhoto, Stage, Specialization
from common.models import Location
@ -11,8 +13,59 @@ from users.models import User
# RealtyFormSet = inlineformset_factory(Project, Realty)
class ProjectsForm(forms.Form):
name = forms.CharField(max_length=255)
class ProjectFilterForm(forms.ModelForm):
class Meta:
model = Project
fields = (
'cro',
'work_type',
'specialization',
)
widgets = {
'work_type': forms.Select(attrs={'class': 'selectpicker'}),
}
def __init__(self, *args, **kwargs):
self.request = kwargs.pop('request')
super().__init__(*args, **kwargs)
self.fields['work_type'].choices = tuple(itertools.chain((('',''),), self.fields['work_type'].choices))
self.fields['work_type'].required = False
self.fields['work_type'].initial = ''
self.fields['specialization'].required = False
self.fields['specialization'].queryset = Specialization.objects.root_nodes()[0].get_descendants()
class ProjectFilterRealtyForm(forms.ModelForm):
class Meta:
model = Realty
fields = (
'building_classification',
'construction_type',
'location',
)
widgets = {
'building_classification': forms.Select(attrs={'class': 'selectpicker'}),
'construction_type': forms.Select(attrs={'class': 'selectpicker'}),
}
def __init__(self, *args, **kwargs):
self.request = kwargs.pop('request')
super().__init__(*args, **kwargs)
self.fields['building_classification'].empty_label = ''
self.fields['building_classification'].required = False
self.fields['construction_type'].empty_label = ''
self.fields['construction_type'].required = False
self.fields['location'].queryset = Location.objects.root_nodes()[0].get_descendants()
class CustomerProjectEditForm(forms.ModelForm):
@ -52,9 +105,7 @@ class CustomerProjectEditForm(forms.ModelForm):
super().__init__(*args, **kwargs)
self.fields['realty'].empty_label = 'Создать новый'
self.fields['specialization'].queryset = Specialization.objects.root_nodes()[0].get_descendants()
self.fields['specialization'].widget.attrs = {'class': '-spec-select', 'style': 'width: 100%'}
if self.instance.pk:
self.fields['files'].queryset = self.instance.files
@ -168,3 +219,6 @@ class CustomerProjectDeleteForm(forms.Form):
super().__init__(*args, **kwargs)
self.fields['pk'].queryset = self.req.user.projects.filter(Q(state='active') | Q(state='trashed'))
# import code; code.interact(local=dict(globals(), **locals()))

@ -83,19 +83,19 @@
</div>
<div class="polsF1 disTab">
<div class="col-lg-3">
<input type='hidden' class="-spec-select -spec-select-level-1" style="width: 100%">
<input type="hidden" class="-spec-select -spec-select-level-1" style="width: 100%">
</div>
<div class="col-lg-3">
<input type='hidden' class="-spec-select -spec-select-level-2" style="width: 100%">
<input type="hidden" class="-spec-select -spec-select-level-2" style="width: 100%">
</div>
<div class="col-lg-3">
<input type='hidden' class="-spec-select -spec-select-level-3" style="width: 100%">
<input type="hidden" class="-spec-select -spec-select-level-3" style="width: 100%">
</div>
<div class="col-lg-3">
<input type='hidden' class="-spec-select -spec-select-level-4" style="width: 100%">
<input type="hidden" class="-spec-select -spec-select-level-4" style="width: 100%">
</div>
<input type="hidden" id="chosenSpecId" name="{{ form.specialization.html_name }}" value="{{ form.specialization.value }}">
@ -253,30 +253,22 @@
</div>
<div class="polsF1 polsF2 disTab">
<div class="col-lg-3">
<input type='hidden' class="-location-select -location-select-country" style="width: 100%">
<input type="hidden" class="-location-select -location-select-country" style="width: 100%">
</div>
<div class="col-lg-3">
<input type='hidden' class="-location-select -location-select-region" style="width: 100%">
<input type="hidden" class="-location-select -location-select-region" style="width: 100%">
</div>
<div class="col-lg-3">
<input type='hidden' class="-location-select -location-select-city" style="width: 100%">
<input type="hidden" class="-location-select -location-select-city" style="width: 100%">
</div>
<input type="hidden" id="chosenLocationId" name="{{ realty_form.location.html_name }}" value="{{ realty_form.location.value }}">
<div class="col-lg-3 make-new">
<label>
<input
type="checkbox"
{% if form.cro.value %}checked{% endif %}
name="{{ form.cro.html_name }}">
<span></span>
</label>
<p>Требуется допуск СРО</p>
<label>{{ form.cro }}<span></span></label>
<p>Требуется допуск (СРО)</p>
</div>
</div>

@ -0,0 +1,259 @@
{% extends 'partials/base.html' %}
{% load common_tags %}
{% block content %}
{% include 'partials/header.html' %}
<div class="container mainScore">
<div class="row">
<div class="col-lg-12">
<p class="titleScore">Биржа проектов</p>
</div>
<form action="{% url 'projects:project-filter' %}" method="GET" novalidate>
<div class="col-lg-12">
<div class="filter clearfix">
<div class="triangle1"></div>
<div class="titleF1 disTab">
<div class="col-lg-3">Тип работы</div>
</div>
<div class="polsF1 disTab">
<div class="col-lg-3">
{{ form.work_type }}
</div>
</div>
<div class="titleF1 disTab">
<div class="col-lg-3">Специализации</div>
<div class="col-lg-9"></div>
</div>
<div class="polsF1 disTab">
<div class="col-lg-3">
<input type="hidden" class="-spec-select -spec-select-level-1" style="width: 100%">
</div>
<div class="col-lg-3">
<input type="hidden" class="-spec-select -spec-select-level-2" style="width: 100%">
</div>
<div class="col-lg-3">
<input type="hidden" class="-spec-select -spec-select-level-3" style="width: 100%">
</div>
<div class="col-lg-3">
<input type="hidden" class="-spec-select -spec-select-level-4" style="width: 100%">
</div>
<input type="hidden" id="chosenSpecId" name="{{ form.specialization.html_name }}" value="{{ form.specialization.value }}">
</div>
<div class="searchF1">
<div class="col-lg-6">
<input type="text" class="searchInp box-sizing" placeholder="Ключевые слова" name="search">
</div>
<div class="col-lg-3">
<a href="#" class="findReal" onclick="$(this).closest('form').submit(); return false">
найти проект
</a>
</div>
<div class="col-lg-3">
<a href="{% url 'projects:project-filter' %}" class="clearSearch">
Очистить фильтр
</a>
</div>
</div>
<div class="resSearchF1">
<div class="col-lg-3">
<p class="titleResF1">Расширенный поиск</p>
<button class="resButtonF1">
<span class="glyphicon glyphicon-arrow-up" aria-hidden="true"></span>
</button>
</div>
<div class="col-lg-9">
<div class="borderS1"></div>
</div>
</div>
<div class="slideRes disTab activeSlide">
<div class="titleF1 disTab">
<div class="col-lg-3">Классификация здания</div>
<div class="col-lg-3">Вид строительства</div>
<div class="col-lg-3"></div>
</div>
<div class="polsF1 disTab">
<div class="col-lg-3">
{{ realty_form.building_classification }}
</div>
<div class="col-lg-3">
{{ realty_form.construction_type }}
</div>
</div>
</div>
<div class="slideRes disTab activeSlide">
<div class="titleF1 disTab">
<div class="col-lg-3">Местоположение</div>
</div>
<div class="polsF1 disTab">
<div class="col-lg-3">
<input type="hidden" class="-location-select -location-select-country" style="width: 100%">
</div>
<div class="col-lg-3">
<input type="hidden" class="-location-select -location-select-region" style="width: 100%">
</div>
<div class="col-lg-3">
<input type="hidden" class="-location-select -location-select-city" style="width: 100%">
</div>
<input type="hidden" id="chosenLocationId" name="{{ realty_form.location.html_name }}" value="{{ realty_form.location.value }}">
</div>
<div class="sro">
<div class="col-lg-12">
<label>{{ form.cro }}<span></span></label>
<p>Требуется допуск (СРО)</p>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-12">
<p class="titleScore">{{ display_msg }}</p>
<div class="linkSort">
<p>Сортировать по:</p>
{# <a href="javascript:void(0)" class="activeSort">#}
{# цене#}
{# <span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span>#}
{# </a>#}
{# <a href="javascript:void(0)">#}
{# cорту#}
{# <span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span>#}
{# </a>#}
{# <a href="javascript:void(0)">#}
{# рейтингу#}
{# <span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span>#}
{# </a>#}
{# <a href="javascript:void(0)">#}
{# дате размещения#}
{# <span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span>#}
{# </a>#}
{# <a href="javascript:void(0)">#}
{# ответам#}
{# <span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span>#}
{# </a>#}
{# <a href="javascript:void(0)">#}
{# просмотрам#}
{# <span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span>#}
{# </a>#}
<button type="submit" name="order_by" value="budget">цене</button>
<button type="submit" name="order_by" value="created">дате размещения</button>
<button type="submit" name="order_by" value="views">просмотрам</button>
</div>
</div>
</form>
<div class="projectsBlock disTab">
{% for proj in projects %}
<div class="projectPro clearfix">
<div class="col-lg-9 leftPro">
<p class="titlePro">
<a href="{% url 'projects:detail' pk=proj.pk %}">{{ proj }}</a>
</p>
<ul class="desPro">
<li>
Объект "{{ proj.realty.name }}"
</li>
<li>
<span>0</span> ответ от имени группы
</li>
</ul>
<p class="textPro">{{ proj.text }}</p>
{% if TEMPLATE_DEBUG %}
<pre class="textPro"><!--
-->{{ proj|inspect }}<br><br><!--
-->Specialization: {{ proj.specialization }}<br><!--
-->Realty location: {{ proj.realty.location }}<br><!--
-->Constr. type: {{ proj.realty.construction_type }}<br><!--
-->Build. classif.: {{ proj.realty.building_classification }}<br><!--
--></pre>
{% endif %}
<ul class="listPro">
<li>{{ proj.created }}</li>
<li>0</li>
<li>{{ proj.answers.count }}</li>
<li>{{ proj.user }}</li>
</ul>
</div>
<div class="col-lg-3 rightPro">
<p class="cenaPro">
{{ proj.budget }} <i class="fa fa-rub"></i>
</p>
<ul>
{% if proj.secure_deal %}
<li>Безопасная сделка</li>
{% endif %}
<li>
Стадия: "П"
</li>
<li>
Отказаться и переместить
в корзину
</li>
</ul>
</div>
</div>
{% endfor %}
</div>
<div class="col-lg-12 pagin">
{% include 'partials/pagination.html' %}
</div>
{% include 'partials/footer.html' %}
</div>
</div>
{% endblock %}

@ -1,179 +0,0 @@
{% extends 'partials/base.html' %}
{% block content %}
{% include 'partials/header.html' %}
<div class="container mainScore">
<div class="row">
<div class="col-lg-12">
<p class="titleScore">Биржа проектов</p>
</div>
<div class="col-lg-12">
<div class="filter clearfix">
<div class="triangle1"></div>
<div class="titleF1 disTab">
<div class="col-lg-3">Специализации:</div>
<div class="col-lg-3"></div>
<div class="col-lg-3"></div>
<div class="col-lg-3"></div>
</div>
<div class="polsF1 disTab">
<div class="col-lg-3">
<input type='hidden' class="-spec-select -spec-select-level-1" style="width: 100%">
</div>
<div class="col-lg-3">
<input type='hidden' class="-spec-select -spec-select-level-2" style="width: 100%">
</div>
<div class="col-lg-3">
<input type='hidden' class="-spec-select -spec-select-level-3" style="width: 100%">
</div>
<div class="col-lg-3">
<input type='hidden' class="-spec-select -spec-select-level-4" style="width: 100%">
</div>
</div>
<div class="searchF1">
<div class="col-lg-6">
<input type="text" class="searchInp box-sizing" placeholder="Ключевые слова" name="search">
</div>
<div class="col-lg-3">
<a href="javascript:void(0)" class="findReal">
найти исполнителя
</a>
</div>
<div class="col-lg-3">
<a href="javascript:void(0)" class="clearSearch">
Очистить фильт
</a>
</div>
</div>
<div class="resSearchF1">
<div class="col-lg-3">
<p class="titleResF1">Расширенный поиск</p>
<button class="resButtonF1">
<span class="glyphicon glyphicon-arrow-up" aria-hidden="true"></span>
</button>
</div>
<div class="col-lg-9">
<div class="borderS1"></div>
</div>
</div>
<div class="slideRes disTab activeSlide">
<div class="titleF1 disTab">
<div class="col-lg-3">Классификация здания</div>
<div class="col-lg-3">Вид строительства</div>
<div class="col-lg-3">Местоположение</div>
<div class="col-lg-3"></div>
</div>
<div class="polsF1 disTab">
<div class="col-lg-3">
<select class="selectpicker">
<option></option>
</select>
</div>
<div class="col-lg-3">
<select class="selectpicker">
</select>
</div>
<div class="col-lg-3">
<select class="selectpicker">
</select>
</div>
<div class="col-lg-3">
<select class="selectpicker">
</select>
</div>
</div>
<div class="sro">
<div class="col-lg-12">
<label><input type="checkbox" value="1" name="k"><span></span></label>
<p>Требуется допуск (СРО)</p>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-12">
<p class="titleScore">Список проектов</p>
<div class="linkSort">
<p>Сортировать по:</p>
<a href="javascript:void(0)" class="activeSort">
цене
<span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span>
</a>
<a href="javascript:void(0)">
cорту
<span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span>
</a>
<a href="javascript:void(0)">
рейтингу
<span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span>
</a>
<a href="javascript:void(0)">
дате размещения
<span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span>
</a>
<a href="javascript:void(0)">
ответам
<span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span>
</a>
<a href="javascript:void(0)">
просмотрам
<span class="glyphicon glyphicon-triangle-bottom" aria-hidden="true"></span>
</a>
</div>
</div>
<div class="projectsBlock disTab">
{% for proj in object_list %}
<div class="projectPro clearfix">
<div class="col-lg-9 leftPro">
<p class="titlePro">
<a href="{% url 'projects:detail' pk=proj.pk %}">{{ proj }}</a>
</p>
<ul class="desPro">
<li>
Объект "{{ proj.realty.name }}"
</li>
<li>
<span>0</span> ответ от имени группы
</li>
</ul>
<p class="textPro">{{ proj.text }}</p>
<ul class="listPro">
<li>{{ proj.created }}</li>
<li>0</li>
<li>{{ proj.answers.count }}</li>
<li>{{ proj.user }}</li>
</ul>
</div>
<div class="col-lg-3 rightPro">
<p class="cenaPro">
{{ proj.budget }} <i class="fa fa-rub"></i>
</p>
<ul>
{% if proj.secure_deal %}
<li>Безопасная сделка</li>
{% endif %}
<li>
Стадия: "П"
</li>
<li>
Отказаться и переместить
в корзину
</li>
</ul>
</div>
</div>
{% endfor %}
</div>
<div class="col-lg-12 pagin">
{% include 'partials/pagination.html' %}
</div>
{% include 'partials/footer.html' %}
</div>
</div>
{% endblock %}

@ -3,6 +3,8 @@ from django.views.generic import TemplateView
from .views import (
add_candidate,
contractor_portfolio_create,
ContractorPortfolioUpdateView,
ContractorProjectAnswerView,
CustomerProjectCreateView,
CustomerProjectDeleteView,
@ -11,16 +13,14 @@ from .views import (
CustomerProjectTrashView,
OfferOrderView,
ProjectComparisonView,
ProjectsView,
ProjectFilterView,
ProjectView,
contractor_portfolio_create,
ContractorPortfolioUpdateView,
)
app_name = 'projects'
urlpatterns = [
urls.url(r'^$', ProjectsView.as_view(), name='list'),
urls.url(r'^$', ProjectFilterView.as_view(), name='project-filter'),
urls.url(r'^create/$', CustomerProjectCreateView.as_view(), name='customer-project-create'),
urls.url(r'^(?P<pk>\d+)/$', ProjectView.as_view(), name='detail'),

@ -17,19 +17,91 @@ from users.models import User
from .forms import (
ContractorProjectAnswerForm,
CustomerProjectEditForm,
PortfolioForm,
CustomerProjectDeleteForm,
CustomerProjectEditForm,
CustomerProjectEditForm,
CustomerProjectRestoreForm,
CustomerProjectTrashForm,
PortfolioForm,
ProjectFilterForm,
ProjectFilterRealtyForm,
RealtyForm,
)
class ProjectsView(ListView):
model = Project
template_name = 'project_list.html'
class ProjectFilterView(BaseMixin, View):
template_name = 'project_filter.html'
form_class = ProjectFilterForm
realty_form = ProjectFilterRealtyForm
def get(self, request, *args, **kwargs):
form = self.form_class(request.GET, request=request)
realty_form = self.realty_form(request.GET, request=request, prefix='realty_form')
context = self.get_context_data(**_.merge({}, request.GET, kwargs))
display_msg = 'Список проектов'
projects = Project.objects
if form.is_valid() and realty_form.is_valid():
cro = form.cleaned_data.get('cro')
work_type = form.cleaned_data.get('work_type')
specialization = form.cleaned_data.get('specialization')
building_classification = realty_form.cleaned_data.get('building_classification')
construction_type = realty_form.cleaned_data.get('construction_type')
location = realty_form.cleaned_data.get('location')
projects = projects.filter(cro=cro)
if work_type: projects = projects.filter(work_type=work_type)
if specialization:
projects = projects.filter(
specialization__lft__gte=specialization.lft,
specialization__rght__lte=specialization.rght,
)
if building_classification: projects = projects.filter(realty__building_classification=building_classification)
if construction_type: projects = projects.filter(realty__construction_type=construction_type)
if location:
projects = projects.filter(
realty__location__lft__gte=location.lft,
realty__location__rght__lte=location.rght,
)
project_count = projects.count()
display_msg = 'Найдено %s проектов' % project_count if project_count > 0 else 'Ничего не найдено'
else:
display_msg = 'Пожалуйста, введите корректные данные'
if form.errors:
messages.info(request, (
'<p>Произошла ошибка (form)</p>'
'<pre>{form}</pre>'
).format(form=pformat(form.errors)))
if realty_form and realty_form.errors:
messages.info(request, (
'<p>Произошла ошибка (realty_form)</p>'
'<pre>{realty_form}</pre>'
).format(realty_form=pformat(realty_form.errors)))
order_by = request.GET.get('order_by') # TODO: Validate
if order_by:
projects = projects.order_by(order_by)
projects = projects[:10]
context.update({
'form': form,
'realty_form': realty_form,
'projects': projects,
'display_msg': display_msg,
})
return render(request, self.template_name, context)
class ProjectView(BaseMixin, View):
@ -335,4 +407,6 @@ class ContractorPortfolioUpdateView(UpdateView):
def get_success_url(self):
return reverse('proje')
# import code; code.interact(local=dict(globals(), **locals()))

@ -25,9 +25,7 @@
<link rel='stylesheet' href='{% static "css/main.css" %}'>
<link rel='stylesheet' href='{% static "css/extra.css" %}'> <!-- Our additional CSS -->
<link rel='stylesheet' href='{% static "css/dev-colors.css" %}'> <!-- Dev-time only, temporary!!! -->
{% endcompress %}
{% endcompress %}
</head>
<body>

@ -9,7 +9,7 @@
<div class="col-lg-7">
<ul class="mainMenu">
<li class="icon_tm1">
<a href="{% url 'projects:list' %}">Биржа проектов</a>
<a href="{% url 'projects:project-filter' %}">Биржа проектов</a>
<span></span>
</li>
{% if request.user.is_contractor %}
@ -35,7 +35,7 @@
<div class="col-lg-7">
<ul class="mainMenu">
<li class="icon_tm1">
<a href="{% url 'projects:list' %}">Биржа проектов</a>
<a href="{% url 'projects:project-filter' %}">Биржа проектов</a>
<span></span>
</li>
<li class="icon_tm2">

Loading…
Cancel
Save