From 9994ded72d303c1a13e386f0168fbb75be92bc64 Mon Sep 17 00:00:00 2001 From: Bachurin Sergey Date: Sat, 16 Aug 2014 13:10:06 +0300 Subject: [PATCH] stamp and signs --- project/customer/views/bank_accounts.py | 1 - project/docs/forms/email.py | 2 + project/docs/views/aktrabot.py | 1 + project/docs/views/base_views.py | 10 +++- project/docs/views/invoice.py | 1 + project/docs/views/nakladn.py | 1 + project/templates/docs/aktrabot/as_pdf.html | 23 +++++++-- .../templates/docs/email/base_email_form.html | 30 ++++++++--- project/templates/docs/invoice/as_pdf.html | 12 ++--- project/templates/docs/nakladn/as_pdf.html | 51 +++++++++++++++---- 10 files changed, 102 insertions(+), 30 deletions(-) diff --git a/project/customer/views/bank_accounts.py b/project/customer/views/bank_accounts.py index b154da1..0ab6efa 100644 --- a/project/customer/views/bank_accounts.py +++ b/project/customer/views/bank_accounts.py @@ -40,7 +40,6 @@ def bank_accounts_add(request): form = form_class(data=request.POST) if form.is_valid(): new_account = form.save(commit=False) - print new_account new_account.company = request.user.profile new_account.save() return redirect(success_url) diff --git a/project/docs/forms/email.py b/project/docs/forms/email.py index 0c5fca2..22d0d5c 100644 --- a/project/docs/forms/email.py +++ b/project/docs/forms/email.py @@ -15,5 +15,7 @@ class EmailForm(forms.Form): widget=forms.Textarea(attrs={'cols': 80, 'rows': 3})) doc_format = forms.ChoiceField(label=u'Отправить как', choices=DOC_FORMATS, initial=DOC_FORMATS[0][0], widget=forms.RadioSelect()) + insert_sign = forms.BooleanField(label=u'Вставить печать и подпись', initial=False, + required=False) save_client_email = forms.BooleanField(label=u'Сохранить этот e-mail в анкете контрагента', initial=False, required=False) diff --git a/project/docs/views/aktrabot.py b/project/docs/views/aktrabot.py index 533e998..4b074e9 100644 --- a/project/docs/views/aktrabot.py +++ b/project/docs/views/aktrabot.py @@ -41,6 +41,7 @@ class AktRabotViews(BaseItemsViews, AddByInvoiceMethodMixin): PDF_TEMPLATE = 'docs/aktrabot/as_pdf.html' XLS_TEMPLATE = 'aktrabot.xls' FILENAME = u'Акт выполненных работ № %s, %s' # без расширения + MAYBE_SIGNED = True # --- грамматика для вывода наименований в шаблонах PADEJI = { diff --git a/project/docs/views/base_views.py b/project/docs/views/base_views.py index 5885bef..02f38b2 100644 --- a/project/docs/views/base_views.py +++ b/project/docs/views/base_views.py @@ -95,6 +95,7 @@ class BaseViews(object): PDF_TEMPLATE = '' XLS_TEMPLATE = '' FILENAME = u'Документ № %s, %s' # без расширения + MAYBE_SIGNED = False # --- константы для вывода наименований в шаблонах PADEJI = { @@ -229,6 +230,7 @@ class BaseViews(object): 'obj_list_count_before_filtering': obj_list_count_before_filtering, 'email_form': email_form, 'template_create_docs': self.TEMPLATE_CREATE_DOCS, + 'maybe_sign': self.MAYBE_SIGNED, } self.update_list_dict(dictionary) return render(self.request, self.TEMPLATE_LIST, dictionary) @@ -363,6 +365,7 @@ class BaseViews(object): 'obj_items': None, 'profile': profile, 'main_account': main_account, + 'doc_sign': kwargs.get('doc_sign', True), } c1 = time() pdf = render_pdf_to_string(self.request, self.PDF_TEMPLATE, params) @@ -459,7 +462,7 @@ class BaseViews(object): else: return HttpResponseServerError('Server error. Try later.') - def send_email(self, subject, to, body, files): + def send_email(self, subject, to, body, files, sign_doc): """Отправка письма.""" dict_context = {'body': body, 'support_email': SUPPORT_EMAIL,} email_body = render_to_string(self.EMAIL_MSG_TEMPLATE, dict_context) @@ -480,6 +483,7 @@ class BaseViews(object): client.save() doc_format = form.cleaned_data['doc_format'] + kwargs['doc_sign'] = form.cleaned_data.get('insert_sign', False) if doc_format in ('pdf', 'xls',): files = [] filename = self.get_filename(*args, **kwargs) @@ -500,7 +504,8 @@ class BaseViews(object): subject = u'%s' % filename, # тема письма = имя файла без расширения to = form.cleaned_data['to'], body = form.cleaned_data['body'], - files = files + files = files, + sign_doc = form.cleaned_data.get('save_client_email', None) ) return False # что-то пошло не так @@ -794,6 +799,7 @@ class BaseItemsViews(BaseViews): 'obj_items': obj_items, 'profile': profile, 'main_account': main_account, + 'doc_sign': kwargs.get('doc_sign', True), } c1 = time() pdf = render_pdf_to_string(self.request, self.PDF_TEMPLATE, params) diff --git a/project/docs/views/invoice.py b/project/docs/views/invoice.py index 9a1bf96..18543fd 100644 --- a/project/docs/views/invoice.py +++ b/project/docs/views/invoice.py @@ -43,6 +43,7 @@ class InvoiceViews(BaseItemsViews): PDF_TEMPLATE = 'docs/invoice/as_pdf.html' XLS_TEMPLATE = 'invoice.xls' FILENAME = u'Счет № %s, %s' # без расширения + MAYBE_SIGNED = True # --- грамматика для вывода наименований в шаблонах PADEJI = { diff --git a/project/docs/views/nakladn.py b/project/docs/views/nakladn.py index c45c603..83f4404 100644 --- a/project/docs/views/nakladn.py +++ b/project/docs/views/nakladn.py @@ -43,6 +43,7 @@ class NakladnViews(BaseItemsViews, AddByInvoiceMethodMixin): PDF_TEMPLATE = 'docs/nakladn/as_pdf.html' XLS_TEMPLATE = 'nakladn.xls' FILENAME = u'Накладная № %s, %s' # без расширения + MAYBE_SIGNED = True # --- грамматика для вывода наименований в шаблонах PADEJI = { diff --git a/project/templates/docs/aktrabot/as_pdf.html b/project/templates/docs/aktrabot/as_pdf.html index da28691..e580d3d 100644 --- a/project/templates/docs/aktrabot/as_pdf.html +++ b/project/templates/docs/aktrabot/as_pdf.html @@ -21,6 +21,7 @@ .center { text-align: center; } .top { vertical-align: top; } + .bottom { vertical-align: bottom; } .bold { font-weight: bold; } .font_8 { font-size: 8pt; } @@ -145,10 +146,18 @@ {# пустая строка #} - {# место для подписи #} - {{ profile.get_boss_fio }} + + {# место для подписи #} + {% if doc_sign and profile.boss_sign %} + + {% else %} + {% endif %} + + {{ profile.get_boss_fio }} - {# место для подписи #} + + {# место для подписи #} + {{ obj.client.contact_name }} @@ -163,7 +172,13 @@ {# пустая строка #} - М. П. + + {% if doc_sign and profile.stamp %} {# TODO передавать флаг из вьюхи #} + {# печать #} + {% else %} + М. П. + {% endif %} + М. П. diff --git a/project/templates/docs/email/base_email_form.html b/project/templates/docs/email/base_email_form.html index ac2d577..ca9aef4 100644 --- a/project/templates/docs/email/base_email_form.html +++ b/project/templates/docs/email/base_email_form.html @@ -45,15 +45,18 @@
-
- {% if not is_ajax %} - - - {% else %} - - - {% endif %} + {% if maybe_sign %} +
+
+ + {% if not is_ajax %}{{ form.insert_sign.errors }}{% endif %} +
+
+ {% endif %}
@@ -66,5 +69,16 @@
+ +
+ {% if not is_ajax %} + + + {% else %} + + + {% endif %} +
+
diff --git a/project/templates/docs/invoice/as_pdf.html b/project/templates/docs/invoice/as_pdf.html index 231caf7..18f78d3 100644 --- a/project/templates/docs/invoice/as_pdf.html +++ b/project/templates/docs/invoice/as_pdf.html @@ -149,7 +149,7 @@ {{ obj.sum_full_total_price|to_float|rubles|capfirst }}. {{ obj.doc_text|safe }} - {% if obj.add_sign_and_stamp and profile.boss_sign %} {# TODO передавать флаг из вьюхи #} + {% if doc_sign and profile.boss_sign %} {# TODO передавать флаг из вьюхи #} {# не делать отступ, если нужно вставить подпись руководителя #} {% else %}
@@ -166,7 +166,7 @@ {{ profile.get_boss_title }} @@ -182,7 +182,7 @@ diff --git a/project/templates/docs/nakladn/as_pdf.html b/project/templates/docs/nakladn/as_pdf.html index afe0e63..b077f50 100644 --- a/project/templates/docs/nakladn/as_pdf.html +++ b/project/templates/docs/nakladn/as_pdf.html @@ -497,12 +497,16 @@ - - + + - + - + {# правая половина #} @@ -521,15 +525,19 @@ - + - + - + {# правая половина #} - + @@ -595,7 +603,13 @@
- {% if profile.boss_sign %} {# TODO передавать флаг из вьюхи #} + {% if doc_sign and profile.boss_sign %} {# TODO передавать флаг из вьюхи #} {# подпись руководителя #} {% endif %}
Главный бухгалтер - {% if profile.glavbuh_sign %} {# TODO передавать флаг из вьюхи #} + {% if doc_sign and profile.glavbuh_sign %} {# TODO передавать флаг из вьюхи #} {# подпись главбуха #} {% else %}
  @@ -197,10 +197,10 @@
Главный бухгалтер - {% if profile.glavbuh_sign %} + {% if doc_sign and profile.glavbuh_sign %} {# подпись главбуха #} {% else %} - {% if profile.boss_sign %} + {% if doc_sign and profile.boss_sign %} {# или подпись руководителя #} {% else %}
  @@ -219,7 +219,7 @@
- {% if obj.add_sign_and_stamp and profile.stamp %} {# TODO передавать флаг из вьюхи #} + {% if doc_sign and profile.stamp %} {# TODO передавать флаг из вьюхи #} {# печать #} {% endif %}
Отпуск груза разрешилОтпуск груза разрешил{{ profile.boss_title|default:'' }} + {% if doc_sign and profile.boss_sign %} + {# или подпись руководителя #} + {% endif %} + {{ profile.get_boss_fio }}{{ profile.get_boss_fio }}  
Главный (старший) бухгалтерГлавный (старший) бухгалтер + {% if doc_sign and profile.glavbuh_sign %} + {# подпись главбуха #} + {% endif %} + {{ profile.get_glavbuh_fio }}{{ profile.get_glavbuh_fio }} Груз принялГруз принял
- + @@ -618,6 +632,25 @@ + + + {# правая половина #} + + + + + + + + + + + +
М.П. + {% if not doc_sign or not profile.stamp %} {# TODO передавать флаг из вьюхи #} + М. П. + {% else %} +   + {% endif %} + « года
+ {% if doc_sign and profile.stamp %} {# TODO передавать флаг из вьюхи #} + {# печать #} + {% endif %} +