diff --git a/api/urls.py b/api/urls.py index 81f751d..a414824 100755 --- a/api/urls.py +++ b/api/urls.py @@ -8,6 +8,7 @@ from .views import ( UserViewSet, MessageViewSet, StageViewSet, + NoteViewSet, ) @@ -20,5 +21,6 @@ router.register(r'realties', RealtyViewSet) router.register(r'specializations', SpecializationViewSet) router.register(r'users', UserViewSet) router.register(r'message', MessageViewSet) +router.register(r'note', NoteViewSet) urlpatterns = router.urls diff --git a/api/views.py b/api/views.py index a8d358d..69ed315 100755 --- a/api/views.py +++ b/api/views.py @@ -18,9 +18,9 @@ from common.models import Location from common.serializers import LocationSerializer from common.filters import LocationFilterSet -from chat.models import Message -from chat.serializers import MessageSerializer -from chat.filters import MessageFilterSet +from chat.models import Message, Notes +from chat.serializers import MessageSerializer, NoteSerializer +from chat.filters import MessageFilterSet, NoteFilterSet class StageViewSet(ModelViewSet): @@ -29,10 +29,6 @@ class StageViewSet(ModelViewSet): filter_class = StageFilterSet permission_classes = (permissions.IsAuthenticatedOrReadOnly,) - # def put(self, request, *args, **kwargs): - # # import code; code.interact(local=dict(globals(), **locals())) - # return super().update(request, *args, **kwargs) - class ProjectViewSet(ModelViewSet): queryset = Project.objects.all() @@ -40,6 +36,12 @@ class ProjectViewSet(ModelViewSet): filter_class = ProjectFilterSet +class NoteViewSet(ModelViewSet): + queryset = Notes.objects.all() + serializer_class = NoteSerializer + filter_class = NoteFilterSet + permission_classes = (permissions.IsAuthenticatedOrReadOnly,) + class MessageViewSet(ModelViewSet): queryset = Message.objects.all() serializer_class = MessageSerializer @@ -57,14 +59,12 @@ class MessageViewSet(ModelViewSet): return queryset - class RealtyViewSet(ModelViewSet): queryset = Realty.objects.all() serializer_class = RealtySerializer filter_class = RealtyFilterSet - class SpecializationViewSet(ModelViewSet): queryset = Specialization.objects.root_nodes()[0].get_descendants() # queryset = Specialization.objects # Migrate with this enabled diff --git a/archilance/settings/base.py b/archilance/settings/base.py index 79509db..2c61f25 100644 --- a/archilance/settings/base.py +++ b/archilance/settings/base.py @@ -52,6 +52,7 @@ LOCAL_APPS = [ 'users', 'reviews', 'chat', + 'wallets', ] INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS diff --git a/archilance/urls.py b/archilance/urls.py index 0f7eead..a860e6a 100644 --- a/archilance/urls.py +++ b/archilance/urls.py @@ -18,6 +18,7 @@ urlpatterns = [ url(r'^chat/', include('chat.urls')), url(r'^specializations/', include('specializations.urls')), url(r'^users/', include('users.urls')), + url(r'^common/', include('common.urls')), url(r'^users/', include('registration.backends.default.urls')), url(r'^admin/', admin.site.urls), diff --git a/assets/css/extra.css b/assets/css/extra.css index 96bebd4..3a87ae4 100644 --- a/assets/css/extra.css +++ b/assets/css/extra.css @@ -64,3 +64,21 @@ background-color: #00bb7b; font-size: 17px; } + +.textAreaBlock2 input[type="text"] { + margin: 0; +} + + +.stepssBlock ul li.reserved::before { + background: rgba(0, 0, 0, 0) url("../img/reserved2.png") no-repeat scroll center center / cover ; + height: 16px; + width: 17px; +} + + +.stepssBlock ul li.unreserved::before { + background: rgba(0, 0, 0, 0) url("../img/reserved.png") no-repeat scroll center center / cover ; + height: 14px; + width: 13px; +} diff --git a/chat/filters.py b/chat/filters.py index 63c24e0..727b598 100644 --- a/chat/filters.py +++ b/chat/filters.py @@ -1,6 +1,6 @@ from rest_framework_filters import FilterSet, RelatedFilter, AllLookupsFilter -from .models import Message +from .models import Message, Notes class MessageFilterSet(FilterSet): @@ -12,3 +12,13 @@ class MessageFilterSet(FilterSet): class Meta: model = Message + + +class NoteFilterSet(FilterSet): + text = AllLookupsFilter() + created = AllLookupsFilter() + sender = RelatedFilter('users.filters.UserFilterSet') + recipent = RelatedFilter('users.filters.UserFilterSet') + + class Meta: + model = Notes diff --git a/chat/serializers.py b/chat/serializers.py index e3b6146..3397e72 100644 --- a/chat/serializers.py +++ b/chat/serializers.py @@ -20,7 +20,16 @@ class MessageSerializer(ModelSerializer): ) -# class NotesSerializer(ModelSerializer): -# -# class Meta: -# model = Notes +class NoteSerializer(ModelSerializer): + + class Meta: + model = Notes + + fields = ( + 'text', + 'created', + 'order', + 'sender', + 'recipent', + ) + diff --git a/chat/templates/chat_contractor.html b/chat/templates/chat_contractor.html index 679a396..17a40da 100644 --- a/chat/templates/chat_contractor.html +++ b/chat/templates/chat_contractor.html @@ -8,6 +8,7 @@

Чат {{ request.user }} {{ request.user.pk }}

+
@@ -29,7 +30,9 @@
+
+
@@ -56,102 +59,46 @@
-
-
-
+
+
-

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

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

Контакты

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

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

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

Заказы

{% for order in orders %} -
+
-

- {{ order }} -

+

{{ order }}

-

- Испонитель: {{ request.user.get_full_name }} -

-

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

+

Исполнитель: {{ request.user.get_full_name }}

+

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

Полное описание заказа @@ -163,27 +110,24 @@
-
+
+

Этапы работы

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

@@ -193,16 +137,33 @@
+
+

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

+

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

+
    +
    + +
    +
      +

    Для заметок

    - - сохранить -
    -
    + + +
    @@ -250,9 +211,6 @@
    -

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

    @@ -272,6 +230,7 @@

    +
    {% include 'partials/footer.html' %}
    @@ -282,10 +241,6 @@ {% block js_block %} {# #} diff --git a/common/admin.py b/common/admin.py index 12d32ef..01a9179 100644 --- a/common/admin.py +++ b/common/admin.py @@ -1,7 +1,7 @@ from django.contrib import admin from mptt.admin import MPTTModelAdmin -from .models import Location, MainPage, Settings +from .models import Location, MainPage, Settings, PrintOrder, PrintDocuments class LocationAdmin(MPTTModelAdmin): readonly_fields = ('pk', 'lft', 'rght', 'tree_id', 'level') @@ -9,3 +9,5 @@ class LocationAdmin(MPTTModelAdmin): admin.site.register(Location, LocationAdmin) admin.site.register(MainPage) admin.site.register(Settings) +admin.site.register(PrintOrder) +admin.site.register(PrintDocuments) diff --git a/common/forms.py b/common/forms.py new file mode 100644 index 0000000..80b0cc3 --- /dev/null +++ b/common/forms.py @@ -0,0 +1,28 @@ +from django import forms +from .models import PrintOrder, PrintDocuments + + +class PrintOrderForm(forms.ModelForm): + files = forms.ModelMultipleChoiceField( + queryset=PrintDocuments.objects.none(), + widget=forms.CheckboxSelectMultiple, + required=False, + ) + + class Meta: + model = PrintOrder + + fields = ( + 'sender', + 'phone', + 'address', + 'shipping', + 'files', + 'text', + ) + + def __init__(self, *args, **kwargs): + self.request = kwargs.pop('request') + super().__init__(*args, **kwargs) + if self.instance.pk: + self.fields['files'].queryset = self.instance.files diff --git a/common/migrations/0002_auto_20160729_1530.py b/common/migrations/0002_auto_20160729_1530.py new file mode 100644 index 0000000..6fb3c27 --- /dev/null +++ b/common/migrations/0002_auto_20160729_1530.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-07-29 12:30 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('common', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='PrintDocuments', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('file', models.FileField(upload_to='common/printdocuments/')), + ], + options={ + 'verbose_name': 'Документы на распечатку', + 'verbose_name_plural': 'Документы на распечатку', + }, + ), + migrations.CreateModel( + name='PrintOrder', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('sender', models.CharField(max_length=150)), + ('phone', models.CharField(max_length=50)), + ('address', models.CharField(max_length=255)), + ('created', models.DateTimeField(default=django.utils.timezone.now)), + ('shipping', models.CharField(choices=[('self_delivery', 'Самовывоз'), ('courier_delivery', 'Доставка курьером')], default='self_delivery', max_length=30)), + ('text', models.TextField()), + ], + options={ + 'verbose_name': 'Заявка на распечатку', + 'verbose_name_plural': 'Заявки на распечатку', + }, + ), + migrations.AddField( + model_name='printdocuments', + name='printorder', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='print_documents', to='common.PrintOrder'), + ), + ] diff --git a/common/migrations/0003_auto_20160729_1747.py b/common/migrations/0003_auto_20160729_1747.py new file mode 100644 index 0000000..0fa308b --- /dev/null +++ b/common/migrations/0003_auto_20160729_1747.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-07-29 14:47 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('common', '0002_auto_20160729_1530'), + ] + + operations = [ + migrations.AddField( + model_name='settings', + name='document_send_description', + field=models.TextField(blank=True), + ), + migrations.AddField( + model_name='settings', + name='document_send_email', + field=models.EmailField(default='muhtarzubanchi05@gmail.com', max_length=100), + ), + migrations.AddField( + model_name='settings', + name='document_send_time_remove', + field=models.IntegerField(default=14), + ), + ] diff --git a/common/models.py b/common/models.py index 57666a3..a1c6e8b 100644 --- a/common/models.py +++ b/common/models.py @@ -1,4 +1,5 @@ from django.db import models +from django.utils import timezone from mptt.models import TreeForeignKey, MPTTModel @@ -36,6 +37,9 @@ class MainPage(models.Model): class Settings(models.Model): time_notification = models.IntegerField(default=180) + document_send_email = models.EmailField(max_length=100, default="muhtarzubanchi05@gmail.com") + document_send_description = models.TextField(blank=True) + document_send_time_remove = models.IntegerField(default=14) def __str__(self): return 'Настройки сайта' @@ -43,3 +47,35 @@ class Settings(models.Model): class Meta: verbose_name = 'Настройки сайта' verbose_name_plural = 'Настройки сайта' + + +class PrintOrder(models.Model): + SHIPPINGS = ( + ('self_delivery', 'Самовывоз'), + ('courier_delivery', 'Доставка курьером'), + ) + sender = models.CharField(max_length=150) + phone = models.CharField(max_length=50) + address = models.CharField(max_length=255) + created = models.DateTimeField(default=timezone.now) + shipping = models.CharField(max_length=30, default='self_delivery', choices=SHIPPINGS) + text = models.TextField() + + def __str__(self): + return self.sender + + class Meta: + verbose_name = 'Заявка на распечатку' + verbose_name_plural = 'Заявки на распечатку' + + +class PrintDocuments(models.Model): + printorder = models.ForeignKey(PrintOrder, related_name='print_documents') + file = models.FileField(upload_to='common/printdocuments/') + + def __str__(self): + return self.file.url + + class Meta: + verbose_name = 'Документы на распечатку' + verbose_name_plural = 'Документы на распечатку' diff --git a/common/templates/document_email.html b/common/templates/document_email.html new file mode 100644 index 0000000..547defd --- /dev/null +++ b/common/templates/document_email.html @@ -0,0 +1,4 @@ + +Welcome {{ username }}! + +Your username is {{ username }} and your password is {{ files }}. diff --git a/common/templates/printdocument_create.html b/common/templates/printdocument_create.html new file mode 100644 index 0000000..973bd99 --- /dev/null +++ b/common/templates/printdocument_create.html @@ -0,0 +1,100 @@ +{% extends 'partials/base.html' %} +{% load staticfiles %} +{% load thumbnail %} +{% block content %} + {% include 'partials/header.html' %} +
    +
    +

    Услуга по распечатке документов

    +
    + {% csrf_token %} + +
    +
    +

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

    + + {% if form.non_field_errors %} +
    {{ form.non_field_errors }}
    + {% endif %} +
    + +
    +
    +

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

    +
    + +
      + +
    +
    +
    + +
    +

    Описание {{ form.text.errors.as_text }}

    + +
    + +
    +
    + +

    Самовывоз

    +
    + +
    + + +

    Доставка курьером

    + +
    +
    + +
    +

    Получатель{{ form.sender.errors.as_text }}

    + +
    + +
    +

    Телефон{{ form.phone.errors.as_text }}

    + +
    + +
    +

    Адрес{{ form.address.errors.as_text }}

    + +
    + + + +
    +
    +

    Описание услуги и расценки

    +
    +
    +
    + {% include 'partials/footer.html' %} +
    +
    +{% endblock %} diff --git a/common/urls.py b/common/urls.py new file mode 100644 index 0000000..de30340 --- /dev/null +++ b/common/urls.py @@ -0,0 +1,11 @@ +from django.conf import urls + +from .views import ( + PrintDocumentCreate, +) + +app_name = 'common' + +urlpatterns = [ + urls.url(r'^printdocument/create/$', PrintDocumentCreate.as_view(), name='create'), +] diff --git a/common/views.py b/common/views.py index 91ea44a..ef0b94d 100644 --- a/common/views.py +++ b/common/views.py @@ -1,3 +1,49 @@ -from django.shortcuts import render +from django.shortcuts import render, redirect +from django.contrib import messages +from django.core.mail import send_mail +from django.template.loader import get_template +from django.template import Context +from django.http import HttpResponse +from django.views.generic import View +from archilance.mixins import BaseMixin -# Create your views here. +from .forms import PrintOrderForm +from .models import PrintDocuments, PrintOrder + + +class PrintDocumentCreate(BaseMixin, View): + form_class = PrintOrderForm + template_name = 'printdocument_create.html' + + def get(self, request, *args, **kwargs): + form = self.form_class(request=request) + return render(request, self.template_name, {'form': form}) + + def post(self, request, *args, **kwargs): + form = self.form_class(request.POST, request.FILES, request=request) + if form.is_valid(): + print_order = form.save(commit=False) + print_order.save() + + for file in request.FILES.getlist('new_files'): + print_doc = PrintDocuments.objects.create(file=file, printorder=print_order) + print_doc.save() + + send_mail('Заявка на распечатку', + get_template('document_email.html').render( + { + 'username': 'Mukhtar', + 'files': 'This is files list' + } + ), + 'dagdahzub@mail.ru', + ['muhtarzubanchi05@gmail.com'], + fail_silently=True + ) + messages.info(request, 'Заявка на распечатку принята') + return redirect('common:create') + # import code; code.interact(local=dict(globals(), **locals())) + else: + context = self.get_context_data(**kwargs) + context.update({'form': form}) + return render(request, self.template_name, context) diff --git a/projects/filters.py b/projects/filters.py index 0323424..5ba3066 100755 --- a/projects/filters.py +++ b/projects/filters.py @@ -65,6 +65,7 @@ class StageFilterSet(FilterSet): status = AllLookupsFilter() pos = AllLookupsFilter() order = RelatedFilter('projects.filters.OrderFilterSet') + is_paid = AllLookupsFilter() class Meta: model = Stage diff --git a/projects/migrations/0005_auto_20160726_1957.py b/projects/migrations/0005_auto_20160726_1957.py new file mode 100644 index 0000000..fc78c3b --- /dev/null +++ b/projects/migrations/0005_auto_20160726_1957.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-07-26 16:57 +from __future__ import unicode_literals + +import datetime +from django.db import migrations, models +from django.utils.timezone import utc + + +class Migration(migrations.Migration): + + dependencies = [ + ('projects', '0004_auto_20160726_1931'), + ] + + operations = [ + migrations.AlterField( + model_name='stage', + name='created', + field=models.DateTimeField(default=datetime.datetime(2016, 7, 26, 16, 57, 39, 517305, tzinfo=utc)), + ), + ] diff --git a/projects/migrations/0006_auto_20160727_1835.py b/projects/migrations/0006_auto_20160727_1835.py new file mode 100644 index 0000000..b065cf2 --- /dev/null +++ b/projects/migrations/0006_auto_20160727_1835.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-07-27 15:35 +from __future__ import unicode_literals + +import datetime +from django.db import migrations, models +from django.utils.timezone import utc + + +class Migration(migrations.Migration): + + dependencies = [ + ('projects', '0005_auto_20160726_1957'), + ] + + operations = [ + migrations.AddField( + model_name='stage', + name='is_paid', + field=models.BooleanField(default=False), + ), + migrations.AlterField( + model_name='stage', + name='created', + field=models.DateTimeField(default=datetime.datetime(2016, 7, 27, 15, 35, 21, 468300, tzinfo=utc)), + ), + ] diff --git a/projects/migrations/0007_auto_20160727_1835.py b/projects/migrations/0007_auto_20160727_1835.py new file mode 100644 index 0000000..a1d565f --- /dev/null +++ b/projects/migrations/0007_auto_20160727_1835.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-07-27 15:35 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('projects', '0006_auto_20160727_1835'), + ] + + operations = [ + migrations.AlterField( + model_name='stage', + name='created', + field=models.DateTimeField(default=django.utils.timezone.now), + ), + ] diff --git a/projects/models.py b/projects/models.py index f97d1ff..22618da 100644 --- a/projects/models.py +++ b/projects/models.py @@ -165,8 +165,9 @@ class Stage(models.Model): term = models.IntegerField(default=0) term_type = models.CharField(max_length=10, choices=TERMS, default='hour') status = models.CharField(choices=STATUSES, max_length=30, default='not_agreed') - created = models.DateTimeField(default=timezone.now()) + created = models.DateTimeField(default=timezone.now) pos = models.IntegerField(default=0, null=True, blank=True) + is_paid = models.BooleanField(default=False) def __str__(self): return self.name diff --git a/projects/serializers.py b/projects/serializers.py index a9ac96c..e48b5cd 100755 --- a/projects/serializers.py +++ b/projects/serializers.py @@ -76,6 +76,7 @@ class StageSerializer(ModelSerializer): 'result', 'pos', 'status', + 'is_paid', ) diff --git a/templates/partials/base.html b/templates/partials/base.html index 1306c27..a5fb277 100644 --- a/templates/partials/base.html +++ b/templates/partials/base.html @@ -68,6 +68,8 @@ -{% block js_block %}{% endblock %} +{% block js_block %} + +{% endblock %} diff --git a/users/serializers.py b/users/serializers.py index cdd4327..8bca6a9 100755 --- a/users/serializers.py +++ b/users/serializers.py @@ -10,7 +10,7 @@ class UserSerializer(ModelSerializer): fields = ( 'avatar', - 'contractor_financial_info', + 'financial_info', 'contractor_specializations', 'contractor_status', 'created', diff --git a/users/templates/contractor_profile.html b/users/templates/contractor_profile.html index 43b1399..8ca7c82 100644 --- a/users/templates/contractor_profile.html +++ b/users/templates/contractor_profile.html @@ -287,7 +287,34 @@
    {{ contractor.contractor_resume.text }} + Редактировать
    + + + + +

    Дипломы / Сертификаты

    @@ -459,14 +486,16 @@ }); }); - - var url = '/work_sell/basic/'; var csrftoken = $.cookie('csrftoken'); $('#fileupload').fileupload({ url: url, crossDomain: false, beforeSend: function (xhr, settings) { + $('#progress .progress-bar').css( + 'width', + '0%' + ); if (!csrfSafeMethod(settings.type)) { xhr.setRequestHeader("X-CSRFToken", csrftoken); } @@ -475,7 +504,12 @@ done: function (e, data) { console.log(data); $.each(data.result.files, function (index, file) { - var img = $('').attr('src', file.url).appendTo("#files"); + var img = $('').attr('src', file.url).appendTo("#files"); + console.log(file); + var currentValue = $("#upload-files-pk").val(); + currentValue += file.id + ';'; + $("#upload-files-pk").val(currentValue); + }); }, progressall: function (e, data) { diff --git a/users/templates/portfolio_create_form.html b/users/templates/portfolio_create_form.html index 7c0a056..ab0a03f 100644 --- a/users/templates/portfolio_create_form.html +++ b/users/templates/portfolio_create_form.html @@ -77,13 +77,32 @@
    - +
    + + +{# #} +{# #} +{# Выберите файлы#} +{# #} +{# #} +{# #} + + + +
    +
    + +
    +
    +
    + +
    +
    - +
    diff --git a/users/templates/worksell_create_form.html b/users/templates/worksell_create_form.html index 690447e..fcb8cbb 100644 --- a/users/templates/worksell_create_form.html +++ b/users/templates/worksell_create_form.html @@ -72,12 +72,12 @@
    - +
    -
    - -
    +{#
    #} +{# #} +{#
    #} diff --git a/wallets/__init__.py b/wallets/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/wallets/admin.py b/wallets/admin.py new file mode 100644 index 0000000..aeb721a --- /dev/null +++ b/wallets/admin.py @@ -0,0 +1,5 @@ +from django.contrib import admin + +from .models import InvoiceHistory + +admin.site.register(InvoiceHistory) diff --git a/wallets/apps.py b/wallets/apps.py new file mode 100644 index 0000000..97938d4 --- /dev/null +++ b/wallets/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class WalletsConfig(AppConfig): + name = 'wallets' diff --git a/wallets/migrations/0001_initial.py b/wallets/migrations/0001_initial.py new file mode 100644 index 0000000..9429f87 --- /dev/null +++ b/wallets/migrations/0001_initial.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-07-27 15:35 +from __future__ import unicode_literals + +import datetime +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion +from django.utils.timezone import utc + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name='InvoiceHistory', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('comment', models.TextField(blank=True)), + ('created', models.DateTimeField(default=datetime.datetime(2016, 7, 27, 15, 35, 21, 502073, tzinfo=utc))), + ('sum', models.DecimalField(blank=True, decimal_places=0, default=0, max_digits=10, null=True)), + ('type', models.CharField(max_length=20)), + ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='invoice_history', to=settings.AUTH_USER_MODEL)), + ], + options={ + 'verbose_name': 'Счет(История)', + 'verbose_name_plural': 'Счет(История)', + }, + ), + ] diff --git a/wallets/migrations/0002_auto_20160727_1835.py b/wallets/migrations/0002_auto_20160727_1835.py new file mode 100644 index 0000000..07b1010 --- /dev/null +++ b/wallets/migrations/0002_auto_20160727_1835.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-07-27 15:35 +from __future__ import unicode_literals + +import datetime +from django.db import migrations, models +from django.utils.timezone import utc + + +class Migration(migrations.Migration): + + dependencies = [ + ('wallets', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='invoicehistory', + name='created', + field=models.DateTimeField(default=datetime.datetime(2016, 7, 27, 15, 35, 53, 331650, tzinfo=utc)), + ), + ] diff --git a/wallets/migrations/0003_auto_20160729_1209.py b/wallets/migrations/0003_auto_20160729_1209.py new file mode 100644 index 0000000..9833cda --- /dev/null +++ b/wallets/migrations/0003_auto_20160729_1209.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-07-29 09:09 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('wallets', '0002_auto_20160727_1835'), + ] + + operations = [ + migrations.AlterField( + model_name='invoicehistory', + name='created', + field=models.DateTimeField(default=django.utils.timezone.now), + ), + ] diff --git a/wallets/migrations/__init__.py b/wallets/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/wallets/models.py b/wallets/models.py new file mode 100644 index 0000000..b815ccd --- /dev/null +++ b/wallets/models.py @@ -0,0 +1,26 @@ +from django.db import models +from django.utils import timezone + +from users.models import User + +TYPES = ( + ('minus', 'Снятие'), + ('plus', 'Приход'), + +) + + +class InvoiceHistory(models.Model): + comment = models.TextField(blank=True) + created = models.DateTimeField(default=timezone.now) + sum = models.DecimalField(max_digits=10, decimal_places=0, default=0, null=True, blank=True) + type = models.CharField(max_length=20) + user = models.ForeignKey(User, related_name='invoice_history') + + def __str__(self): + return self.pk + + class Meta: + verbose_name = 'Счет(История)' + verbose_name_plural = 'Счет(История)' + diff --git a/wallets/tests.py b/wallets/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/wallets/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/wallets/views.py b/wallets/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/wallets/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/work_sell/serialize.py b/work_sell/serialize.py index 88fcb20..ec3e636 100644 --- a/work_sell/serialize.py +++ b/work_sell/serialize.py @@ -5,6 +5,7 @@ from django.core.urlresolvers import reverse def serialize(instance, file_attr='file'): obj = getattr(instance, file_attr) return { + 'id': instance.id, 'url': obj.url, 'name': obj.name, 'type': mimetypes.guess_type(obj.path)[0] or 'image/png',