|
|
|
|
@ -21,6 +21,7 @@ from project.commons.pdf_tools import render_pdf_to_string, pdf_to_response |
|
|
|
|
|
|
|
|
|
from .. import models, forms |
|
|
|
|
from ..decorators import license_required |
|
|
|
|
from ..utils import raise_if_no_profile |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PDF_PROFILE_NAME = u'Реквизиты.pdf' |
|
|
|
|
@ -33,13 +34,13 @@ SUPPORT_EMAIL = getattr(settings, 'SUPPORT_EMAIL', '') |
|
|
|
|
@csrf_protect |
|
|
|
|
def profile_view(request): |
|
|
|
|
"""Просмотр профиля пользователя, фильтрация реквизитов, скачать/отправить реквизиты по почте.""" |
|
|
|
|
raise_if_no_profile(request) |
|
|
|
|
|
|
|
|
|
template_name = 'customer/profile/view.html' |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
profile = request.user.profile |
|
|
|
|
except: |
|
|
|
|
raise Http404 |
|
|
|
|
accounts = models.BankAccount.objects.get_all(request.user.profile) |
|
|
|
|
|
|
|
|
|
accounts = models.BankAccount.objects.get_all(profile) |
|
|
|
|
|
|
|
|
|
filters_form_class = forms.get_profile_filters_form_class(profile.profile_type) |
|
|
|
|
filters = models.UserProfileFilters.objects.get_or_create_filters(user=request.user) |
|
|
|
|
@ -72,20 +73,20 @@ def profile_view(request): |
|
|
|
|
@csrf_protect |
|
|
|
|
def profile_edit(request): |
|
|
|
|
"""Редактировать профиль пользователя.""" |
|
|
|
|
raise_if_no_profile(request) |
|
|
|
|
|
|
|
|
|
template_name = 'customer/profile/edit.html' |
|
|
|
|
success_url = 'customer_profile_view' |
|
|
|
|
|
|
|
|
|
if request.method == 'POST' and '_cancel' in request.POST: |
|
|
|
|
return redirect(success_url) |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
profile = request.user.profile |
|
|
|
|
except: |
|
|
|
|
raise Http404 |
|
|
|
|
|
|
|
|
|
form_class = forms.get_profile_form_class(profile.profile_type) |
|
|
|
|
|
|
|
|
|
accounts = models.BankAccount.objects.get_all(request.user.profile) |
|
|
|
|
bank_account_form = forms.BankAccountForm(initial={'company': request.user.profile}) |
|
|
|
|
accounts = models.BankAccount.objects.get_all(profile) |
|
|
|
|
bank_account_form = forms.BankAccountForm(initial={'company': profile}) |
|
|
|
|
|
|
|
|
|
if request.method == 'POST': |
|
|
|
|
form = form_class(data=request.POST, files=request.FILES, instance=profile) |
|
|
|
|
@ -193,6 +194,8 @@ def _send_profile_email(subject, to, body, pdf_content): |
|
|
|
|
@csrf_protect |
|
|
|
|
def profile_email(request): |
|
|
|
|
"""Форма отправки профиля пользователя на email аттачем в PDF.""" |
|
|
|
|
raise_if_no_profile(request) |
|
|
|
|
|
|
|
|
|
template_name = 'customer/profile/email.html' |
|
|
|
|
success_url = 'customer_profile_view' |
|
|
|
|
|
|
|
|
|
@ -201,10 +204,8 @@ def profile_email(request): |
|
|
|
|
if request.method == 'POST' and '_cancel' in request.POST: |
|
|
|
|
return redirect('customer_profile_view') |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
profile = request.user.profile |
|
|
|
|
except: |
|
|
|
|
raise Http404 |
|
|
|
|
|
|
|
|
|
filters = models.UserProfileFilters.objects.get_or_create_filters(user=request.user) |
|
|
|
|
|
|
|
|
|
if request.method == 'POST': |
|
|
|
|
|