diff --git a/projects/forms.py b/projects/forms.py index 75f9aed..8214835 100644 --- a/projects/forms.py +++ b/projects/forms.py @@ -1,33 +1,37 @@ from django import forms from django.forms import ModelForm, HiddenInput, Form, Select from django.forms.models import inlineformset_factory -from .models import Project, Portfolio, Answer, Realty, PortfolioPhoto, Stage +from mptt.forms import TreeNodeChoiceField +from .models import Project, Portfolio, Answer, Realty, PortfolioPhoto, Stage, Specialization # RealtyFormSet = inlineformset_factory(Project, Realty) class ProjectForm(ModelForm): + specialization = TreeNodeChoiceField(queryset=Specialization.objects.exclude(id=1)) + class Meta: model = Project fields = ( 'budget', 'budget_by_agreement', - 'created', 'cro', 'currency', - 'customer', 'name', 'price_and_term_required', - 'realty', - 'secure_deal', - 'specialization', - 'term', + 'deal_type', 'term_type', 'text', 'work_type', - # TODO: Add "files" + 'specialization', ) + widgets = { + 'specialization': Select(attrs={'class':'selectpicker'}), + 'currency': Select(attrs={'class':'selectpicker2 valul'}), + 'term_type': Select(attrs={'class':'selectpicker'}), + } + class ProjectsForm(Form): name = forms.CharField(max_length=255) @@ -38,13 +42,20 @@ class RealtyForm(ModelForm): model = Realty fields = ( - # 'city', + 'country', + 'city', 'building_classification', 'construction_type', - 'country', 'name', ) + widgets = { + 'construction_type': Select(attrs={'class':'selectpicker'}), + 'building_classification': Select(attrs={'class':'selectpicker'}), + 'city': Select(attrs={'class':'selectpicker'}), + 'country': Select(attrs={'class':'selectpicker'}), + } + class Realty1Form(Form): pass diff --git a/projects/migrations/0026_auto_20160610_1204.py b/projects/migrations/0026_auto_20160610_1204.py new file mode 100644 index 0000000..e96f2b5 --- /dev/null +++ b/projects/migrations/0026_auto_20160610_1204.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.6 on 2016-06-10 09:04 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('projects', '0025_auto_20160609_1916'), + ] + + operations = [ + migrations.AlterModelOptions( + name='projectfile', + options={'verbose_name': 'Файл проекта', 'verbose_name_plural': 'Файлы проектов'}, + ), + migrations.RemoveField( + model_name='project', + name='secure_deal', + ), + migrations.AddField( + model_name='project', + name='deal_type', + field=models.CharField(choices=[('secure_deal', 'Безопасная сделка (с резервированием бюджета) '), ('direct_payment', 'Прямая оплата Исполнителю на его кошелек/счет')], default='secure_deal', max_length=20), + ), + ] diff --git a/projects/migrations/0027_auto_20160610_1231.py b/projects/migrations/0027_auto_20160610_1231.py new file mode 100644 index 0000000..33d44bf --- /dev/null +++ b/projects/migrations/0027_auto_20160610_1231.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.6 on 2016-06-10 09:31 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('projects', '0026_auto_20160610_1204'), + ] + + operations = [ + migrations.AlterField( + model_name='realty', + name='city', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='realties', to='projects.City'), + ), + migrations.AlterField( + model_name='realty', + name='country', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='realties', to='projects.Country'), + ), + ] diff --git a/projects/migrations/0028_auto_20160610_1301.py b/projects/migrations/0028_auto_20160610_1301.py new file mode 100644 index 0000000..d5826d1 --- /dev/null +++ b/projects/migrations/0028_auto_20160610_1301.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.6 on 2016-06-10 10:01 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('projects', '0027_auto_20160610_1231'), + ] + + operations = [ + migrations.AlterField( + model_name='project', + name='work_type', + field=models.CharField(choices=[('1', 'Проектирование'), ('2', 'Техническое сопровождение')], default='1', max_length=20), + ), + ] diff --git a/projects/models.py b/projects/models.py index d6bc34e..1dc8554 100644 --- a/projects/models.py +++ b/projects/models.py @@ -65,9 +65,9 @@ class City(models.Model): class Realty(models.Model): building_classification = models.ForeignKey(BuildingClassfication, related_name='realties') - city = models.CharField(max_length=50) + city = models.ForeignKey(City, related_name='realties') construction_type = models.ForeignKey(ConstructionType, related_name='realties') - country = models.CharField(max_length=50) + country = models.ForeignKey(Country, related_name='realties') name = models.CharField(max_length=255) user = models.ForeignKey(User, related_name='realties') @@ -84,6 +84,11 @@ class Project(models.Model): ('1', 'Проектирование'), ('2', 'Техническое сопровождение') ) + + DEAL_TYPES = ( + ('secure_deal', 'Безопасная сделка (с резервированием бюджета) '), + ('direct_payment', 'Прямая оплата Исполнителю на его кошелек/счет'), + ) budget = models.DecimalField(max_digits=10, decimal_places=0) budget_by_agreement = models.BooleanField(default=False) @@ -94,12 +99,12 @@ class Project(models.Model): name = models.CharField(max_length=255) price_and_term_required = models.BooleanField(default=False, blank=True) realty = models.ForeignKey(Realty, null=True, related_name='projects') - secure_deal = models.BooleanField(default=False) + deal_type = models.CharField(max_length=20, default='secure_deal', choices=DEAL_TYPES) specialization = models.ForeignKey(Specialization, related_name='projects') term = models.IntegerField(default=0) term_type = models.CharField(max_length=20, choices=TERMS, default='hour') text = models.TextField(blank=True) - work_type = models.IntegerField(default=1, choices=WORK_TYPES) + work_type = models.CharField(default='1', max_length=20, choices=WORK_TYPES) def __str__(self): return self.name @@ -169,7 +174,6 @@ class Stage(models.Model): verbose_name_plural = 'Этапы' - class Candidate(models.Model): answer = models.ForeignKey(Answer, related_name='candidates') project = models.ForeignKey(Project, related_name='candidates') diff --git a/projects/templates/customer_project_create.html b/projects/templates/customer_project_create.html index 096732e..a149250 100644 --- a/projects/templates/customer_project_create.html +++ b/projects/templates/customer_project_create.html @@ -69,11 +69,7 @@
- + {{ form_project.specialization }}
- + + {{ form_project.currency }}
- + {{ form_project.term_type }}
- +

или по договоренности

- +

Сделать для исполнителей обязательным для заполнения поля цена и срок

@@ -122,25 +112,23 @@
- +

Безопасная сделка (с резервированием бюджета) +

- Lorem ipsum dolor sit amet, consectetur adipisicing elit. Porro vel suscipit eaque - quidem voluptate aperiam enim aut libero, excepturi architecto maxime, placeat maiores, - odio itaque, ex consectetur dignissimos dicta officia. + Описание

- +

Прямая оплата Исполнителю на его кошелек/счет

- Lorem ipsum dolor sit amet, consectetur adipisicing elit. Porro vel suscipit eaque - quidem voluptate aperiam enim aut libero, excepturi architecto maxime, placeat maiores, - odio itaque, ex consectetur dignissimos dicta officia. + Описание

@@ -171,21 +159,13 @@
- +
- + {{ form_realty.building_classification }}
- + {{ form_realty.construction_type }}
@@ -193,21 +173,13 @@
- + {{ form_realty.country }}
- + {{ form_realty.city }}
- +

Требуется допуск СРО

diff --git a/projects/urls.py b/projects/urls.py index c744ee5..a5e305f 100644 --- a/projects/urls.py +++ b/projects/urls.py @@ -1,14 +1,14 @@ from django.conf import urls from django.views.generic import TemplateView -from .views import ProjectListView, ProjectDetailView, ProjectCreateView, \ +from .views import ProjectsView, ProjectDetailView, ProjectCreateView, \ ProjectComparisonView, add_candidate, ChatView, OfferOrderView app_name = 'projects' urlpatterns = [ - urls.url(r'^$', ProjectListView.as_view(), name='list'), + urls.url(r'^$', ProjectsView.as_view(), name='list'), urls.url(r'^candidate/add/(?P(\d+))/(?P(\d+))/$', add_candidate, name='add-candidate'), urls.url(r'^candidate/comparison/(?P\d+)$', ProjectComparisonView.as_view(), name='comparison'), urls.url(r'^create/$', ProjectCreateView.as_view(), name='project-create'), diff --git a/projects/views.py b/projects/views.py index ede9e81..93d1b69 100644 --- a/projects/views.py +++ b/projects/views.py @@ -12,7 +12,7 @@ from .forms import ProjectForm, PortfolioForm, AnswerForm, RealtyForm from .mixins import LastAccessMixin -class ProjectListView(ListView): +class ProjectsView(ListView): model = Project def get_context_data(self, **kwargs): @@ -73,7 +73,7 @@ class ProjectCreateView(PermissionRequiredMixin, View): def post(self, request, *args, **kwargs): form_project = self.form_project(request.POST) - form_realty = self.form_realty(request.POST,prefix='form_2') + form_realty = self.form_realty(request.POST, prefix='form_2') if form_project.is_valid() and form_realty.is_valid(): return self.form_valid(request, form_project, form_realty) return render(request, self.template_name, {'form_project': form_project, 'form_realty': form_realty})