diff --git a/api/views.py b/api/views.py index cdf1baa..170964a 100755 --- a/api/views.py +++ b/api/views.py @@ -33,7 +33,7 @@ class MessageViewSet(ModelViewSet): queryset = Message.objects.all() serializer_class = MessageSerializer filter_class = MessageFilterSet - + def get_queryset(self): queryset = Message.objects.all() search_param = self.request.query_params.get('operand', None) diff --git a/archilance/settings/base.py b/archilance/settings/base.py index 5502678..0aed8fc 100644 --- a/archilance/settings/base.py +++ b/archilance/settings/base.py @@ -40,12 +40,13 @@ THIRD_PARTY_APPS = [ LOCAL_APPS = [ 'api', 'common', + 'work_sell', 'archilance', 'projects', 'specializations', 'users', 'reviews', - 'work_sell', + 'chat', ] diff --git a/assets/js/chat.js b/assets/js/chat.js index eca3529..fe6129c 100644 --- a/assets/js/chat.js +++ b/assets/js/chat.js @@ -109,6 +109,8 @@ $(function () { dataType: 'json', success: function (json) { $.each(json.results, function (i, v) { + console.log(v.sender.id); + console.log(v.recipent.id); inbox.innerHTML += '
' + '

Иванов

13.0.2016
' + '

' + v.text + '

'; diff --git a/projects/migrations/0038_auto_20160706_1249.py b/projects/migrations/0038_auto_20160706_1249.py new file mode 100644 index 0000000..ba7272e --- /dev/null +++ b/projects/migrations/0038_auto_20160706_1249.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.6 on 2016-07-06 09:49 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion +import mptt.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('common', '0003_mainpage'), + ('specializations', '0002_auto_20160602_1203'), + ('projects', '0037_auto_20160704_1444'), + ] + + operations = [ + migrations.AddField( + model_name='portfolio', + name='budget', + field=models.DecimalField(decimal_places=0, default=0, max_digits=10, null=True), + ), + migrations.AddField( + model_name='portfolio', + name='budget_by_agreement', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='portfolio', + name='building_classification', + field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='portfolios', to='projects.BuildingClassfication'), + preserve_default=False, + ), + migrations.AddField( + model_name='portfolio', + name='construction_type', + field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='portfolios', to='projects.ConstructionType'), + preserve_default=False, + ), + migrations.AddField( + model_name='portfolio', + name='location', + field=mptt.fields.TreeForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='portfolios', to='common.Location'), + ), + migrations.AddField( + model_name='portfolio', + name='specialization', + field=mptt.fields.TreeForeignKey(default=5, on_delete=django.db.models.deletion.CASCADE, related_name='portfolios', to='specializations.Specialization'), + preserve_default=False, + ), + migrations.AddField( + model_name='portfolio', + name='term', + field=models.IntegerField(default=0), + ), + migrations.AddField( + model_name='portfolio', + name='term_type', + field=models.CharField(choices=[('project', 'За проект'), ('hour', 'За час'), ('day', 'За день'), ('month', 'За месяц')], default='hour', max_length=20), + ), + migrations.AddField( + model_name='portfolio', + name='worksell', + field=models.BooleanField(default=False), + ), + migrations.AlterField( + model_name='portfolio', + name='user', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='portfolios', to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/projects/models.py b/projects/models.py index baa9f41..e08d8f8 100644 --- a/projects/models.py +++ b/projects/models.py @@ -180,7 +180,16 @@ class Candidate(models.Model): class Portfolio(models.Model): description = models.TextField() name = models.CharField(max_length=255) - user = models.ForeignKey(User, related_name='portfolio') + budget = models.DecimalField(max_digits=10, decimal_places=0, default=0, null=True) + budget_by_agreement = models.BooleanField(default=False) + specialization = TreeForeignKey(Specialization, related_name='portfolios') + term = models.IntegerField(default=0) + term_type = models.CharField(max_length=20, choices=TERMS, default='hour') + building_classification = models.ForeignKey(BuildingClassfication, related_name='portfolios') + construction_type = models.ForeignKey(ConstructionType, related_name='portfolios') + location = TreeForeignKey('common.Location', related_name='portfolios', null=True, blank=True) + worksell = models.BooleanField(default=False) + user = models.ForeignKey(User, related_name='portfolios') def __str__(self): return self.name diff --git a/projects/templates/portfolio_create.html b/projects/templates/portfolio_create.html new file mode 100644 index 0000000..0d1eda1 --- /dev/null +++ b/projects/templates/portfolio_create.html @@ -0,0 +1,92 @@ +{% load common_tags %} + + + diff --git a/specializations/views.py b/specializations/views.py index a8a9f37..459fe4f 100644 --- a/specializations/views.py +++ b/specializations/views.py @@ -55,4 +55,5 @@ class JSONResponseMixin(object): class JSONView(JSONResponseMixin, TemplateView): def render_to_response(self, context, **response_kwargs): + context = {'test': 'data'} return self.render_to_json_response(context, **response_kwargs) diff --git a/users/templates/contractor_chat.html b/users/templates/contractor_chat.html deleted file mode 100644 index fc30eb2..0000000 --- a/users/templates/contractor_chat.html +++ /dev/null @@ -1,582 +0,0 @@ -{% extends 'partials/base.html' %} -{% load staticfiles %} -{% load common_tags %} -{% block content %} -{% include 'partials/header.html' %} -
-
-
-

Чат

-
-
-
- -
-
-
-
-
-

Заказы

-
- -

- Дизай-проект квартиры на набережной 200 m2 -

-
-

- Испонитель: Группа Икс -

-
    -
  • Иванов Петр Иванович
  • -
  • Сергей Пенкин
  • -
  • Александ Смирнов
  • -
  • Иванов Петр
  • -
-

- Чаты: Иванов, Петров, Пенкин -

- - - Полное описание заказа - -
-
-
- -

- Дизай-проект квартиры на набережной 200 m2 -

-
-

- Испонитель: Группа Икс -

-
    -
  • Иванов Петр Иванович
  • -
  • Сергей Пенкин
  • -
  • Александ Смирнов
  • -
  • Иванов Петр
  • -
-

- Чаты: Иванов, Петров, Пенкин -

- - - Полное описание заказа - -
-
-
- -

- Дизай-проект квартиры на набережной 200 m2 -

-
-

- Испонитель: Группа Икс -

-
    -
  • Иванов Петр Иванович
  • -
  • Сергей Пенкин
  • -
  • Александ Смирнов
  • -
  • Иванов Петр
  • -
-

- Чаты: Иванов, Петров, Пенкин -

- - - Полное описание заказа - -
-
-
-
-
-
-
-

- Иванов Петр Иванович -

- - 13.0.2016 / 21:05 - -
-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. -

-
-
-
-

- Вы -

- - 13.0.2016 / 21:05 - -
-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. -

-
-
-
-

- Иванов Петр Иванович -

- - 13.0.2016 / 21:05 - -
-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. -

-
-
-
-

- Вы -

- - 13.0.2016 / 21:05 - -
-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. -

-
-
-
-

- Вы -

- - 13.0.2016 / 21:05 - -
-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. -

-
- -
-
-

Прикрепить файл

- - Не более 10 файлов с общим объемом 500мб - -
- отправить -
-
-
-
-

Контакты

- -
-
-
- Начало: - Срок сдачи: -
-
- 13.0.2016 - 13.0.2016 -
-
-
-

Входящие документы

-
    -
  • - Архитерурное 2.jpg - 7мб -
    -
  • -
  • - Архитерурное 2.jpg - 7мб -
    -
  • -
  • - Архитерурное 2.jpg - 7мб -
    -
  • -
- - Распечатать с помощью ресурса - -
-
-

Для заметок

- - сохранить -
- - -
-
-
- -
-
-
-

- Иванов Петр Иванович -

- - 13.0.2016 / 21:05 - -
-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. -

-
-
-
-

- Вы -

- - 13.0.2016 / 21:05 - -
-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. -

-
-
-
-

- Иванов Петр Иванович -

- - 13.0.2016 / 21:05 - -
-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. -

-
-
-
-

- Вы -

- - 13.0.2016 / 21:05 - -
-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. -

-
-
-
-

- Вы -

- - 13.0.2016 / 21:05 - -
-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. -

-
- -
-
-

Прикрепить файл

- - Не более 10 файлов с общим объемом 500мб - -
- отправить -
-
-
-
-

Для заметок

- - сохранить -
- -
-
-
-
-
-

Заказы

-
- -

- Дизай-проект квартиры на набережной 200 m2 -

-
-

- Заказчик: Группа Икс -

-
    -
  • Иванов Петр Иванович
  • -
  • Сергей Пенкин
  • -
- - - Полное описание заказа - -
-
-
- -

- Дизай-проект квартиры на набережной 200 m2 -

-
-

- Заказчик: Группа Икс -

-
    -
  • Иванов Петр Иванович
  • -
  • Сергей Пенкин
  • -
- - - Полное описание заказа - -
-
-
- -

- Дизай-проект квартиры на набережной 200 m2 -

-
-

- Заказчик: Группа Икс -

-
    -
  • Иванов Петр Иванович
  • -
  • Сергей Пенкин
  • -
- - - Полное описание заказа - -
-
-
-
-
-
-
-

- Иванов Петр Иванович -

- - 13.0.2016 / 21:05 - -
-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. -

-
-
-
-

- Вы -

- - 13.0.2016 / 21:05 - -
-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. -

-
-
-
-

- Иванов Петр Иванович -

- - 13.0.2016 / 21:05 - -
-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. -

-
-
-
-

- Вы -

- - 13.0.2016 / 21:05 - -
-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. -

-
-
-
-

- Вы -

- - 13.0.2016 / 21:05 - -
-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. -

-
- -
-
-

Прикрепить файл

- - Не более 10 файлов с общим объемом 500мб - -
- отправить -
-
-
-

Этапы работы

-
-

1 / Согласование условий

-

- Обсуджение задания и условий выполнения работы. Подтверждение заказа исполнителем. -

-
-
-
-

- Этап 1Название этапа -

-

- Результаты этапа: Готовый чертеж 1 -

-
-

до 16.03.2015

- 30 000 -
-
-
-
-
-

- Этап 2Название этапа -

-

- Результаты этапа: Готовый чертеж 1 -

-
-

до 16.03.2015

- 30 000 -
-
-
- -
-

2 / Резервирование

-

- Резервирование заказчиком суммы оплаты по заказ. Деньги перечисляются и хранятся на сайте. -

-
    -
  • Сумма еще не зарезервирована
  • -
  • Сумма за этап1, Зарезервирована
  • -
-
-
-

3 / Выполнение работы

-

- Процесс выполнения задания в заказе до получения заказчиком итогового результата работы. -

-
-
-
-
- {% include 'partials/footer.html' %} -
-
-{% endblock %} diff --git a/users/templates/contractor_profile.html b/users/templates/contractor_profile.html index ff950e4..3c3568c 100644 --- a/users/templates/contractor_profile.html +++ b/users/templates/contractor_profile.html @@ -4,49 +4,48 @@ {% block content %} {% include 'partials/header.html' %} - +
-
- profile-image -
+
+ profile-image
+
- {% load specializtions_tags %} + {% load specializtions_tags %} {% specialization_widget contractor.pk %}
@@ -73,10 +72,10 @@ {% ratings_widget contractor.pk %} {% if contractor.cro %} -
-
-

Есть допуск СРО

-
+
+
+

Есть допуск СРО

+
{% endif %} @@ -100,20 +99,35 @@
- +
- + + + +
{% for p in user.portfolio.all %}
-
+
@@ -132,45 +146,60 @@ {% endfor %}
- +
- +
+
{% for ws in user.work_sell.all %}
-
-
-
-
-
-
- {{ ws.price }} +
+
+
-
-
-
-

{{ ws }}

-
-
- +
+
+ {{ ws.budget }} +
-
- +
+
+

{{ ws }}

+
+
+ + + +
+
+ +
-
{% endfor %}
@@ -179,7 +208,7 @@
- +
@@ -252,7 +281,7 @@

Загрузить файл

- +
@@ -270,7 +299,7 @@
- +
@@ -288,7 +317,7 @@
- +
@@ -298,7 +327,7 @@

Загрузить файл

- +
@@ -316,7 +345,7 @@
- +
@@ -334,19 +363,19 @@
- +
- +

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. Proin sodales pulvinar tempor. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Nam fermentum, nulla luctus pharetra vulputate, felis tellus mollis orci, sed rhoncus sapien nunc eget odio. + Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum +

- +
{% include 'partials/footer.html' %}
@@ -374,3 +404,40 @@
{% endblock %} + + +{% block js_block %} + +{% endblock %} diff --git a/users/templates/customer_chat.html b/users/templates/customer_chat.html deleted file mode 100644 index 252d488..0000000 --- a/users/templates/customer_chat.html +++ /dev/null @@ -1,312 +0,0 @@ -{% extends 'partials/base.html' %} -{% load staticfiles %} -{% load common_tags %} -{% block content %} -{% include 'partials/header.html' %} - -
-
-
-

Чат

-
-
-
-
- -
-
-
-
-
-
-

Заказы

-
- -

- Дизай-проект квартиры на набережной 200 m2 -

-
-

- Испонитель: Группа Икс -

-
    -
  • Иванов Петр Иванович
  • -
  • Сергей Пенкин
  • -
  • Александ Смирнов
  • -
  • Иванов Петр
  • -
-

- Чаты: Иванов, Петров, Пенкин -

- - - Полное описание заказа - -
-
-
- -

- Дизай-проект квартиры на набережной 200 m2 -

-
-

- Испонитель: Группа Икс -

-
    -
  • Иванов Петр Иванович
  • -
  • Сергей Пенкин
  • -
  • Александ Смирнов
  • -
  • Иванов Петр
  • -
-

- Чаты: Иванов, Петров, Пенкин -

- - - Полное описание заказа - -
-
-
-
-
-
-
-

- Иванов Петр Иванович -

- - 13.0.2016 / 21:05 - -
-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. -

-
-
-
-

- Вы -

- - 13.0.2016 / 21:05 - -
-

- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean euismod bibendum laoreet. Proin gravida dolor sit amet lacus accumsan et viverra justo commodo. -

-
- -
-
-

Прикрепить файл

- - Не более 10 файлов с общим объемом 500мб - -
- отправить -
-
-
-
-

Контакты

- -
-
-
- Начало: - Срок сдачи: -
-
- 13.0.2016 - 13.0.2016 -
-
-
-

Входящие документы

-
    -
  • - Архитерурное 2.jpg - 7мб -
    -
  • -
- - Распечатать с помощью ресурса - -
-
-

Для заметок

- - сохранить -
- - -
-
-
-
-
-

Заказы

-
- -

- Дизай-проект квартиры на набережной 200 m2 -

-
-

- Заказчик: Группа Икс -

-
    -
  • Иванов Петр Иванович
  • -
  • Сергей Пенкин
  • -
- - - Полное описание заказа - -
-
-
- -

- Дизай-проект квартиры на набережной 200 m2 -

-
-

- Заказчик: Группа Икс -

-
    -
  • Иванов Петр Иванович
  • -
  • Сергей Пенкин
  • -
- - - Полное описание заказа - -
-
-
-
-
-
-
-

- Иванов Петр Иванович -

- - 13.0.2016 / 21:05 - -
-

- Lorem ipsum dolor sit amet

-
-
-
-

- Вы -

- - 13.0.2016 / 21:05 - -
-

- Lorem ipsum dolor sit amet

-
- -
-
-

Прикрепить файл

- - Не более 10 файлов с общим объемом 500мб - -
- отправить -
-
-
-

Этапы работы

-
-

1 / Согласование условий

-

- Обсуджение задания и условий выполнения работы. Подтверждение заказа исполнителем. -

-
-
-
-

- Этап 1Название этапа -

-

- Результаты этапа: Готовый чертеж 1 -

-
-

до 16.03.2015

- 30 000 -
-
-
-
-
-

- Этап 2Название этапа -

-

- Результаты этапа: Готовый чертеж 1 -

-
-

до 16.03.2015

- 30 000 -
-
-
- -
-

2 / Резервирование

-

- Резервирование заказчиком суммы оплаты по заказ.

-
    -
  • Сумма еще не зарезервирована
  • -
  • Сумма за этап1, Зарезервирована
  • -
-
-
-

3 / Выполнение работы

-

- Процесс выполнения задания в заказе

-
-
-
-
- {% include 'partials/footer.html' %} -
-
-{% endblock %} diff --git a/users/templates/portfolio_create_form.html b/users/templates/portfolio_create_form.html new file mode 100644 index 0000000..beb2de8 --- /dev/null +++ b/users/templates/portfolio_create_form.html @@ -0,0 +1,82 @@ +{% load common_tags %} + + + diff --git a/users/templates/worksell_create_form.html b/users/templates/worksell_create_form.html new file mode 100644 index 0000000..7327442 --- /dev/null +++ b/users/templates/worksell_create_form.html @@ -0,0 +1,90 @@ +{% load common_tags %} + + + diff --git a/users/urls.py b/users/urls.py index d004649..d12a052 100755 --- a/users/urls.py +++ b/users/urls.py @@ -12,8 +12,6 @@ from .views import ( CustomerProfileTrashedProjectsView, ContractorFinancialInfoEdit, CustomerProfileEditView, - CustomerChat, - ContractorChat, # UserDetailView, # UserInfoListView, UserListView, @@ -38,7 +36,5 @@ urlpatterns = [ # urls.url(r'^(?P\d+)/$', UserView.as_view(), name='user_view'), urls.url(r'contractors/(?P\d+)/edit/$', ContractorProfileEditView.as_view(), name='contractor-edit'), urls.url(r'customers/(?P\d+)/edit/$', CustomerProfileEditView.as_view(), name='customers-edit'), - urls.url(r'customer/chat/$', CustomerChat.as_view(), name='customer-chat'), - urls.url(r'contractor/chat/$', ContractorChat.as_view(), name='contractor-chat'), urls.url(r'contractors/(?P\d+)/financialinfo/edit/$', ContractorFinancialInfoEdit.as_view(), name='contractor-financical'), ] diff --git a/users/views.py b/users/views.py index aeeb4e9..1ce4004 100644 --- a/users/views.py +++ b/users/views.py @@ -8,11 +8,13 @@ from django.core.urlresolvers import reverse from archilance.mixins import BaseMixin from common.utils import get_or_none from specializations.models import Specialization +from work_sell.forms import WorkSellForm from .models import User, ContractorFinancialInfo from .mixins import CheckForUserMixin from .forms import UserEditForm, ContractorFinancicalInfoForm + class UserListView(ListView): model = User template_name = 'users_list.html' @@ -27,9 +29,15 @@ class ContractorListView(ListView): class ContractorProfileDetailView(DetailView): model = User + worksell_form_class = WorkSellForm template_name = 'contractor_profile.html' context_object_name = 'contractor' + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context['worksell_form'] = self.worksell_form_class + return context + class ContractorOfficeDetailView(DetailView): model = User @@ -139,16 +147,3 @@ class ContractorFinancialInfoEdit(CheckForUserMixin, View): return render(request, self.template_name,{'form': form}) - -class CustomerChat(View): - template_name = 'customer_chat.html' - - def get(self, request, *args, **kwargs): - return render(request, self.template_name) - - -class ContractorChat(View): - template_name = 'contractor_chat.html' - - def get(self, request, *args, **kwargs): - return render(request, self.template_name) diff --git a/work_sell/forms.py b/work_sell/forms.py index 4483fed..86979b8 100644 --- a/work_sell/forms.py +++ b/work_sell/forms.py @@ -1,9 +1,22 @@ from django import forms +from common.models import Location from .models import WorkSell + class WorkSellForm(forms.ModelForm): class Meta: model = WorkSell fields = '__all__' + + widgets = { + 'construction_type': forms.Select(attrs={'class':'selectpicker'}), + 'building_classification': forms.Select(attrs={'class':'selectpicker'}), + } + + def __init__(self, *args, **kwargs): + # self.request = kwargs.pop('request') + super().__init__(*args, **kwargs) + + self.fields['location'].queryset = Location.objects.root_nodes()[0].get_descendants() diff --git a/work_sell/migrations/0008_auto_20160706_1249.py b/work_sell/migrations/0008_auto_20160706_1249.py new file mode 100644 index 0000000..569d9b3 --- /dev/null +++ b/work_sell/migrations/0008_auto_20160706_1249.py @@ -0,0 +1,67 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.6 on 2016-07-06 09:49 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import mptt.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('projects', '0038_auto_20160706_1249'), + ('common', '0003_mainpage'), + ('specializations', '0002_auto_20160602_1203'), + ('work_sell', '0007_auto_20160705_1514'), + ] + + operations = [ + migrations.RemoveField( + model_name='worksell', + name='price', + ), + migrations.AddField( + model_name='worksell', + name='budget', + field=models.DecimalField(decimal_places=0, default=0, max_digits=10, null=True), + ), + migrations.AddField( + model_name='worksell', + name='budget_by_agreement', + field=models.BooleanField(default=False), + ), + migrations.AddField( + model_name='worksell', + name='building_classification', + field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='worksells', to='projects.BuildingClassfication'), + preserve_default=False, + ), + migrations.AddField( + model_name='worksell', + name='construction_type', + field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE, related_name='worksells', to='projects.ConstructionType'), + preserve_default=False, + ), + migrations.AddField( + model_name='worksell', + name='location', + field=mptt.fields.TreeForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='worksells', to='common.Location'), + ), + migrations.AddField( + model_name='worksell', + name='specialization', + field=mptt.fields.TreeForeignKey(default=5, on_delete=django.db.models.deletion.CASCADE, related_name='worksells', to='specializations.Specialization'), + preserve_default=False, + ), + migrations.AddField( + model_name='worksell', + name='term', + field=models.IntegerField(default=0), + ), + migrations.AddField( + model_name='worksell', + name='term_type', + field=models.CharField(choices=[('project', 'За проект'), ('hour', 'За час'), ('day', 'За день'), ('month', 'За месяц')], default='hour', max_length=20), + ), + ] diff --git a/work_sell/migrations/0009_auto_20160707_1315.py b/work_sell/migrations/0009_auto_20160707_1315.py new file mode 100644 index 0000000..15bb2d8 --- /dev/null +++ b/work_sell/migrations/0009_auto_20160707_1315.py @@ -0,0 +1,56 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.6 on 2016-07-07 10:15 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import mptt.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('work_sell', '0008_auto_20160706_1249'), + ] + + operations = [ + migrations.RemoveField( + model_name='worksell', + name='budget_by_agreement', + ), + migrations.AddField( + model_name='worksell', + name='currency', + field=models.CharField(blank=True, choices=[('rur', 'RUR'), ('usd', 'USD'), ('eur', 'EUR')], default='rur', max_length=20, null=True), + ), + migrations.AlterField( + model_name='worksell', + name='budget', + field=models.DecimalField(blank=True, decimal_places=0, default=0, max_digits=10, null=True), + ), + migrations.AlterField( + model_name='worksell', + name='building_classification', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='worksells', to='projects.BuildingClassfication'), + ), + migrations.AlterField( + model_name='worksell', + name='construction_type', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='worksells', to='projects.ConstructionType'), + ), + migrations.AlterField( + model_name='worksell', + name='specialization', + field=mptt.fields.TreeForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='worksells', to='specializations.Specialization'), + ), + migrations.AlterField( + model_name='worksell', + name='term', + field=models.IntegerField(blank=True, default=0, null=True), + ), + migrations.AlterField( + model_name='worksell', + name='term_type', + field=models.CharField(blank=True, choices=[('project', 'За проект'), ('hour', 'За час'), ('day', 'За день'), ('month', 'За месяц')], default='hour', max_length=20, null=True), + ), + ] diff --git a/work_sell/migrations/0010_auto_20160707_1401.py b/work_sell/migrations/0010_auto_20160707_1401.py new file mode 100644 index 0000000..321b296 --- /dev/null +++ b/work_sell/migrations/0010_auto_20160707_1401.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.6 on 2016-07-07 11:01 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.utils.timezone +import sorl.thumbnail.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('work_sell', '0009_auto_20160707_1315'), + ] + + operations = [ + migrations.AlterField( + model_name='worksell', + name='created', + field=models.DateTimeField(blank=True, default=django.utils.timezone.now, null=True), + ), + migrations.AlterField( + model_name='worksell', + name='img', + field=sorl.thumbnail.fields.ImageField(blank=True, null=True, upload_to='worksell/worksell'), + ), + ] diff --git a/work_sell/models.py b/work_sell/models.py index 89d9ee0..6aa6af2 100644 --- a/work_sell/models.py +++ b/work_sell/models.py @@ -1,16 +1,28 @@ +from mptt.models import TreeForeignKey +from sorl.thumbnail import ImageField + from django.db import models from django.utils import timezone -from sorl.thumbnail import ImageField + from users.models import User +from projects.models import BuildingClassfication, ConstructionType, TERMS, CURRENCIES +from specializations.models import Specialization class WorkSell(models.Model): name = models.CharField(max_length=255) description = models.TextField(blank=True) - img = ImageField(upload_to='worksell/worksell') - price = models.DecimalField(max_digits=10, decimal_places=0, default=0) + img = ImageField(upload_to='worksell/worksell', null=True, blank=True) + budget = models.DecimalField(max_digits=10, decimal_places=0, default=0, null=True, blank=True) + currency = models.CharField(max_length=20, default='rur', choices=CURRENCIES, null=True, blank=True) + specialization = TreeForeignKey(Specialization, related_name='worksells', null=True, blank=True) + term = models.IntegerField(default=0, null=True, blank=True) + term_type = models.CharField(max_length=20, choices=TERMS, default='hour', null=True, blank=True) contractor = models.ForeignKey(User, related_name='work_sell') - created = models.DateTimeField(default=timezone.now) + building_classification = models.ForeignKey(BuildingClassfication, related_name='worksells', null=True, blank=True) + construction_type = models.ForeignKey(ConstructionType, related_name='worksells', null=True, blank=True) + location = TreeForeignKey('common.Location', related_name='worksells', null=True, blank=True) + created = models.DateTimeField(default=timezone.now, null=True, blank=True) def __str__(self): return self.name diff --git a/work_sell/templates/worksell_create.html b/work_sell/templates/worksell_create.html new file mode 100644 index 0000000..752e85f --- /dev/null +++ b/work_sell/templates/worksell_create.html @@ -0,0 +1,55 @@ +{% extends 'partials/base.html' %} +{% block content %} +
{% csrf_token %} + +
+ + + + Add files... + + +
+ +
+{% endblock %} + +{% block js_block %} + + +{% endblock %} diff --git a/work_sell/templates/worksell_edit.html b/work_sell/templates/worksell_edit.html new file mode 100644 index 0000000..8a52a84 --- /dev/null +++ b/work_sell/templates/worksell_edit.html @@ -0,0 +1,102 @@ +{% extends 'partials/base.html' %} + +{% load common_tags %} + +{% block content %} + {% include 'partials/header.html' %} + +
+
+
+

Изменение готового проекта

+
+ +
{% csrf_token %} +
+

Название заказа {{ form.name.errors.as_text }}

+ +
+ +
+

Подробно опишите задание {{ form.description.errors.as_text }}

+ +
+ +
+

Специализации

+
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + + + +
+

Бюджет{{ form.budget.errors.as_text }}

+
+
+ +
+
+ {{ form.currency}} +
+
+
+ +
+

Срок выполнения{{ form.budget.errors.as_text }}

+
+
+ +
+
+ {{ form.term_type }} +
+
+
+ +
+
+
+

Вид строительства

+ {{ form.construction_type}} +
+ +
+

Классификация здания

+ {{ form.building_classification}} +
+ +
+ +
+ +
+ +
+ + + +
+ {% include 'partials/footer.html' %} +
+
+{% endblock %} diff --git a/work_sell/templates/worksells_list.html b/work_sell/templates/worksells_list.html index 586545a..b3cf2f9 100644 --- a/work_sell/templates/worksells_list.html +++ b/work_sell/templates/worksells_list.html @@ -3,87 +3,7 @@ {% load thumbnail %} {% block content %} - +{% include 'partials/header.html' %}
@@ -93,33 +13,25 @@
-
Тип работ:
Специализации:
+
- +
- +
- +
- +
+
Тип работ:
@@ -215,11 +127,12 @@

{{ work }}

-
-
- -
+ +
+ +
+
diff --git a/work_sell/urls.py b/work_sell/urls.py index 6db4aaf..a560133 100644 --- a/work_sell/urls.py +++ b/work_sell/urls.py @@ -3,11 +3,17 @@ from django.conf import urls from .views import ( WorkSellsView, WorkSellDetail, + WorkSellCreateView, + WorkSellUpdateView, + work_sell_create, ) app_name = 'work_sell' urlpatterns = [ urls.url(r'^$', WorkSellsView.as_view(), name='list'), + urls.url(r'^create/$', WorkSellCreateView.as_view(), name='create'), + urls.url(r'^(?P\d+)/edit/$', WorkSellUpdateView.as_view(), name='edit'), + urls.url(r'^test/$', work_sell_create, name='test'), urls.url(r'^(?P\d+)/$', WorkSellDetail.as_view(), name='detail'), ] diff --git a/work_sell/views.py b/work_sell/views.py index 615a489..63093ae 100644 --- a/work_sell/views.py +++ b/work_sell/views.py @@ -1,7 +1,11 @@ +import json from django.shortcuts import render -from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView +from django.core.urlresolvers import reverse +from django.http import JsonResponse, HttpResponse +from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView, TemplateView from .models import WorkSell +from .forms import WorkSellForm class WorkSellsView(ListView): @@ -20,13 +24,52 @@ class WorkSellDetail(DetailView): return context +def work_sell_create(request): + if request.is_ajax(): + form = WorkSellForm(data=request.POST) + if form.is_valid(): + instance = form.save(commit=False) + instance.save() + data = {'status': 'ok'} + else: + data = {'status': 'no', 'form_errors': form.errors} + return HttpResponse(json.dumps(data), content_type='application/json') + return HttpResponse("HEllo") + + class WorkSellCreateView(CreateView): model = WorkSell + form_class = WorkSellForm + template_name = 'worksell_create.html' -class WorkSellUpdateView(CreateView): +class WorkSellUpdateView(UpdateView): model = WorkSell + form_class = WorkSellForm + template_name = 'worksell_edit.html' + + def get_success_url(self): + return reverse('work_sell:list') class WorkSellDeleteView(CreateView): model = WorkSell + + +class JSONResponseMixin(object): + def render_to_json_response(self, context, **response_kwargs): + return JsonResponse( + self.get_data(context), + **response_kwargs + ) + + def get_data(self, context): + context = {'test': 'data'} + return context + + +class JSONView(JSONResponseMixin, TemplateView): + def render_to_response(self, context, **response_kwargs): + return self.render_to_json_response(context, **response_kwargs) + +