Заказы
{% for order in orders %}
-
+
-
- {{ order }}
-
+
{{ order }}
-
+
+
Этапы работы
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' %}
+
+
+
Услуга по распечатке документов
+
+ {% 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 %}