Added validate account in profile

feature/docker
Dmitriy Shesterkin 9 years ago
parent 54bf195a07
commit bd7f1a39cd
  1. 18
      src/customer/models.py
  2. 4
      src/dokumentor/templates/docs/_base/base_list.html
  3. 5
      src/dokumentor/templates/docs/_base/preview.html

@ -14,9 +14,10 @@ from customer import consts, managers, utils
from myauth.models import DokUser from myauth.models import DokUser
from commons.utils import only_numerics from commons.utils import only_numerics
from django.utils.deconstruct import deconstructible from django.utils.deconstruct import deconstructible
from django.core.exceptions import ValidationError
PROFILE_IMAGES_UPLOAD_DIR = 'customer/profile/' # куда сохранять загруженные изображения # куда сохранять загруженные изображения
PROFILE_IMAGES_UPLOAD_DIR = 'customer/profile/'
BOSS_SIGN_IMG_SIZE = (159, 65) BOSS_SIGN_IMG_SIZE = (159, 65)
GLAVBUH_SIGN_IMG_SIZE = (159, 65) GLAVBUH_SIGN_IMG_SIZE = (159, 65)
STAMP_IMG_SIZE = (180, 180) STAMP_IMG_SIZE = (180, 180)
@ -177,7 +178,7 @@ class UserProfile(models.Model):
def get_main_bank_account(self): def get_main_bank_account(self):
try: try:
bank_accounts = BankAccount.objects.filter(company=self, is_main=True)[0] bank_accounts = BankAccount.objects.filter(company=self, is_main=True).first()
return bank_accounts return bank_accounts
except BankAccount.DoesNotExist: except BankAccount.DoesNotExist:
return None return None
@ -262,6 +263,17 @@ class UserProfile(models.Model):
fax_code = u'(%s)' % fax_code if fax_code else fax_code fax_code = u'(%s)' % fax_code if fax_code else fax_code
return (u'%s %s' % (fax_code, self.fax,)).strip() return (u'%s %s' % (fax_code, self.fax,)).strip()
# TODO : test
def validate_has_profile_account(self):
"""
Check there account from this profile
:return: True or False
"""
if self.bank_accounts.all():
return True
else:
return False
class BankAccount(models.Model): class BankAccount(models.Model):
"""Расчетные счета.""" """Расчетные счета."""

@ -8,6 +8,9 @@
{% if user.profile.check_main_reqs_not_filled %} {% if user.profile.check_main_reqs_not_filled %}
<p>Документор не может создать ничего, пока вы не добавите в него свои реквизиты. Заполните хотя бы те поля, которые отмечены * на странице <a href="{% url "customer_profile_edit" %}">Мои реквизиты</a>.</p> <p>Документор не может создать ничего, пока вы не добавите в него свои реквизиты. Заполните хотя бы те поля, которые отмечены * на странице <a href="{% url "customer_profile_edit" %}">Мои реквизиты</a>.</p>
{% else %} {% else %}
{% if not user.profile.validate_has_profile_account %}
<p>Документор не может создать ничего, пока вы не добавите в него свои реквизиты.Пожалуйста, укажите свои банковские реквизиты на странице <a href="{% url "customer_profile_edit" %}">Мои реквизиты</a>.</p>
{% else %}
{% url url_prefix|add:'add' as url_add %} {% url url_prefix|add:'add' as url_add %}
{% with img_desc='<img src="'|add:STATIC_URL|add:'img/desc.png">' img_asc='<img src="'|add:STATIC_URL|add:'img/asc.png">' img_none='<img src="'|add:STATIC_URL|add:'img/nosort.png">' %} {% with img_desc='<img src="'|add:STATIC_URL|add:'img/desc.png">' img_asc='<img src="'|add:STATIC_URL|add:'img/asc.png">' img_none='<img src="'|add:STATIC_URL|add:'img/nosort.png">' %}
@ -128,6 +131,7 @@
{% endif %} {% endif %}
{% endwith %} {% endwith %}
{% endif %} {% endif %}
{% endif %}
</div> </div>
{% endblock %} {% endblock %}

@ -1,4 +1,5 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load static %}
<div class="clear"></div> <div class="clear"></div>
{% block title %}Просмотр {{ padeji.rodit }} №{{ obj.doc_num }} от {{ obj.doc_date }}{% endblock %} {% block title %}Просмотр {{ padeji.rodit }} №{{ obj.doc_num }} от {{ obj.doc_date }}{% endblock %}
@ -57,6 +58,6 @@
var CLIENT = new Object; var CLIENT = new Object;
CLIENT.get_url_pattern = "{% url 'customer_clients_get_ajax' 0 %}"; CLIENT.get_url_pattern = "{% url 'customer_clients_get_ajax' 0 %}";
</script> </script>
<script src="{{ STATIC_URL }}js/docs/del_doc.js"></script> <script src="{% static 'js/docs/del_doc.js' %}"></script>
<script src="{{ STATIC_URL }}js/docs/list.email.js"></script> <script src="{% static 'js/docs/list.email.js' %}"></script>
{% endblock %} {% endblock %}

Loading…
Cancel
Save