added fields from dadata on the settlement account of the user

remotes/origin/mitri4
Dmitriy Shesterkin 9 years ago
parent c575d707f6
commit 6886fd8c58
  1. 3
      .gitignore
  2. 2
      project/customer/views/profile.py
  3. 4
      project/settings.py
  4. 189
      project/static/css/suggestions.css
  5. 2
      project/static/js/lib/jquery.suggestions.min.js
  6. 1
      project/templates/base.html
  7. 43
      project/templates/customer/profile/edit.html

3
.gitignore vendored

@ -13,3 +13,6 @@ distribute-*.tar.gz
_public_html/ _public_html/
celerybeat-schedule celerybeat-schedule
yandex_money.log yandex_money.log
/tmp_emails/
/tmp/
/celerybeat-schedule.db

@ -87,6 +87,7 @@ def profile_edit(request):
accounts = models.BankAccount.objects.get_all(profile) accounts = models.BankAccount.objects.get_all(profile)
bank_account_form = forms.BankAccountForm(initial={'company': profile}) bank_account_form = forms.BankAccountForm(initial={'company': profile})
dadata_api_key = settings.DADATA_API_KEY
if request.method == 'POST': if request.method == 'POST':
form = form_class(data=request.POST, files=request.FILES, instance=profile) form = form_class(data=request.POST, files=request.FILES, instance=profile)
@ -113,6 +114,7 @@ def profile_edit(request):
'profile': profile, 'profile': profile,
'accounts': accounts, 'accounts': accounts,
'bank_account_form': bank_account_form, 'bank_account_form': bank_account_form,
'dadata_api_key': dadata_api_key
} }
return render(request, template_name, dictionary) return render(request, template_name, dictionary)

@ -369,3 +369,7 @@ try:
from project.local_settings import * from project.local_settings import *
except ImportError: except ImportError:
pass pass
DADATA_API_KEY = 'e4232c46f82c0b2e8c5f9bd583d6224ce9c934e0'
DADATA_SECRET_KEY = '9c5c3fdfba74af122730db650346b3e91586abc7'

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -9,6 +9,7 @@
<title>{% block title %}{% endblock %} | Документор</title> <title>{% block title %}{% endblock %} | Документор</title>
<link rel="shortcut icon" href="{{ STATIC_URL }}favicon.ico" /> <link rel="shortcut icon" href="{{ STATIC_URL }}favicon.ico" />
<link rel="stylesheet" href="{{ STATIC_URL }}css/ui-lightness/jquery-ui-1.10.3.custom.css" /> <link rel="stylesheet" href="{{ STATIC_URL }}css/ui-lightness/jquery-ui-1.10.3.custom.css" />
<link rel="stylesheet" href="{{ STATIC_URL }}css/suggestions.css" />
<link rel="stylesheet" href="{{ STATIC_URL }}css/style.css" /> <link rel="stylesheet" href="{{ STATIC_URL }}css/style.css" />
{% render_block "css" %} {% render_block "css" %}

@ -526,4 +526,47 @@
</script> </script>
<script src="{{ STATIC_URL }}js/customer/profile.edit.js"></script> <script src="{{ STATIC_URL }}js/customer/profile.edit.js"></script>
<script src="{{ STATIC_URL }}js/lib/jquery.suggestions.min.js"></script>
<script>
"use strict";
var index,
bankEditForm = $("#bank-account-edit-form"),
bankBicInput = $("#id_bik", bankEditForm),
bankShortNameInput = $("#id_short_name", bankEditForm),
bankFullNameInput = $("#id_name", bankEditForm),
BankCorrespondentAccountInput = $("#id_korr_account", bankEditForm),
formInputs = [bankBicInput, bankShortNameInput, bankFullNameInput, BankCorrespondentAccountInput];
function showSuggestion(suggestion) {
// console.log(suggestion);
var data = suggestion.data;
if (!data) return;
bankShortNameInput.val(data.name && data.name.payment || "");
bankFullNameInput.val(data.name && data.name.full || "");
bankBicInput.val(data.bic);
BankCorrespondentAccountInput.val(data.correspondent_account);
}
for (index = formInputs.length - 1; index >= 0; --index) {
formInputs[index].suggestions({
token: "{{ dadata_api_key }}",
type: "BANK",
count: 5,
/* Вызывается, когда пользователь выбирает одну из подсказок */
onSelect: showSuggestion
});
}
</script>
{% endblock %} {% endblock %}

Loading…
Cancel
Save