Fixes #ARC-13 #ARC-47

remotes/origin/PR-39
ArturBaybulatov 10 years ago
parent 80cfcc653b
commit 96f8bd7e95
  1. 20
      archilance/util.py
  2. 8
      assets/js/main.js
  3. 32
      projects/forms.py
  4. 8
      projects/templates/customer_project_create.html
  5. 32
      projects/templates/customer_project_edit.html
  6. 2
      projects/views.py
  7. 44
      users/templates/contractor_filter.html

@ -1,9 +1,11 @@
from django.core import validators
from django.shortcuts import _get_queryset
from django.utils import timezone
from pprint import pprint, pformat
import natsort
import pydash as _; _.map = _.map_; _.filter = _.filter_
import random
import string
def take(coll, n):
@ -89,3 +91,21 @@ def decap(s):
raise TypeError('String expected')
return s[0].lower() + s[1:] if len(s) > 0 else s
def random_ident(length=8):
return ''.join(
[random.choice(string.ascii_lowercase)] +
_.times(lambda x_: random.choice(string.ascii_letters + string.digits), length-1)
)
def validate_phone(text):
text = text.replace(' ', '').replace('-', '')
validate = validators.RegexValidator(
regex=r'^((\+7|8)(\(\d{3}\)|(\d{3}))\d{7})$',
message='Неверный номер телефона. Формат: +71112223344',
)
validate(text)

@ -6,11 +6,11 @@ $(document).ready(function(){
if ($.cookie('slideResVisible')) {
$('.slideRes').slideDown(300);
$('.resButtonF1').css('transform','rotate(0deg)');
//$('#extraFields').val('')
$('#extraFields').val('on')
} else {
$('.slideRes').slideUp(300);
$('.resButtonF1').css('transform','rotate(180deg)');
//$('#extraFields').val('on')
$('#extraFields').val('')
}
$('.resButtonF1').click(function(e){
@ -20,12 +20,12 @@ $(document).ready(function(){
$('.slideRes').slideUp(300);
$(this).css('transform','rotate(180deg)');
$.cookie('slideResVisible', '', {expires: new Date(new Date().getTime() + 300000)}) // 5 minutes
//$('#extraFields').val('')
$('#extraFields').val('')
} else {
$('.slideRes').slideDown(300);
$(this).css('transform','rotate(0deg)');
$.cookie('slideResVisible', 'on', {expires: new Date(new Date().getTime() + 300000)})
//$('#extraFields').val('on')
$('#extraFields').val('on')
}
});

@ -6,6 +6,7 @@ from pprint import pprint, pformat
import itertools
from .models import Project, ProjectFile, Portfolio, Answer, AnswerMessage, Realty, PortfolioPhoto, Stage
from archilance import util
from common.models import Location
from specializations.models import Specialization
from users.models import User, Team
@ -117,12 +118,27 @@ class CustomerProjectEditForm(forms.ModelForm):
super().__init__(*args, **kwargs)
self.fields['realty'].empty_label = 'Создать новый'
self.fields['realty'].queryset = self.request.user.realties.all()
self.fields['budget'].required = False
self.fields['currency'].required = False
self.fields['term_type'].required = False
self.fields['specialization'].queryset = Specialization.objects.root_nodes()[0].get_descendants()
# self.fields['specialization'].queryset = Specialization.objects # Migrate with this enabled
if self.instance.pk:
self.fields['files'].queryset = self.instance.files
def clean(self):
cleaned_data = super().clean()
if not cleaned_data.get('budget_by_agreement'):
if not cleaned_data.get('budget'): raise forms.ValidationError({'budget': 'Это поле обязательно'})
if not cleaned_data.get('currency'): raise forms.ValidationError({'currency': 'Это поле обязательно'})
if not cleaned_data.get('term_type'): raise forms.ValidationError({'term_type': 'Это поле обязательно'})
return cleaned_data
class RealtyForm(forms.ModelForm):
@ -145,8 +161,24 @@ class RealtyForm(forms.ModelForm):
self.request = kwargs.pop('request')
super().__init__(*args, **kwargs)
self.fields['name'].required = False
self.fields['location'].queryset = Location.objects.root_nodes()[0].get_descendants()
# self.fields['location'].queryset = Location.objects # Migrate with this enabled
def clean_name(self):
name = self.cleaned_data.get('name')
if not name:
if self.data.get('extra_fields'):
raise forms.ValidationError('Это поле обязательно')
else:
if not self.instance.pk:
name = self.instance.name
else:
name = 'Новый объект %s' % util.random_ident(length=20)
return name
class PortfolioForm(forms.ModelForm):

@ -14,6 +14,8 @@
<form action="{% url 'projects:customer-project-create' %}" method="POST" enctype="multipart/form-data" novalidate>
{% csrf_token %}
<input type="hidden" id="extraFields" name="extra_fields" value="">
<div class="chatBlock new-rass new-rass2 disTab">
<div class="col-lg-9">
<p class="new-pp new-pp3">Формирование заказа</p>
@ -52,7 +54,7 @@
<p class="type-work">Тип работы <span style="color: red">{{ form.work_type.errors.as_text }}</span></p>
<div class="mail-block type-work-inset">
{% for id, name in form.work_type.field.choices %}
{% for id, text in form.work_type.field.choices %}
<div class="inset-mb">
<label>
<input
@ -64,7 +66,7 @@
<span></span>
</label>
<p>{{ name }}</p>
<p>{{ text }}</p>
</div>
{% endfor %}
</div>
@ -187,8 +189,6 @@
<!--<p><input type="text" id="extraFields" name="extra_fields" value=""></p>-->
<div class="resSearchF1">
<div class="col-lg-3">
<p class="titleResF1">Расширенный поиск</p>

@ -13,7 +13,9 @@
<form action="{% url 'projects:customer-project-edit' pk=pk %}" method="POST" enctype="multipart/form-data" novalidate>
{% csrf_token %}
<input type="hidden" name="next" value="{% url 'projects:detail' pk=pk %}">
<input type="hidden" id="extraFields" name="extra_fields" value="">
<div class="chatBlock new-rass new-rass2 disTab">
<div class="col-lg-9">
@ -92,22 +94,22 @@
</div>
<div class="polsF1 disTab -spec-select-container">
<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" class="-chosen-spec-id" name="{{ form.specialization.html_name }}" value="{{ form.specialization.value }}">
<input type="hidden" name="{{ form.specialization.html_name }}" value="{{ form.specialization.value }}" class="-chosen-spec-id">
</div>
<div class="titleF1 titleF2 disTab">
<div class="col-lg-12">Бюджет <span style="color: red">{{ form.budget.errors.as_text }}</span></div>
@ -258,19 +260,19 @@
</div>
</div>
<div class="titleF1 disTab">
<div class="col-lg-12">Местоположение:</div>
<div class="col-lg-12">Местоположение <span style="color: red">{{ realty_form.location.errors.as_text }}</span></div>
</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 }}">
@ -288,17 +290,11 @@
<p>Требуется допуск СРО</p>
</div>
</div>
<div class="searchF1 polsF1 polsFF links-filter">
<input class="btn-submit-link" type="submit" value="Сохранить">
</div>
</div>
<div class="searchF1 polsF1 polsFF links-filter">
<input class="btn-submit-link" type="submit" value="Сохранить">
</div>
</div>
</div>
</form>

@ -403,7 +403,7 @@ class CustomerProjectEditView(BaseMixin, View):
if request.user.is_authenticated() and request.user.is_customer():
return super().dispatch(request, *args, **kwargs)
else:
return HttpResponseForbidden('403 Forbidden')
raise PermissionDenied
def get(self, request, *args, **kwargs):
project = get_object_or_404(request.user.projects, pk=kwargs.get('pk'))

@ -42,30 +42,7 @@
</div>
<div class="titleF1 titleF2 disTab">
<div class="col-lg-3">Местоположение</div>
</div>
<div class="searchF1 polsF1 polsFF polsF3">
<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="{{ form.location.html_name }}" value="{{ form.location.value }}">
<div class="col-lg-3">
<a href="#" class="findReal" onclick="$(this).closest('form').submit(); return false">
найти исполнителя
@ -103,6 +80,27 @@
<div class="slideRes disTab activeSlide">
<div class="titleF1 disTab">
<div class="col-lg-12">Местоположение</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="{{ form.location.html_name }}" value="{{ form.location.value }}">
</div>
<div class="titleF1 disTab">
<div class="col-lg-3">Классификация здания</div>
<div class="col-lg-3">Тип работы</div>

Loading…
Cancel
Save