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'), # ('id', 'Relation? False', 'Null? False', 'Blank? True', 'Hidden? False'),
# ('price_and_term_required', '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'), # ('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.contrib.sites.models import Site
from django.views.generic.base import ContextMixin from django.views.generic.base import ContextMixin
@ -16,6 +17,8 @@ class BaseMixin(ContextMixin):
c['domain'] = Site.objects.get_current().domain c['domain'] = Site.objects.get_current().domain
c['TEMPLATE_DEBUG'] = settings.TEMPLATE_DEBUG
return c 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! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
TEMPLATE_DEBUG = True # Show debug info in templates. See `projects/templates/project_filter.html`
ALLOWED_HOSTS = [] ALLOWED_HOSTS = []

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

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

@ -2,6 +2,8 @@ from django import forms
from django.db.models import Q from django.db.models import Q
from django.forms.models import inlineformset_factory from django.forms.models import inlineformset_factory
from mptt.forms import TreeNodeChoiceField from mptt.forms import TreeNodeChoiceField
from pprint import pprint, pformat
import itertools
from .models import Project, ProjectFile, Portfolio, Answer, Realty, PortfolioPhoto, Stage, Specialization from .models import Project, ProjectFile, Portfolio, Answer, Realty, PortfolioPhoto, Stage, Specialization
from common.models import Location from common.models import Location
@ -11,8 +13,59 @@ from users.models import User
# RealtyFormSet = inlineformset_factory(Project, Realty) # RealtyFormSet = inlineformset_factory(Project, Realty)
class ProjectsForm(forms.Form): class ProjectFilterForm(forms.ModelForm):
name = forms.CharField(max_length=255) 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): class CustomerProjectEditForm(forms.ModelForm):
@ -52,9 +105,7 @@ class CustomerProjectEditForm(forms.ModelForm):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.fields['realty'].empty_label = 'Создать новый' self.fields['realty'].empty_label = 'Создать новый'
self.fields['specialization'].queryset = Specialization.objects.root_nodes()[0].get_descendants() 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: if self.instance.pk:
self.fields['files'].queryset = self.instance.files self.fields['files'].queryset = self.instance.files
@ -168,3 +219,6 @@ class CustomerProjectDeleteForm(forms.Form):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.fields['pk'].queryset = self.req.user.projects.filter(Q(state='active') | Q(state='trashed')) 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>
<div class="polsF1 disTab"> <div class="polsF1 disTab">
<div class="col-lg-3"> <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>
<div class="col-lg-3"> <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>
<div class="col-lg-3"> <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>
<div class="col-lg-3"> <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> </div>
<input type="hidden" id="chosenSpecId" name="{{ form.specialization.html_name }}" value="{{ form.specialization.value }}"> <input type="hidden" id="chosenSpecId" name="{{ form.specialization.html_name }}" value="{{ form.specialization.value }}">
@ -253,30 +253,22 @@
</div> </div>
<div class="polsF1 polsF2 disTab"> <div class="polsF1 polsF2 disTab">
<div class="col-lg-3"> <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>
<div class="col-lg-3"> <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>
<div class="col-lg-3"> <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> </div>
<input type="hidden" id="chosenLocationId" name="{{ realty_form.location.html_name }}" value="{{ realty_form.location.value }}"> <input type="hidden" id="chosenLocationId" name="{{ realty_form.location.html_name }}" value="{{ realty_form.location.value }}">
<div class="col-lg-3 make-new"> <div class="col-lg-3 make-new">
<label> <label>{{ form.cro }}<span></span></label>
<input <p>Требуется допуск (СРО)</p>
type="checkbox"
{% if form.cro.value %}checked{% endif %}
name="{{ form.cro.html_name }}">
<span></span>
</label>
<p>Требуется допуск СРО</p>
</div> </div>
</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 ( from .views import (
add_candidate, add_candidate,
contractor_portfolio_create,
ContractorPortfolioUpdateView,
ContractorProjectAnswerView, ContractorProjectAnswerView,
CustomerProjectCreateView, CustomerProjectCreateView,
CustomerProjectDeleteView, CustomerProjectDeleteView,
@ -11,16 +13,14 @@ from .views import (
CustomerProjectTrashView, CustomerProjectTrashView,
OfferOrderView, OfferOrderView,
ProjectComparisonView, ProjectComparisonView,
ProjectsView, ProjectFilterView,
ProjectView, ProjectView,
contractor_portfolio_create,
ContractorPortfolioUpdateView,
) )
app_name = 'projects' app_name = 'projects'
urlpatterns = [ 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'^create/$', CustomerProjectCreateView.as_view(), name='customer-project-create'),
urls.url(r'^(?P<pk>\d+)/$', ProjectView.as_view(), name='detail'), urls.url(r'^(?P<pk>\d+)/$', ProjectView.as_view(), name='detail'),

@ -17,19 +17,91 @@ from users.models import User
from .forms import ( from .forms import (
ContractorProjectAnswerForm, ContractorProjectAnswerForm,
CustomerProjectEditForm,
PortfolioForm,
CustomerProjectDeleteForm, CustomerProjectDeleteForm,
CustomerProjectEditForm, CustomerProjectEditForm,
CustomerProjectEditForm,
CustomerProjectRestoreForm, CustomerProjectRestoreForm,
CustomerProjectTrashForm, CustomerProjectTrashForm,
PortfolioForm,
ProjectFilterForm,
ProjectFilterRealtyForm,
RealtyForm, RealtyForm,
) )
class ProjectsView(ListView): class ProjectFilterView(BaseMixin, View):
model = Project template_name = 'project_filter.html'
template_name = 'project_list.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): class ProjectView(BaseMixin, View):
@ -335,4 +407,6 @@ class ContractorPortfolioUpdateView(UpdateView):
def get_success_url(self): def get_success_url(self):
return reverse('proje') return reverse('proje')
# import code; code.interact(local=dict(globals(), **locals())) # 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/main.css" %}'>
<link rel='stylesheet' href='{% static "css/extra.css" %}'> <!-- Our additional 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!!! --> <link rel='stylesheet' href='{% static "css/dev-colors.css" %}'> <!-- Dev-time only, temporary!!! -->
{% endcompress %}
{% endcompress %}
</head> </head>
<body> <body>

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

Loading…
Cancel
Save