PR-5 Финансовая информация доработка

in process...
remotes/origin/HEAD
booblegum 9 years ago
parent 972fafdf31
commit b0d76f2a32
  1. 99
      assets/js/build/user_profile_edit.js
  2. 25
      assets/js/src/seeds/user_check_statuses.js
  3. 4
      assets/js/src/user_profile_edit.js
  4. 43
      assets/sass/components/custom-components.sass
  5. 4
      users/models.py
  6. 146
      users/static/css/user_profile_edit.css
  7. 128
      users/static/sass/user-profile-edit.sass
  8. 237
      users/templates/user_profile_edit.html
  9. 188
      users/views.py

@ -49,12 +49,54 @@
var _avatar_upload = __webpack_require__(29);
var _bootstrap_tabs = __webpack_require__(16);
var _user_check_statuses = __webpack_require__(30);
$(function () {
(0, _avatar_upload.avatarUploadInit)();
(0, _bootstrap_tabs.tabsHashInit)();
(0, _user_check_statuses.checkBoxBindingInit)();
});
/***/ },
/***/ 16:
/***/ function(module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
function tabsHashInit() {
// store the currently selected tab in the hash value
$("a[data-toggle=tab]").on("shown.bs.tab", function (e) {
var target = $(e.target);
if (target.hasClass("tab-inserted")) {
target.siblings(".active").removeClass("active");
target.addClass("active");
return;
}
var id = target.attr("href").substr(1);
var scrollmem = $('body').scrollTop() || $('html').scrollTop();
window.location.hash = id;
$('html,body').scrollTop(scrollmem);
});
}
function restoreTab() {
// on load of the page: switch to the currently selected tab
var hash = window.location.hash;
var a = $("a[data-toggle=\"tab\"][href=\"" + hash + "\"]");
hash && a.tab('show');
}
exports.tabsHashInit = tabsHashInit;
exports.restoreTab = restoreTab;
/***/ },
/***/ 29:
/***/ function(module, exports) {
@ -106,6 +148,63 @@
exports.avatarUploadInit = avatarUploadInit;
/***/ },
/***/ 30:
/***/ function(module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
function checkBoxBindingInit() {
var $residency_checkBoxes = $('input[name=residency]');
var $legal_status_checkBoxes = $('input[name=legal_status]');
var $legal_status_boxes = $legal_status_checkBoxes.closest('div');
var shows = {
'russian_resident': ['individual', 'entity', 'employed'],
'non_russian_resident': ['individual', 'entity'],
'russian_stay_permit': ['individual']
};
// $legal_status_boxes.hide();
$residency_checkBoxes.first().attr("checked", true);
$legal_status_checkBoxes.first().attr("checked", true);
$residency_checkBoxes.on("click", function (e) {
$legal_status_checkBoxes.first().attr("checked", true);
$legal_status_boxes.hide();
var value = $(e.target).val();
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = shows[value][Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var legal_status = _step.value;
// console.log(legal_status);
$('input[value=' + legal_status + ']').closest('div').show();
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
});
}
exports.checkBoxBindingInit = checkBoxBindingInit;
/***/ }
/******/ });

@ -0,0 +1,25 @@
function checkBoxBindingInit() {
let $residency_checkBoxes = $('input[name=residency]');
let $legal_status_checkBoxes = $('input[name=legal_status]');
let $legal_status_boxes = $legal_status_checkBoxes.closest('div');
let shows = {
'russian_resident': ['individual', 'entity', 'employed'],
'non_russian_resident': ['individual', 'entity'],
'russian_stay_permit': ['individual'],
};
// $legal_status_boxes.hide();
$residency_checkBoxes.first().attr("checked", true);
$legal_status_checkBoxes.first().attr("checked", true);
$residency_checkBoxes.on("click", function (e) {
$legal_status_checkBoxes.first().attr("checked", true);
$legal_status_boxes.hide();
let value = $(e.target).val();
for (let legal_status of shows[value]){
// console.log(legal_status);
$(`input[value=${legal_status}]`).closest('div').show();
}
})
}
export {checkBoxBindingInit}

@ -1,5 +1,9 @@
import {avatarUploadInit} from './seeds/avatar_upload'
import {tabsHashInit, restoreTab} from './seeds/bootstrap_tabs'
import {checkBoxBindingInit} from './seeds/user_check_statuses'
$(function () {
avatarUploadInit();
tabsHashInit();
checkBoxBindingInit();
});

@ -234,6 +234,10 @@ textarea.description
width: 20px
height: 20px
label.fin_statuses
font-style: italic
color: #6b6868
.custom-check
cursor: pointer
display: inline-block
@ -499,3 +503,42 @@ textarea.description
background: none !important
color: #2c2c2c
opacity: 0.8
.rad
cursor: pointer
user-select: none
-webkit-user-select: none
-webkit-touch-callout: none
>
input
/* HIDE ORG RADIO & CHECKBOX
visibility: hidden
position: absolute
i
/* DEFAULT <i> STYLE
display: inline-block
vertical-align: middle
width: 24px
height: 24px
border-radius: 50%
transition: 0.2s
box-shadow: inset 0 0 0 16px #fff
border: 1px solid #cccccc
background: #cccccc
margin-right: 5px
&:hover > i
/* HOVER <i> STYLE
box-shadow: inset 0 0 0 3px #fff
background: #cccccc
> input:checked + i
/* (RADIO CHECKED) <i> STYLE
box-shadow: inset 0 0 0 3px #fff
background: #cccccc
/* RADIO & CHECKBOX STYLES
/* CHECKBOX OVERWRITE STYLES
label.rad
font-style: italic
color: #606060

@ -56,13 +56,13 @@ class UserFinancialInfo(models.Model):
RESIDENCIES = (
('russian_resident', 'Резидент РФ'),
('non_russian_resident', 'Нерезидент РФ'),
('refugee', 'Беженец'),
('russian_stay_permit', 'Вид на жительство'),
)
LEGAL_STATUSES = (
('individual', 'Физическое лицо'),
('legal_entity', 'ИП и юридическое лицо'),
('entity', 'Юридическое лицо'),
('employed', 'Частный предприниматель'),
)
address = models.CharField(max_length=1000)

@ -1,146 +0,0 @@
.mainContent {
padding: 43px 25px 40px 25px;
}
/*TODO: Привязать к ширине блока справа*/
.avatarInset {
width: 210px;
height: 210px;
}
.avatar {
background-color: #F1F1F1;
width: 228px;
height: 228px;
padding: 10px;
}
.simple-input, .simple-select {
height: 51px;
width: 100%;
border: 1px solid #cccccc;
outline: none;
padding: 5px 40px 5px 20px;
background-color: white;
margin-bottom: -1px;
}
.simple-input:-webkit-autofill, .simple-select:-webkit-autofill{
transition: background-color 5000s ease-in-out 0s
}
.simple-select select {
background-color: darkgray;
}
.simple-select {
display: flex;
align-items: center;
text-align: center;
}
.simple-select.fill{
background-color: #F2F2F2;
}
.simple-select .text{
color: #a3a3a3;
}
.toggle .btn {
padding: 14px 20px;
border-radius: 40px;
}
.bottom-line {
padding-bottom: 10px;
border-bottom: 1px solid #cccccc;
}
.top-line {
/*padding-bottom: 10px;*/
border-top: 1px solid #cccccc;
}
/* СУПЕР-костыльная кнопка. Не прикасаться!*/
.upload-new {
width: 50%;
height: 30px;
overflow: hidden;
cursor: pointer;
border-radius: 40px;
border: 1px solid #FF0029;
}
.upload-new:hover, .btn-simple:hover {
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
-webkit-transform: scale(1.04);
-moz-transform: scale(1.04);
transform: scale(1.04);
}
.upload-new, .btn-simple {
transition: all 0.3s;
cursor: pointer;
}
.upload-new input {
display: block !important;
width: 100% !important;
height: 30px !important;
opacity: 0 !important;
cursor: pointer;
}
.upload-new p {
line-height: 30px;
text-transform: uppercase;
margin: -30px 0 0 0;
/*padding: 0 5px 0 5px;*/
font-size: 12px;
text-align: center;
font-family: Myriad;
}
/** Конец супер-костыля**/
.row-eq-height {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
.info {
background-color: #F2F2F2;
padding: 50px 40px;
margin-top: 20px;
}
.btn-simple {
border-radius: 40px;
padding: 10px 15px;
border: 1px solid #FF0029;
/*color: black;*/
background: none;
font-family: Myriad;
font-weight: normal;
font-style: normal;
font-size: 14pt;
}
.no-margin .selected-element {
margin: 0;
}
.-live-image-avatar-upload-container .-position-relative-parent {
position: relative
}
.-live-image-avatar-upload-container .-live-image-delete {
position: absolute;
top: 0;
right: 0;
background-color: white;
}

@ -0,0 +1,128 @@
.mainContent
padding: 43px 25px 40px 25px
/*TODO: Привязать к ширине блока справа
.avatarInset
width: 210px
height: 210px
.avatar
background-color: #F1F1F1
width: 228px
height: 228px
padding: 10px
.simple-input, .simple-select
height: 51px
width: 100%
border: 1px solid #cccccc
outline: none
padding: 5px 40px 5px 20px
background-color: white
margin-bottom: -1px
.simple-input:-webkit-autofill
transition: background-color 5000s ease-in-out 0s
.simple-select
&:-webkit-autofill
transition: background-color 5000s ease-in-out 0s
select
background-color: darkgray
display: flex
align-items: center
text-align: center
&.fill
background-color: #F2F2F2
.text
color: #a3a3a3
.toggle .btn
padding: 14px 20px
border-radius: 40px
.bottom-line
padding-bottom: 10px
border-bottom: 1px solid #cccccc
.top-line
/*padding-bottom: 10px;
border-top: 1px solid #cccccc
/* СУПЕР-костыльная кнопка. Не прикасаться -)
.upload-new
width: 50%
height: 30px
overflow: hidden
cursor: pointer
border-radius: 40px
border: 1px solid #FF0029
&:hover
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2)
-webkit-transform: scale(1.04)
-moz-transform: scale(1.04)
transform: scale(1.04)
.btn-simple:hover
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2)
-webkit-transform: scale(1.04)
-moz-transform: scale(1.04)
transform: scale(1.04)
.upload-new, .btn-simple
transition: all 0.3s
cursor: pointer
.upload-new
input
display: block !important
width: 100% !important
height: 30px !important
opacity: 0 !important
cursor: pointer
p
line-height: 30px
text-transform: uppercase
margin: -30px 0 0 0
/*padding: 0 5px 0 5px;
font-size: 12px
text-align: center
font-family: Myriad
/** Конец супер-костыля*
.row-eq-height
display: -webkit-box
display: -webkit-flex
display: -ms-flexbox
display: flex
.info, .financial_info
background-color: #F2F2F2
padding: 50px 40px
margin-top: 20px
.btn-simple
border-radius: 40px
padding: 10px 15px
border: 1px solid #FF0029
/*color: black;
background: none
font-family: Myriad
font-weight: normal
font-style: normal
font-size: 14pt
.no-margin .selected-element
margin: 0
.-live-image-avatar-upload-container
.-position-relative-parent
position: relative
.-live-image-delete
position: absolute
top: 0
right: 0
background-color: white

@ -5,17 +5,13 @@
{#{% block old_css %}{% endblock %}#}
{% block personal_css %}
<link rel='stylesheet' href='{% sass_src "lib/proekton-components/sass/components.sass" %}'>
<link rel='stylesheet' href='{% sass_src "sass/old_main.sass" %}'>
<link rel='stylesheet' href='{% static "css/project_filter.css" %}'>{# other #}
<link rel='stylesheet' href='{% static "css/font-awesome.min.css" %}'>
<link rel='stylesheet' href='{% static "css/user_profile_edit.css" %}'>
<link rel='stylesheet' href='{% static "css/custom-checkboxes.css" %}'>
<link rel='stylesheet' href='{% sass_src "sass/components/custom-components.sass" %}'>
<link rel='stylesheet' href='{% sass_src "sass/user-profile-edit.sass" %}'>
{% endblock %}
{% block content %}
<div class="container main-scope">
<div class="row main-content">
{# <div class="old-main">#}
<form method="POST" enctype="multipart/form-data" novalidate>
{% csrf_token %}
{% if request.user.is_customer %}
@ -215,113 +211,166 @@
<div class="col-lg-12">
<div class="top-line" style="padding-top: 15px">
<div class="btn-group toggle" role="group" aria-label="...">
<a style="z-index: 0" href="#"
{# <a style="z-index: 0" href="{% url 'users:user-profile-edit' pk=pk %}"#}
<a data-toggle="tab" href="#info"
role="button"
class="btn btn-default active">Общая информация</a>
<a href="#"
class="btn btn-default" role="button">Финансовая информация</a>
class="btn btn-default tab-inserted active">Общая информация</a>
<a data-toggle="tab" href="#financial_info"
class="btn btn-default tab-inserted" role="button">Финансовая
информация</a>
</div>
</div>
</div>
</div>
<div class="row info">
<div class="col-lg-3">
<div class="header"> Дата рождения</div>
<div class="birth_edit_dat">
{{ form.date_of_birth }}
</div>
</div>
<div class="col-lg-3">
<div style="position: relative" class="select-box-container custom-select"
id="gender">
<div class="select-box-header">
<div class="header">Пол</div>
<div class="tab-content">
<div id="info" class="tab-pane fade in active">
<div class="row info">
<div class="col-lg-3">
<div class="header"> Дата рождения</div>
<div class="birth_edit_dat">
{{ form.date_of_birth }}
</div>
</div>
<input class="simple-select" placeholder="Выберите"
value="{{ form.get_gender_display }}" readonly>
<input type="hidden" name="{{ form.gender.html_name }}"
value="{{ form.gender.value }}">
<div class="select-box-options" style="width: 100%; display: none">
<div style="min-width: inherit" class="box-wrapper">
<ul>
{% for id, text in form.gender.field.choices %}
<li data-id="{{ id }}">{{ text }}</li>
{% endfor %}
</ul>
<div class="col-lg-3">
<div style="position: relative" class="select-box-container custom-select"
id="gender">
<div class="select-box-header">
<div class="header">Пол</div>
</div>
<input class="simple-select" placeholder="Выберите"
value="{{ form.get_gender_display }}" readonly>
<input type="hidden" name="{{ form.gender.html_name }}"
value="{{ form.gender.value }}">
<div class="select-box-options" style="width: 100%; display: none">
<div style="min-width: inherit" class="box-wrapper">
<ul>
{% for id, text in form.gender.field.choices %}
<li data-id="{{ id }}">{{ text }}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="col-lg-3">
{% if request.user.is_contractor %}
<div style="position: relative"
class="select-box-container custom-select"
id="gender">
<div class="select-box-header">
<div class="header">Статус</div>
</div>
<input class="simple-select" placeholder="Выберите"
value="{{ form.get_status_display }}" readonly>
<input type="hidden" name="{{ form.contractor_status.html_name }}"
value="{{ form.contractor_status.value }}">
<div class="select-box-options" style="width: 100%; display: none">
<div style="min-width: inherit" class="box-wrapper">
<ul>
{% for id, text in form.contractor_status.field.choices %}
<li data-id="{{ id }}">{{ text }}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
{% else %}
<div class="header">{{ form.organization_name.label }}</div>
<input name="organization_name" class="simple-input"
placeholder="Название организации"
{# autocomplete="False"#}
value="{{ form.organization_name.value }}">
{% endif %}
</div>
<div class="col-lg-3">
<div class="header">Skype</div>
<input name="{{ form.skype.html_name }}" class="simple-input"
placeholder="skype id"
value="{{ form.skype.value }}">
</div>
<div class="clearfix visible-lg"></div>
<div class="col-lg-3 vertical-child">
<div class="header">Сайт</div>
<input name="{{ form.website.html_name }}" class="simple-input"
placeholder="example.com"
value="{{ form.website.value }}">
</div>
<div class="col-lg-3 vertical-child">
<div class="header">Телефон</div>
<input name="{{ form.phone.html_name }}" class="simple-input phone"
placeholder="+7(909)999 00 00"
value="{{ form.phone.value }}"
type="tel">
</div>
<div class="col-lg-3 vertical-child">
<div class="header">Второй телефон</div>
<input name="{{ form.phone2.html_name }}" class="simple-input phone"
placeholder="+7(909)999 00 00"
value="{{ form.phone2.value }}"
type="tel">
</div>
<div class="col-lg-3 vertical-child" style="text-align: center">
<div style="display: block;" class="header">&nbsp;</div>
<input type="submit" class="btn btn-simple" value="СОХРАНИТЬ">
</div>
</div>
</div>
<div class="col-lg-3">
{% if request.user.is_contractor %}
<div style="position: relative" class="select-box-container custom-select"
id="gender">
<div class="select-box-header">
<div class="header">Статус</div>
<div id="financial_info" class="tab-pane fade">
<div class="row financial_info">
<div class="row">
<div class="col-lg-6">
<div class="header">Имя, Фамилия, Отчество</div>
<input name="fio" class="simple-input"
placeholder="Иванов Иван Иванович"
value="{{ fin_info_form.fio.value }}">
</div>
<input class="simple-select" placeholder="Выберите"
value="{{ form.get_status_display }}" readonly>
<input type="hidden" name="{{ form.contractor_status.html_name }}"
value="{{ form.contractor_status.value }}">
<div class="select-box-options" style="width: 100%; display: none">
<div style="min-width: inherit" class="box-wrapper">
<ul>
{% for id, text in form.contractor_status.field.choices %}
<li data-id="{{ id }}">{{ text }}</li>
{% endfor %}
</ul>
</div>
<div class="col-lg-3">
<div class="header"> Дата рождения</div>
{# <div class="birth_edit_dat">#}
{{ fin_info_form.date_of_birth }}
{# </div>#}
</div>
<div class="col-lg-3 vertical-child">
<div class="header">Телефон</div>
<input name="{{ form.phone.html_name }}" class="simple-input phone"
placeholder="+7(909)999 00 00"
value="{{ fin_info_form.phone.value }}"
type="tel">
</div>
</div>
{% else %}
<div class="header">{{ form.organization_name.label }}</div>
<input name="organization_name" class="simple-input"
placeholder="Название организации"
{# autocomplete="False"#}
value="{{ form.organization_name.value }}">
{% endif %}
<div class="header">Резиденство</div>
<div class="row">
{% for residence in RESIDENCIES %}
<div class="col-lg-3">
<label class="mod-align-center fin_statuses">
<input name="residency" class="custom-radio" type="radio"
value="{{ residence.0 }}">
&nbsp; {{ residence.1 }}
</label>
</div>
{% endfor %}
</div>
<div class="header">Юридический статус</div>
<div class="row">
{% for legal_status in LEGAL_STATUSES %}
<div class="col-lg-3">
<label class="mod-align-center fin_statuses">
<input name="legal_status" class="custom-radio" type="radio"
value="{{ legal_status.0 }}">
&nbsp; {{ legal_status.1 }}
</label>
</div>
{% endfor %}
</div>
</div> <!-- financial_info -->
</div>
<div class="col-lg-3">
<div class="header">Skype</div>
<input name="{{ form.skype.html_name }}" class="simple-input"
placeholder="skype id"
value="{{ form.skype.value }}">
</div>
<div class="clearfix visible-lg"></div>
<div class="col-lg-3 vertical-child">
<div class="header">Сайт</div>
<input name="{{ form.website.html_name }}" class="simple-input"
placeholder="example.com"
value="{{ form.website.value }}">
</div>
<div class="col-lg-3 vertical-child">
<div class="header">Телефон</div>
<input name="{{ form.phone.html_name }}" class="simple-input phone"
placeholder="+7 909 999 00 00"
value="{{ form.phone.value }}"
type="tel">
</div>
<div class="col-lg-3 vertical-child">
<div class="header">Второй телефон</div>
<input name="{{ form.phone2.html_name }}" class="simple-input phone"
placeholder="+7 909 999 00 00"
value="{{ form.phone2.value }}"
type="tel">
</div>
<div class="col-lg-3 vertical-child" style="text-align: center">
<div class="header">&nbsp;</div>
<input type="submit" class="btn btn-simple" value="СОХРАНИТЬ">
</div>
</div>
</div>
</div> <!-- bottom -->
</div>
</form>
{# </div>#}
</div>
</div>
@ -329,7 +378,7 @@
{% block personal_js %}
{{ block.super }}
<script src='{% static "lib/proekton-components/js/build/init_user_profile.js" %}'></script>
<script src='{% static "projects-filter.js" %}'></script>
{# <script src='{% static "projects-filter.js" %}'></script>#}
<script src='{% static "lib/jquery.fileupload/js/vendor/jquery.ui.widget.js" %}'></script>
<script src='{% static "lib/jquery-ui/jquery-ui.js" %}'></script>
<script src='{% static "lib/jquery-ui/i18n/datepicker-ru.js" %}'></script>

@ -21,7 +21,7 @@ _.map = _.map_;
_.filter = _.filter_
from .forms import TeamForm, ContractorResumeFilesForm, ContractorResumeForm, CustomerProfileForm
from .models import User, Team, ContractorResume, ContractorResumeFiles, TeamInvitation
from .models import User, Team, ContractorResume, ContractorResumeFiles, TeamInvitation, UserFinancialInfo
from archilance import util
from archilance.mixins import BaseMixin
from common.mixins import ContractorRequiredMixin, NoCsrfMixin
@ -128,6 +128,10 @@ class UserProfileEditViewFull(BaseMixin, View):
# import code
# code.interact(local=dict(globals(), **locals()))
context.update({'form': form})
context.update({
'RESIDENCIES': UserFinancialInfo.RESIDENCIES,
'LEGAL_STATUSES': UserFinancialInfo.LEGAL_STATUSES,
})
return render(request, self.template_name, context)
@ -252,188 +256,6 @@ class UserFinancialInfoEditView(BaseMixin, View):
return render(request, self.template_name, context)
# class ContractorFilterViewOld(BaseMixin, View):
# template_name = 'contractor_filter.html'
# form_class = ContractorFilterForm
#
# def get(self, request, *args, **kwargs):
# form = self.form_class(request.GET, request=request)
# context = self.get_context_data(**_.merge({}, request.GET, kwargs))
# coll = []
#
# if form.is_valid():
# contractors = teams = None
# contr_count = team_count = None
# get_contractors = get_teams = None
# ord = None
#
# cro = form.cleaned_data.get('cro')
# specialization = form.cleaned_data.get('specialization')
# location = form.cleaned_data.get('location')
# work_type = form.cleaned_data.get('work_type')
# build_classif = form.cleaned_data.get('building_classification')
# constr_type = form.cleaned_data.get('construction_type')
#
# party_types = form.cleaned_data.get('party_types')
# last_party_types = form.cleaned_data.get('last_party_types')
#
# if party_types == 'all':
# get_contractors = get_teams = True
# elif party_types == 'contractors':
# get_contractors = True
# elif party_types == 'teams':
# get_teams = True
# elif not party_types:
# if last_party_types == 'contractors':
# get_contractors = True
# elif last_party_types == 'teams':
# get_teams = True
# else:
# get_contractors = get_teams = True
#
# if party_types:
# last_party_types = party_types
#
# context.update({'last_party_types': last_party_types})
#
# if get_contractors:
# contractors = User.contractor_objects.all()
#
# if cro:
# contractors = contractors.filter(cro=cro)
#
# if specialization:
# contractors = contractors.filter(
# contractor_specializations__lft__gte=specialization.lft,
# contractor_specializations__rght__lte=specialization.rght,
# )
#
# if location:
# contractors = contractors.filter(
# location__lft__gte=location.lft,
# location__rght__lte=location.rght,
# )
#
# if work_type:
# contractors = contractors.filter(orders__project__work_type=work_type)
#
# if build_classif:
# contractors = contractors.filter(Q(orders__project__realty__building_classification=build_classif) |
# Q(contractor_building_classifications=build_classif))
#
# if constr_type:
# contractors = contractors.filter(Q(orders__project__realty__construction_type=constr_type) |
# Q(contractor_construction_types=constr_type))
#
# if get_teams:
# teams = Team.objects.all()
#
# if cro:
# teams = teams.filter(Q(contractors__cro=cro) | Q(owner__cro=cro))
#
# if specialization:
# teams = teams.filter(
# (
# Q(contractors__contractor_specializations__lft__gte=specialization.lft)
# & Q(contractors__contractor_specializations__rght__lte=specialization.rght)
# ) | (
# Q(owner__contractor_specializations__lft__gte=specialization.lft)
# & Q(owner__contractor_specializations__rght__lte=specialization.rght)
# ),
# )
#
# if location:
# teams = teams.filter(
# (
# Q(contractors__location__lft__gte=location.lft)
# & Q(contractors__location__rght__lte=location.rght)
# ) | (
# Q(owner__location__lft__gte=location.lft)
# & Q(owner__location__rght__lte=location.rght)
# ),
# )
#
# if work_type:
# teams = teams.filter(
# Q(contractors__orders__project__work_type=work_type)
# | Q(owner__orders__project__work_type=work_type),
# )
#
# if build_classif:
# teams = teams.filter(
# Q(contractors__orders__project__realty__building_classification=build_classif)
# | Q(owner__orders__project__realty__building_classification=build_classif),
# )
#
# if constr_type:
# teams = teams.filter(
# Q(contractors__orders__project__realty__construction_type=constr_type)
# | Q(owner__orders__project__realty__construction_type=constr_type),
# )
#
# if get_contractors and get_teams:
# coll = tuple(itertools.chain(contractors.distinct(), teams.distinct()))
# count = len(coll)
# display_msg = 'Найдено %s элементов' % count if count > 0 else 'Ничего не найдено'
# elif get_contractors:
# coll = contractors.distinct()
# count = coll.count()
# display_msg = 'Найдено %s исполнителей' % count if count > 0 else 'Ничего не найдено'
# elif get_teams:
# coll = teams.distinct()
# count = coll.count()
# display_msg = 'Найдено %s групп' % count if count > 0 else 'Ничего не найдено'
#
# order_by = form.cleaned_data.get('order_by')
# last_order_by = form.cleaned_data.get('last_order_by')
# reverse_order = form.cleaned_data.get('reverse_order')
#
# if order_by:
# reverse_order = not reverse_order if order_by == last_order_by else False
# ord = order_by
# last_order_by = ord
# elif last_order_by:
# ord = last_order_by
#
# if ord:
# if ord == 'name':
# coll = natsort.natsorted(coll, key=lambda obj: getattr(obj, 'username', None) or obj.name,
# reverse=reverse_order)
# elif ord == 'created':
# coll = natsort.natsorted(coll, key=lambda obj: obj.created, reverse=reverse_order)
#
# context.update({
# 'last_order_by': last_order_by,
# 'reverse_order': reverse_order,
# })
# else:
# display_msg = 'Пожалуйста, введите корректные данные'
#
# if form.errors:
# messages.info(request, (
# '<p>Произошла ошибка (form)</p>'
# '<pre>{form}</pre>'
# ).format(form=pformat(form.errors)))
#
# paginator = Paginator(coll, settings.PAGE_SIZE)
# page = request.GET.get('page')
#
# try:
# coll = paginator.page(page)
# except PageNotAnInteger:
# coll = paginator.page(1)
# except EmptyPage:
# coll = paginator.page(paginator.num_pages)
#
# context.update({
# 'form': form,
# 'coll': coll,
# 'is_paginated': True,
# 'page_obj': coll,
# 'display_msg': display_msg,
# })
#
# return render(request, self.template_name, context)
# TODO: не работает сортировка по reviews(не получилось создать отзывы) и views(не нашел счетчик просмотров)
class ContractorFilterView(BaseMixin, View):

Loading…
Cancel
Save