diff --git a/archilance/settings/base.py b/archilance/settings/base.py index 8ccb3a2..c2e290d 100644 --- a/archilance/settings/base.py +++ b/archilance/settings/base.py @@ -38,6 +38,7 @@ THIRD_PARTY_APPS = [ LOCAL_APPS = [ 'api', + 'common', 'archilance', 'projects', 'specializations', diff --git a/common/__init__.py b/common/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/common/admin.py b/common/admin.py new file mode 100644 index 0000000..3e55e94 --- /dev/null +++ b/common/admin.py @@ -0,0 +1,9 @@ +from django.contrib import admin +from mptt.admin import MPTTModelAdmin + +from .models import Location + +class LocationAdmin(MPTTModelAdmin): + readonly_fields = ('pk', 'lft', 'rght', 'tree_id', 'level') + +admin.site.register(Location, LocationAdmin) diff --git a/common/apps.py b/common/apps.py new file mode 100644 index 0000000..5f2f078 --- /dev/null +++ b/common/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class CommonConfig(AppConfig): + name = 'common' diff --git a/common/migrations/0001_initial.py b/common/migrations/0001_initial.py new file mode 100644 index 0000000..7149f56 --- /dev/null +++ b/common/migrations/0001_initial.py @@ -0,0 +1,66 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.6 on 2016-06-15 12:56 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import django.db.models.manager +import mptt.fields + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='City', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255)), + ], + options={ + 'verbose_name_plural': 'Города', + 'verbose_name': 'Город', + }, + ), + migrations.CreateModel( + name='Country', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=255)), + ], + options={ + 'verbose_name_plural': 'Страны', + 'verbose_name': 'Страна', + }, + ), + migrations.CreateModel( + name='Location', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('name', models.CharField(max_length=50)), + ('type', models.CharField(blank=True, choices=[('country', 'Страна'), ('region', 'Регион'), ('town', 'Город')], max_length=20, null=True)), + ('lft', models.PositiveIntegerField(db_index=True, editable=False)), + ('rght', models.PositiveIntegerField(db_index=True, editable=False)), + ('tree_id', models.PositiveIntegerField(db_index=True, editable=False)), + ('level', models.PositiveIntegerField(db_index=True, editable=False)), + ('parent', mptt.fields.TreeForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='children', to='common.Location')), + ], + options={ + 'verbose_name_plural': 'Местоположения', + 'verbose_name': 'Местоположение', + }, + managers=[ + ('_default_manager', django.db.models.manager.Manager()), + ], + ), + migrations.AddField( + model_name='city', + name='country', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='cities', to='common.Country'), + ), + ] diff --git a/common/migrations/0002_auto_20160615_1625.py b/common/migrations/0002_auto_20160615_1625.py new file mode 100644 index 0000000..cbdd8cd --- /dev/null +++ b/common/migrations/0002_auto_20160615_1625.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.6 on 2016-06-15 13:25 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('common', '0001_initial'), + ] + + operations = [ + migrations.RemoveField( + model_name='city', + name='country', + ), + migrations.AlterField( + model_name='location', + name='type', + field=models.CharField(choices=[('_root', 'Корень'), ('country', 'Страна'), ('region', 'Регион'), ('town', 'Город')], default=None, max_length=20), + preserve_default=False, + ), + migrations.DeleteModel( + name='City', + ), + migrations.DeleteModel( + name='Country', + ), + ] diff --git a/common/migrations/__init__.py b/common/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/common/models.py b/common/models.py new file mode 100644 index 0000000..e3770ed --- /dev/null +++ b/common/models.py @@ -0,0 +1,21 @@ +from django.db import models +from mptt.models import TreeForeignKey, MPTTModel + +class Location(MPTTModel): + TYPES = ( + ('_root', 'Корень'), + ('country', 'Страна'), + ('region', 'Регион'), + ('town', 'Город'), + ) + + name = models.CharField(max_length=50) + parent = TreeForeignKey('self', blank=True, null=True, related_name='children', db_index=True) + type = models.CharField(max_length=20, choices=TYPES) + + def __str__(self): + return self.name + + class Meta: + verbose_name = 'Местоположение' + verbose_name_plural = 'Местоположения' diff --git a/common/tests.py b/common/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/common/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/common/views.py b/common/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/common/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/projects/admin.py b/projects/admin.py index 7c4ac6f..a61cfe0 100644 --- a/projects/admin.py +++ b/projects/admin.py @@ -1,7 +1,7 @@ from django.contrib import admin from .models import Project, Portfolio, PortfolioPhoto, \ - Answer, Realty, Candidate, Order, Stage, Country, City,\ + Answer, Realty, Candidate, Order, Stage,\ BuildingClassfication, ConstructionType, ProjectFile @@ -16,8 +16,6 @@ admin.site.register(Realty) admin.site.register(Order) admin.site.register(Candidate) admin.site.register(Stage) -admin.site.register(Country) -admin.site.register(City) admin.site.register(BuildingClassfication) admin.site.register(ConstructionType) admin.site.register(Project, ProjectAdmin) diff --git a/projects/forms.py b/projects/forms.py index e8d6dcf..46a2e51 100644 --- a/projects/forms.py +++ b/projects/forms.py @@ -46,8 +46,6 @@ class RealtyForm(ModelForm): model = Realty fields = ( - 'country', - 'city', 'building_classification', 'construction_type', 'name', @@ -56,8 +54,6 @@ class RealtyForm(ModelForm): 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): diff --git a/projects/migrations/0032_auto_20160615_1610.py b/projects/migrations/0032_auto_20160615_1610.py new file mode 100644 index 0000000..30cea38 --- /dev/null +++ b/projects/migrations/0032_auto_20160615_1610.py @@ -0,0 +1,52 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.6 on 2016-06-15 13:10 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import django.utils.timezone +import mptt.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('common', '0001_initial'), + ('projects', '0031_auto_20160610_1434'), + ] + + operations = [ + migrations.RemoveField( + model_name='city', + name='country', + ), + migrations.RemoveField( + model_name='realty', + name='city', + ), + migrations.RemoveField( + model_name='realty', + name='country', + ), + migrations.AddField( + model_name='realty', + name='location', + field=mptt.fields.TreeForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='realties', to='common.Location'), + ), + migrations.AlterField( + model_name='order', + name='created', + field=models.DateTimeField(default=django.utils.timezone.now), + ), + migrations.AlterField( + model_name='project', + name='state', + field=models.CharField(choices=[('active', 'Активный'), ('trashed', 'В корзине'), ('deleted', 'Удален')], default='active', max_length=20), + ), + migrations.DeleteModel( + name='City', + ), + migrations.DeleteModel( + name='Country', + ), + ] diff --git a/projects/models.py b/projects/models.py index 2f24027..d0be358 100644 --- a/projects/models.py +++ b/projects/models.py @@ -1,3 +1,4 @@ +from mptt.models import TreeForeignKey from datetime import datetime from django.db import models from django.utils import timezone @@ -40,34 +41,10 @@ class ConstructionType(models.Model): verbose_name_plural = 'Виды строительства' -class Country(models.Model): - name = models.CharField(max_length=255) - - def __str__(self): - return self.name - - class Meta: - verbose_name = 'Страна' - verbose_name_plural = 'Страны' - - -class City(models.Model): - name = models.CharField(max_length=255) - country = models.ForeignKey(Country, related_name='cities') - - def __str__(self): - return self.name - - class Meta: - verbose_name = 'Город' - verbose_name_plural = 'Города' - - class Realty(models.Model): building_classification = models.ForeignKey(BuildingClassfication, related_name='realties') - city = models.ForeignKey(City, related_name='realties') construction_type = models.ForeignKey(ConstructionType, related_name='realties') - country = models.ForeignKey(Country, related_name='realties') + location = TreeForeignKey('common.Location', related_name='realties', null=True, blank=True) name = models.CharField(max_length=255) user = models.ForeignKey(User, related_name='realties') diff --git a/projects/templates/_trash/project_form.html b/projects/templates/_trash/project_form.html new file mode 100644 index 0000000..63d0ed9 --- /dev/null +++ b/projects/templates/_trash/project_form.html @@ -0,0 +1,278 @@ +{% extends 'partials/base.html' %} + +{% block content %} +
+

Новый заказ

+
+ +
+ {% csrf_token %} + {{ form_project.errors }} + {{ form_realty.errors }} +
+ {{ project_form.errors }} +
+

Формирование заказа

+
+

Название заказа

+ + {{ project_form.name.errors }} +
+
+

Подробно опишите задание

+ +
+
+
+
+

Дополнительно

+
+
+ {# #} + {#
#} + {# #} + {#

+ добавить файл (до 100 файлов)

#} + {#
#} + {# #} + {# #} +
    +
  • + Архитерурное 2.jpg + 7мб +
    +
  • +
+
+

Тип работы:

+
+
+ +

Проектирование

+
+ +
+ +

Техническое сопровождение

+
+
+ +
+
+
+
+
+
Специализация проекта:
+
+
+
+
+ + +
+
+ + + +{# {{ project_form.specialization }}#} +
+
+ +
+
+ {# #} +
+
+ {# #} +
+
+
+
Бюджет
+
+
+
+
+ + +
+
+ +
+
+ +

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

+
+
+
+ +

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

+
+
+
Способ оплаты
+
+
+
+ +

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

+

+ Текст +

+
+
+ +

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

+

+ Текст +

+
+
+
+
+

Расширенный поиск

+ +
+
+
+
+
+
+
+
Выбор объекта:
+
Наименование:
+
Классификация здания:
+
Вид строительства:
+
+
+
+ +
+
+ +
+
+ +
+
+ +
+
+
+
Местоположение:
+
+
+
+ +
+
+ +
+
+ +

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

+
+
+ + + +
+
+ +
+ + + + + +{% endblock %} +{% block js_block %} + +{% endblock %} diff --git a/projects/templates/_trash/testport.html b/projects/templates/_trash/testport.html new file mode 100644 index 0000000..b21ecc8 --- /dev/null +++ b/projects/templates/_trash/testport.html @@ -0,0 +1,18 @@ +
{% csrf_token %} + {{ form.as_p }} + +
+ Photos + {{ portfolio_photo_form.management_form }} + {{ portfolio_photo_form.non_form_errors }} + {% for form in portfolio_photo_form %} + {{ form.id }} +
+ {{ form.img.errors }} + {{ form.img.label_tag }} + {{ form.img }} +
+ {% endfor %} +
+ +
diff --git a/projects/templates/contractor_project_detail.html b/projects/templates/contractor_project_detail.html index 888887a..cd9c4c3 100644 --- a/projects/templates/contractor_project_detail.html +++ b/projects/templates/contractor_project_detail.html @@ -72,7 +72,7 @@