diff --git a/project/commons/context_processors.py b/project/commons/context_processors.py new file mode 100644 index 0000000..bbf0ee5 --- /dev/null +++ b/project/commons/context_processors.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +from django.conf import settings + + +def get_dadata_api_key(request): + return { + "dadata_api_key": settings.DADATA_API_KEY + } diff --git a/project/customer/views/clients.py b/project/customer/views/clients.py index 1afe40f..4402c59 100644 --- a/project/customer/views/clients.py +++ b/project/customer/views/clients.py @@ -25,13 +25,11 @@ def clients_list(request, page_num=None): page, pagination_form = pagination(request, client_list, page_num) client_form = forms.ClientForm() - dadata_api_key = settings.DADATA_API_KEY dictionary = { 'page': page, 'pagination_form': pagination_form, - 'client_form': client_form, - 'dadata_api_key': dadata_api_key + 'client_form': client_form } return render(request, template_name, dictionary) diff --git a/project/customer/views/profile.py b/project/customer/views/profile.py index 8f4fc03..662d19f 100644 --- a/project/customer/views/profile.py +++ b/project/customer/views/profile.py @@ -87,7 +87,6 @@ def profile_edit(request): accounts = models.BankAccount.objects.get_all(profile) bank_account_form = forms.BankAccountForm(initial={'company': profile}) - dadata_api_key = settings.DADATA_API_KEY if request.method == 'POST': form = form_class(data=request.POST, files=request.FILES, instance=profile) @@ -113,8 +112,7 @@ def profile_edit(request): 'form': form, 'profile': profile, 'accounts': accounts, - 'bank_account_form': bank_account_form, - 'dadata_api_key': dadata_api_key + 'bank_account_form': bank_account_form } return render(request, template_name, dictionary) diff --git a/project/settings.py b/project/settings.py index 06dbc89..b4311e5 100644 --- a/project/settings.py +++ b/project/settings.py @@ -140,6 +140,7 @@ TEMPLATE_CONTEXT_PROCESSORS = ( 'sekizai.context_processors.sekizai', 'project.callback.context_processors.add_forms', 'project.customer.context_processors.license_check_soon_ends', + 'project.commons.context_processors.get_dadata_api_key', ) diff --git a/project/static/js/profile/search-main-external-api.js b/project/static/js/profile/search-main-external-api.js index cb4797f..e929809 100644 --- a/project/static/js/profile/search-main-external-api.js +++ b/project/static/js/profile/search-main-external-api.js @@ -65,8 +65,10 @@ $(document).ready(function() { if (data.name && data.name.full) profileOrgFullName.val(join([data.opf && data.opf.full || "", data.name.full], " ")); if (data.address) { - profileAddress.val(data.address.value); - profileLegalAddress.val(data.address.value); + var address = data.address.value; + profileAddress.val(address); + profileLegalAddress.val(address); + profilePostalAddress.val(address); } if (data.management) { @@ -131,7 +133,7 @@ $(document).ready(function() { profileInputs = [ profileOrgName, profileOrgFullName, profileInn, profileKpp, profileOqrn, profileBossName, profileBossSurname, profileBossMiddleName, - profileAddress, profileLegalAddress + profileAddress, profileLegalAddress, profilePostalAddress ]; } else { diff --git a/project/templates/docs/_base/base_add.html b/project/templates/docs/_base/base_add.html index 913008e..8a94f3b 100644 --- a/project/templates/docs/_base/base_add.html +++ b/project/templates/docs/_base/base_add.html @@ -23,4 +23,9 @@ {% include form_template_js %} + + + + + {% include 'hbs/bank-tpl.html' %} {% endblock %}