PR-61 Правки по профилю заказчика, формам заполнения и ссылке в шапке

Мелкие визуальные и функциональные правки
remotes/origin/HEAD
booblegum 9 years ago
parent 3600cef18b
commit d293a32700
  1. 7
      assets/js/build/create_project.js
  2. 2
      assets/js/build/init_customer_project_create.js
  3. 84
      assets/js/build/init_portfolio_create_edit.js
  4. 7
      assets/js/src/customer_project_create.js
  5. 2
      assets/js/src/init_customer_project_create.js
  6. 87
      assets/js/src/init_portfolio_create_edit.js
  7. 12
      projects/templates/customer_project_create_or_edit.html
  8. 12
      projects/views.py
  9. 2
      users/static/sass/customer-profile.sass
  10. 8
      users/templates/partials/inc-objects.html
  11. 4
      users/views.py

@ -76,6 +76,12 @@
}); });
} }
function changeButtonText() {
//Если перешли со страницы профиля по кнопке "Добавить заказ"
var id = window.location.hash.replace("#", "");
if (id) $('.js-change-text').val("ДОБАВИТЬ ЗАКАЗ");
}
$(function () { $(function () {
(0, _file_upload.fileUploadInit)(); (0, _file_upload.fileUploadInit)();
(0, _extended_field.extendedFieldInit)(); (0, _extended_field.extendedFieldInit)();
@ -86,6 +92,7 @@
(0, _scroll_on_required.scrollOnRequiredInit)(); (0, _scroll_on_required.scrollOnRequiredInit)();
(0, _popups.showPopupsInit)(); (0, _popups.showPopupsInit)();
(0, _ajax_registration.ajaxRegistrationInit)('customer'); (0, _ajax_registration.ajaxRegistrationInit)('customer');
changeButtonText();
window.addMessage = _popups.addMessage; window.addMessage = _popups.addMessage;
}); });

@ -174,8 +174,10 @@
if (!sb_realty_top.dataTree.data.length) { if (!sb_realty_top.dataTree.data.length) {
sb_realty_top.hide(); sb_realty_top.hide();
} else { } else {
//Если перешли со страницы профиля по кнопке "Добавить заказ"
var id = window.location.hash.replace("#", ""); var id = window.location.hash.replace("#", "");
if (id) sb_realty_top.setElementById(id); if (id) sb_realty_top.setElementById(id);
select_realty.add(id);
} }
}); });
select_realty.on("add", function (args) { select_realty.on("add", function (args) {

@ -111,86 +111,6 @@
sb_build_1.setNearbySelectBox("", sb_build_main); sb_build_1.setNearbySelectBox("", sb_build_main);
} }
function createConstructionType(url) {
sb_constr_main = new _NoTreeSelect2.default($('#sb-construction-type'), { url: url, visible: true });
sb_constr_main.setHeader("Вид строительства");
var select_constr_type = new _SelectedContainer2.default($('#selected-construction-type'), {
obj: sb_constr_main,
noTree: true,
onlyOne: true
});
sb_constr_main.connectSelectedContainer(select_constr_type);
}
function createLocations(url) {
sb_loc_main = new _TreeSelect2.default($('#sb-location-1'), { url: url, visible: true });
sb_loc_main.setHeader("Местоположение");
var select_loc = new _SelectedContainer2.default($('#selected-location'), {
obj: sb_loc_main,
onlyOne: true
});
sb_loc_main.connectSelectedContainer(select_loc);
var sb_loc_1 = new _TreeSelect2.default($('#sb-location-2'), { obj: sb_loc_main });
var sb_loc_2 = new _TreeSelect2.default($('#sb-location-3'), { obj: sb_loc_main });
sb_loc_main.setNearbySelectBox(sb_loc_1);
sb_loc_1.setNearbySelectBox(sb_loc_2, sb_loc_main);
sb_loc_2.setNearbySelectBox("", sb_loc_1);
}
function createRealty(url) {
var sb_realty = new _SelectOrCreate2.default($('#sb-realty'), { url: url, visible: true });
sb_realty.setHeader(" ");
var select_realty = new _SelectedContainerCreate2.default($('#selected-realty'), {
obj: sb_realty,
noTree: true,
onlyOne: true,
noHeader: true
});
sb_realty.connectSelectedContainer(select_realty);
sb_realty.setLinkBoxes([sb_loc_main, sb_constr_main, sb_build_main]);
select_realty.on("add", function () {
$('#checkbox-sb-realty').attr("disabled", true);
});
select_realty.on("remove", function () {
$('#checkbox-sb-realty').attr("disabled", false);
});
sb_realty.dataPromise.then(function () {
var $realty = $('#sb-realty');
var check = $('#checkbox-sb-realty');
if (!check.prop("checked")) {
$realty.hide();
}
});
var sb_realty_top = new _NoTreeSelect2.default($('#sb-realty-top'), { url: url, visible: true });
sb_realty_top.setHeader("Объект");
sb_realty_top.connectSelectedContainer(select_realty);
sb_realty_top.dataPromise.then(function () {
if (!sb_realty_top.dataTree.data.length) {
sb_realty_top.hide();
} else {
var id = window.location.hash.replace("#", "");
if (id) sb_realty_top.setElementById(id);
}
});
select_realty.on("add", function (args) {
//TODO: Костыли!!!
$('#checkbox-sb-realty').prop("checked", true);
sb_realty.show();
var id = args[0];
if (id.text) return;
var el = sb_realty.dataTree.getElementById(id);
sb_realty_top.dataPromise.then(function () {
sb_realty_top.$searchInput.val(el.name);
sb_realty_top.selectedEl.id = id;
sb_realty_top.selectedEl.value = el.name;
});
sb_realty.selectedEl.id = id;
sb_realty._fillBoxes();
});
}
var sb_loc_main = void 0, var sb_loc_main = void 0,
sb_constr_main = void 0, sb_constr_main = void 0,
sb_build_main = void 0; sb_build_main = void 0;
@ -198,10 +118,6 @@
createSpecs('/api/specializations_flat'); createSpecs('/api/specializations_flat');
// Классификация здания // Классификация здания
createBuildingClass('/api/building_classifications'); createBuildingClass('/api/building_classifications');
// createConstructionType('/api/construction_type');
// createLocations('/api/locations_flat');
// createRealty('/api/realties/current_user')
}); });
// import SingleTreeSelect from 'components/SingleTreeSelect' // import SingleTreeSelect from 'components/SingleTreeSelect'

@ -20,6 +20,12 @@ function showHideRealry() {
}) })
} }
function changeButtonText() {
//Если перешли со страницы профиля по кнопке "Добавить заказ"
let id = window.location.hash.replace("#", "");
if (id) $('.js-change-text').val("ДОБАВИТЬ ЗАКАЗ");
}
$(function () { $(function () {
fileUploadInit(); fileUploadInit();
extendedFieldInit(); extendedFieldInit();
@ -30,5 +36,6 @@ $(function () {
scrollOnRequiredInit(); scrollOnRequiredInit();
showPopupsInit(); showPopupsInit();
ajaxRegistrationInit('customer'); ajaxRegistrationInit('customer');
changeButtonText();
window.addMessage = addMessage; window.addMessage = addMessage;
}); });

@ -113,8 +113,10 @@ $(function () {
if (!sb_realty_top.dataTree.data.length) { if (!sb_realty_top.dataTree.data.length) {
sb_realty_top.hide() sb_realty_top.hide()
}else{ }else{
//Если перешли со страницы профиля по кнопке "Добавить заказ"
let id = window.location.hash.replace("#", ""); let id = window.location.hash.replace("#", "");
if (id) sb_realty_top.setElementById(id); if (id) sb_realty_top.setElementById(id);
select_realty.add(id);
} }
}); });
select_realty.on("add", (args)=> { select_realty.on("add", (args)=> {

@ -52,97 +52,10 @@ $(function () {
sb_build_1.setNearbySelectBox("", sb_build_main); sb_build_1.setNearbySelectBox("", sb_build_main);
} }
function createConstructionType(url) {
sb_constr_main = new NoTreeSelect($('#sb-construction-type'), {url, visible: true});
sb_constr_main.setHeader("Вид строительства");
let select_constr_type = new SelectedContainer($('#selected-construction-type'), {
obj: sb_constr_main,
noTree: true,
onlyOne: true
});
sb_constr_main.connectSelectedContainer(select_constr_type);
}
function createLocations(url) {
sb_loc_main = new TreeSelect($('#sb-location-1'), {url, visible: true});
sb_loc_main.setHeader("Местоположение");
let select_loc = new SelectedContainer($('#selected-location'),
{
obj: sb_loc_main,
onlyOne: true
});
sb_loc_main.connectSelectedContainer(select_loc);
let sb_loc_1 = new TreeSelect($('#sb-location-2'), {obj: sb_loc_main});
let sb_loc_2 = new TreeSelect($('#sb-location-3'), {obj: sb_loc_main});
sb_loc_main.setNearbySelectBox(sb_loc_1);
sb_loc_1.setNearbySelectBox(sb_loc_2, sb_loc_main);
sb_loc_2.setNearbySelectBox("", sb_loc_1);
}
function createRealty(url) {
let sb_realty = new SelectOrCreate($('#sb-realty'), {url, visible: true});
sb_realty.setHeader(" ");
let select_realty = new SelectedContainerCreate($('#selected-realty'),
{
obj: sb_realty,
noTree: true,
onlyOne: true,
noHeader: true
});
sb_realty.connectSelectedContainer(select_realty);
sb_realty.setLinkBoxes([sb_loc_main, sb_constr_main, sb_build_main]);
select_realty.on("add", () => {
$('#checkbox-sb-realty').attr("disabled", true)
});
select_realty.on("remove", () => {
$('#checkbox-sb-realty').attr("disabled", false)
});
sb_realty.dataPromise.then(function () {
let $realty = $('#sb-realty');
let check = $('#checkbox-sb-realty');
if (!check.prop("checked")) {
$realty.hide();
}
}
);
let sb_realty_top = new NoTreeSelect($('#sb-realty-top'), {url, visible: true});
sb_realty_top.setHeader("Объект");
sb_realty_top.connectSelectedContainer(select_realty);
sb_realty_top.dataPromise.then(function () {
if (!sb_realty_top.dataTree.data.length) {
sb_realty_top.hide()
}else{
let id = window.location.hash.replace("#", "");
if (id) sb_realty_top.setElementById(id);
}
});
select_realty.on("add", (args)=> {
//TODO: Костыли!!!
$('#checkbox-sb-realty').prop("checked", true);
sb_realty.show();
let id = args[0];
if (id.text) return;
let el = sb_realty.dataTree.getElementById(id);
sb_realty_top.dataPromise.then(function () {
sb_realty_top.$searchInput.val(el.name);
sb_realty_top.selectedEl.id = id;
sb_realty_top.selectedEl.value = el.name;
});
sb_realty.selectedEl.id = id;
sb_realty._fillBoxes();
})
}
let sb_loc_main, sb_constr_main, sb_build_main; let sb_loc_main, sb_constr_main, sb_build_main;
// Тип работы // Тип работы
createSpecs('/api/specializations_flat'); createSpecs('/api/specializations_flat');
// Классификация здания // Классификация здания
createBuildingClass('/api/building_classifications'); createBuildingClass('/api/building_classifications');
// createConstructionType('/api/construction_type');
// createLocations('/api/locations_flat');
// createRealty('/api/realties/current_user')
}); });

@ -254,6 +254,7 @@
autocomplete="off"> autocomplete="off">
</div> </div>
<div class="col-lg-4"> <div class="col-lg-4">
<div class="header">&nbsp</div>
<div class="row"> <div class="row">
<div class="col-lg-1"> <div class="col-lg-1">
<input name="{{ form.price_and_term_required.html_name }}" id="safe" <input name="{{ form.price_and_term_required.html_name }}" id="safe"
@ -268,6 +269,7 @@
</div> </div>
</div> </div>
<div class="col-lg-2"> <div class="col-lg-2">
<div class="header">&nbsp</div>
<div class="row"> <div class="row">
<div class="col-lg-2"> <div class="col-lg-2">
<input name="{{ form.budget_by_agreement.html_name }}" id="by_agreement" <input name="{{ form.budget_by_agreement.html_name }}" id="by_agreement"
@ -381,7 +383,7 @@
<div class="col-lg-3" style="text-align: center"> <div class="col-lg-3" style="text-align: center">
<input style="width: 100%" type="submit" class="btn btn-simple" <input style="width: 100%" type="submit" class="btn btn-simple js-change-text"
value="{% if pk %}СОХРАНИТЬ{% else %}РАЗМЕСТИТЬ{% endif %} ЗАКАЗ"> value="{% if pk %}СОХРАНИТЬ{% else %}РАЗМЕСТИТЬ{% endif %} ЗАКАЗ">
</div> </div>
<div class="col-lg-3 col-lg-offset-6" style="text-align: center"> <div class="col-lg-3 col-lg-offset-6" style="text-align: center">
@ -426,10 +428,10 @@
{% endblock %} {% endblock %}
{% block old_js %} {% block old_js %}
<script src='{% static "lib/jquery.fileupload/js/vendor/jquery.ui.widget.js" %}'></script> {# <script src='{% static "lib/jquery.fileupload/js/vendor/jquery.ui.widget.js" %}'></script>#}
<script src='{% static "lib/jquery.fileupload/js/jquery.iframe-transport.js" %}'></script> {# <script src='{% static "lib/jquery.fileupload/js/jquery.iframe-transport.js" %}'></script>#}
<script src='{% static "lib/jquery.fileupload/js/jquery.fileupload.js" %}'></script> {# <script src='{% static "lib/jquery.fileupload/js/jquery.fileupload.js" %}'></script>#}
<script src='{% static "lib/jquery.fileupload/js/jquery.fileupload-process.js" %}'></script> {# <script src='{% static "lib/jquery.fileupload/js/jquery.fileupload-process.js" %}'></script>#}
<script src='{% static "my-libs.js" %}'></script> <script src='{% static "my-libs.js" %}'></script>
{% endblock %} {% endblock %}
{% block js_block %} {% block js_block %}

@ -395,18 +395,22 @@ class ProjectFilterView(BaseMixin, View):
class SortRealtyBy(View): class SortRealtyBy(View):
def get_context(self): def get_context_data(self, **kwargs):
# print("request.POST = ", self.request.POST) context = {}
user_id = self.request.POST.get('user_id') user_id = self.request.POST.get('user_id')
sort_by = self.request.POST.get('sortBy') sort_by = self.request.POST.get('sortBy')
state = self.request.POST.get('state') state = self.request.POST.get('state')
objects = Realty.objects.filter(user__id=user_id, state=state, is_virtual=False) objects = Realty.objects.filter(user__id=user_id, state=state, is_virtual=False)
if sort_by == 'num_orders': if sort_by == 'num_orders':
objects = objects.annotate(num_orders=Count('projects')) objects = objects.annotate(num_orders=Count('projects'))
return {"objects": objects.order_by('{}'.format(sort_by))} context.update({
"objects": objects.order_by('{}'.format(sort_by)),
"customer": User.objects.get(id=user_id),
})
return context
def post(self, *args, **kwargs): def post(self, *args, **kwargs):
return render(self.request, 'partials/inc-objects.html', self.get_context()) return render(self.request, 'partials/inc-objects.html', self.get_context_data())
class CustomerProjectCreateView(BaseMixin, View): class CustomerProjectCreateView(BaseMixin, View):

@ -77,7 +77,7 @@ table.projects
.cut .cut
display: inline-block display: inline-block
text-overflow: ellipsis text-overflow: ellipsis
max-width: 550px max-width: 500px
overflow: hidden overflow: hidden
word-wrap: break-word word-wrap: break-word
white-space: nowrap white-space: nowrap

@ -70,16 +70,18 @@
<div class="row" id="obj-{{ object.id }}" style="display: none"> <div class="row" id="obj-{{ object.id }}" style="display: none">
<div class="col-lg-12"> <div class="col-lg-12">
<div class="separator"> <div class="separator" style="margin-bottom: 5px">
<div class="border"></div> <div class="border"></div>
</div> </div>
<table class="projects"> <table class="projects">
{% for project in object.projects.all %} {% for project in object.projects.all %}
<tr> <tr>
<td><strong>{{ forloop.counter }}</strong></td> <td><strong>{{ forloop.counter }}</strong></td>
<td>{{ project.name }}</td>
<td> <td>
<span class="icon-calendar">{{ project.created }}</span> <a class="cut-name" href="{% url 'projects:detail' project.pk %}">{{ project.name|truncatechars:25 }}</a>
</td>
<td>
<span class="icon-calendar" style="white-space: nowrap">{{ project.created }}</span>
</td> </td>
<td> <td>
<span class="icon-eye">{{ project.hit_count.hits }}</span> <span class="icon-eye">{{ project.hit_count.hits }}</span>

@ -797,7 +797,7 @@ class CustomerProfileView(BaseMixin, DetailView):
context_object_name = 'customer' context_object_name = 'customer'
def get_object(self, queryset=None): def get_object(self, queryset=None):
return get_object_or_404(User, pk=self.kwargs['pk']) return get_object_or_404(self.model, pk=self.kwargs['pk'])
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data() context = super().get_context_data()
@ -805,7 +805,7 @@ class CustomerProfileView(BaseMixin, DetailView):
# profile-info # profile-info
context.update( context.update(
{ {
'ratings': User.objects.get(pk=user_id).rating, 'ratings': self.model.objects.get(pk=user_id).rating,
'deals': Order.objects.filter(secure=True, contractor_id=user_id, status=1).count(), 'deals': Order.objects.filter(secure=True, contractor_id=user_id, status=1).count(),
'reviews_n': Review.objects.filter(target_contractor_id=user_id, type='neutral').count(), 'reviews_n': Review.objects.filter(target_contractor_id=user_id, type='neutral').count(),
'reviews_m': Review.objects.filter(target_contractor_id=user_id, type='negative').count(), 'reviews_m': Review.objects.filter(target_contractor_id=user_id, type='negative').count(),

Loading…
Cancel
Save