From 3268eb621c29483be596d33c529b6ac5f90e64de Mon Sep 17 00:00:00 2001 From: Reena-cell Date: Thu, 20 Oct 2022 23:59:02 +0200 Subject: [PATCH] /feature- add create account page --- apimanager/accounts/__init__.py | 0 apimanager/accounts/apps.py | 5 + apimanager/accounts/forms.py | 172 +++++++++++++ .../accounts/static/accounts/css/accounts.css | 18 ++ .../accounts/static/accounts/js/accounts.js | 0 .../accounts/templates/accounts/index.html | 166 ++++++++++++ .../accounts/templates/accounts/update.html | 223 ++++++++++++++++ apimanager/accounts/tests.py | 3 + apimanager/accounts/urls.py | 18 ++ apimanager/accounts/views.py | 242 ++++++++++++++++++ apimanager/apimanager/settings.py | 1 + apimanager/apimanager/urls.py | 1 + apimanager/base/templates/base.html | 3 +- 13 files changed, 851 insertions(+), 1 deletion(-) create mode 100644 apimanager/accounts/__init__.py create mode 100644 apimanager/accounts/apps.py create mode 100644 apimanager/accounts/forms.py create mode 100644 apimanager/accounts/static/accounts/css/accounts.css create mode 100644 apimanager/accounts/static/accounts/js/accounts.js create mode 100644 apimanager/accounts/templates/accounts/index.html create mode 100644 apimanager/accounts/templates/accounts/update.html create mode 100644 apimanager/accounts/tests.py create mode 100644 apimanager/accounts/urls.py create mode 100644 apimanager/accounts/views.py diff --git a/apimanager/accounts/__init__.py b/apimanager/accounts/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/apimanager/accounts/apps.py b/apimanager/accounts/apps.py new file mode 100644 index 0000000..9b3fc5a --- /dev/null +++ b/apimanager/accounts/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class AccountsConfig(AppConfig): + name = 'accounts' diff --git a/apimanager/accounts/forms.py b/apimanager/accounts/forms.py new file mode 100644 index 0000000..0885dd2 --- /dev/null +++ b/apimanager/accounts/forms.py @@ -0,0 +1,172 @@ +""" +Forms of Accounts app +""" + +from django import forms +from django.utils.translation import ugettext_lazy as _ + +import random + + +class CreateAccountForm(forms.Form): + + account_id = forms.CharField( + label=_('Account Id'), + widget=forms.TextInput( + attrs={ + 'placeholder': 'account-id-{}'.format(random.randint(1,1000)), + 'class': 'form-control', + } + ), + initial='account-id-{}'.format(random.randint(1,1000)), + ) + + user_id = forms.CharField( + label=_('User Id'), + widget=forms.TextInput( + attrs={ + 'class': 'form-control', + } + ), + required=True + ) + bank_id = forms.ChoiceField( + label=_('Bank Id'), + widget=forms.Select( + attrs={ + 'class': 'form-control', + } + ), + choices=[], + ) + + label = forms.CharField( + label=_('Label'), + widget=forms.TextInput( + attrs={ + 'placeholder': _('Select the label'), + 'class': 'form-control', + } + ), + required=False + ) + + product_code = forms.CharField( + label=_('Write Product Code'), + widget=forms.TextInput( + attrs={ + 'placeholder': "1234BW", + 'class': 'form-control', + } + ), + required=False + ) + + balance_currency = forms.CharField( + label=_('Currency'), + widget=forms.TextInput( + attrs={ + 'placeholder': "EUR", + 'class': 'form-control', + } + ), + required=True, + ) + + balance_amount = forms.FloatField( + label=_('Amount'), + widget=forms.TextInput( + attrs={ + 'placeholder': "0", + 'class': 'form-control', + } + ), + required=False, + ) + + branch_id = forms.CharField( + label=_('Branch Id'), + widget=forms.TextInput( + attrs={ + 'placeholder': 'DERBY6', + 'class': 'form-control', + } + ), + required=False, + ) + + account_routings_scheme = forms.CharField( + label=_('Account Number'), + widget=forms.TextInput( + attrs={ + 'placeholder': 'Account Number', + 'class': 'form-control', + } + ), + required=False, + ) + + account_routings_address = forms.CharField( + label=_('Address'), + widget=forms.TextInput( + attrs={ + 'placeholder': 'Address', + 'class': 'form-control', + } + ), + required=False, + ) + account_attributes_product_code = forms.CharField( + label=_('Account Attribute Product Code'), + widget=forms.TextInput( + attrs={ + 'placeholder': '1234BW', + 'class': 'form-control', + } + ), + required=False, + ) + account_attributes_id = forms.CharField( + label=_('Account Attribute Id'), + widget=forms.TextInput( + attrs={ + 'placeholder': '613c83ea-80f9-4560-8404-b9cd4ec42a7f', + 'class': 'form-control', + } + ), + required=False, + ) + account_attributes_name = forms.CharField( + label=_('Account Attribute Name'), + widget=forms.TextInput( + attrs={ + 'placeholder': 'OVERDRAFT_START_DATE', + 'class': 'form-control', + } + ), + required=False, + ) + account_attributes_value = forms.CharField( + label=_('Thursday'), + widget=forms.TextInput( + attrs={ + 'placeholder': '2012-04-23', + 'class': 'form-control', + } + ), + required=False, + ) + account_attributes_instance_code = forms.CharField( + label=_('Account Attribute Instance Code'), + widget=forms.TextInput( + attrs={ + 'placeholder': 'LKJL98769F', + 'class': 'form-control', + } + ), + required=False, + ) + + def __init__(self, *args, **kwargs): + kwargs.setdefault('label_suffix', '') + super(CreateAccountForm, self).__init__(*args, **kwargs) diff --git a/apimanager/accounts/static/accounts/css/accounts.css b/apimanager/accounts/static/accounts/css/accounts.css new file mode 100644 index 0000000..ab9482c --- /dev/null +++ b/apimanager/accounts/static/accounts/css/accounts.css @@ -0,0 +1,18 @@ +#accounts div { + margin: 5px 0; +} + +/* The actual popup (appears on top) */ +.popuptext { + width: 250px; + background-color: #555; + color: #fff; + text-align: left; + border-radius: 6px; + padding: 8px 0; + z-index: 1; + /*bottom: 125%;*/ + top:100%; + left: 50%; + margin-left: -80px; +} diff --git a/apimanager/accounts/static/accounts/js/accounts.js b/apimanager/accounts/static/accounts/js/accounts.js new file mode 100644 index 0000000..e69de29 diff --git a/apimanager/accounts/templates/accounts/index.html b/apimanager/accounts/templates/accounts/index.html new file mode 100644 index 0000000..aeb611a --- /dev/null +++ b/apimanager/accounts/templates/accounts/index.html @@ -0,0 +1,166 @@ +{% extends 'base.html' %} {% load static %} {% load i18n %} {% block page_title %}{{ block.super }} / Account{% endblock page_title %} {% block content %} +
+

{% trans "Account Create" %}

+ +
+ {% csrf_token %} {% if form.non_field_errors %} +
{{ form.non_field_errors }}
+ {% endif %} +
+
+ {% if form.account_id.errors %} +
{{ form.account_id.errors }}
+ {% endif %} +
+ {{ form.account_id.label_tag }} {{ form.account_id }} +
+
+
+ {% if form.user_id.errors %} +
{{ form.user_id.errors }}
+ {% endif %} +
+ {{ form.user_id.label_tag }} {{ form.user_id }} +
+
+
+ {% if form.label.errors %} +
{{ form.label.errors }}
+ {% endif %} +
+ {{ form.label.label_tag }} {{ form.label }} +
+
+
+
+
+ {% if form.product_code.errors %} +
+ {{ form.product_code.errors }} +
+ {% endif %} +
+ {{ form.product_code.label_tag }} {{ form.product_code }} +
+
+
+ {% if form.balance_currency.errors %} +
+ {{ form.balance_currency.errors }} +
+ {% endif %} +
+ {{ form.balance_currency.label_tag }} {{ form.balance_currency }} +
+
+
+ {% if form.balance_amount.errors %} +
+ {{ form.balance_amount.errors }} +
+ {% endif %} +
+ {{ form.balance_amount.label_tag }} {{ form.balance_amount }} +
+
+
+
+
+ {% if form.branch_id.errors %} +
{{ form.branch_id.errors }}
+ {% endif %} +
+ {{ form.branch_id.label_tag }} {{ form.branch_id }} +
+
+
+ {% if form.account_routings_scheme.errors %} +
+ {{ form.account_routings_scheme.errors }} +
+ {% endif %} +
+ {{ form.account_routings_scheme.label_tag }} {{ form.account_routings_scheme }} +
+
+
+ {% if form.account_routings_address.errors %} +
{{ form.account_routings_address.errors }}
+ {% endif %} +
+ {{ form.account_routings_address.label_tag }} {{ form.account_routings_address }} +
+
+
+
+
+ {% if form.account_attributes_product_code.errors %} +
+ {{ form.account_attributes_product_code.errors }} +
+ {% endif %} +
+ {{ form.account_attributes_product_code.label_tag }} {{ form.account_attributes_product_code }} +
+
+
+ {% if form.account_attributes_id.errors %} +
{{ form.account_attributes_id.errors }}
+ {% endif %} +
+ {{ form.account_attributes_id.label_tag }} {{ form.account_attributes_id }} +
+
+
+ {% if form.account_attributes_name.errors %} +
{{ form.account_attributes_name.errors }}
+ {% endif %} +
+ {{ form.account_attributes_name.label_tag }} {{ form.account_attributes_name }} +
+
+
+
+
+ {% if form.bank_id.errors %} +
{{ form.bank_id.errors }}
+ {% endif %} +
+ {{ form.bank_id.label_tag }} {{ form.bank_id }} +
+
+
+ {% if form.account_attributes_value.errors %} +
+ {{ form.account_attributes_value.errors }} +
+ {% endif %} +
+ {{ form.account_attributes_value.label_tag }} {{ form.account_attributes_value }} +
+
+
+ {% if form.account_attributes_instance_code.errors %} +
+ {{ form.account_attributes_instance_code.errors }} +
+ {% endif %} +
+ {{ form.account_attributes_instance_code.label_tag }} {{ form.account_attributes_instance_code }} +
+
+
+
+ +
+
+
+ +{% endblock %} {% block extrajs %} {% endblock extrajs %} {% block extracss %} + {% endblock extracss %} diff --git a/apimanager/accounts/templates/accounts/update.html b/apimanager/accounts/templates/accounts/update.html new file mode 100644 index 0000000..672e61e --- /dev/null +++ b/apimanager/accounts/templates/accounts/update.html @@ -0,0 +1,223 @@ +{% extends 'base.html' %} {% load static %} {% load i18n %} +{% block page_title %}{{ block.super }} / Atms{% endblock page_title %} {% block content %} +
+

{% trans "ATM Detail" %}

+

{{ bank_id }} : {{ atm_id }}

+
+ {% csrf_token %} {% if form.non_field_errors %} +
+ {{ form.non_field_errors }} +
+ {% endif %} + + +
+
+ {% if form.services.errors %} +
{{ form.services.errors }}
{% endif %} +
+ {{ form.services.label_tag }} {{ form.services }} +
+
+
+ {% if form.location_latitude.errors %} +
{{ form.location_latitude.errors }} +
{% endif %} +
+ {{ form.location_latitude.label_tag }} {{ form.location_latitude }} +
+
+
+ {% if form.location_longitude.errors %} +
{{ form.location_longitude.errors }} +
{% endif %} +
+ {{ form.location_longitude.label_tag }} {{ form.location_longitude }} +
+
+
+
+
+ {% if form.meta_license_name.errors %} +
{{ form.meta_license_name.errors }} +
{% endif %} +
+ {{ form.meta_license_name.label_tag }} {{ form.meta_license_name }} +
+
+
+ {% if form.located_at.errors %} +
{{ form.located_at.errors }} +
{% endif %} +
+ {{ form.located_at.label_tag }} {{ form.located_at }} +
+
+
+ {% if form.has_deposit_capability.errors %} +
{{ form.has_deposit_capability.errors }} +
{% endif %} +
+ {{ form.has_deposit_capability.label_tag }} {{ form.has_deposit_capability }} +
+
+
+
+
+ {% if form.is_accessible.errors %} +
{{ form.is_accessible.errors }}
{% endif %} +
+ {{ form.is_accessible.label_tag }} {{ form.is_accessible }} +
+
+
+ {% if form.accessibility_features.errors %} +
{{ form.accessibility_features.errors }}
+ {% endif %} +
+ {{ form.accessibility_features.label_tag }} {{ form.accessibility_features }} +
+
+
+ {% if form.more_info.errors %} +
{{ form.more_info.errors }}
{% endif %} +
+ {{ form.more_info.label_tag }} {{ form.more_info }} +
+
+
+
+
+ {% if form.notes.errors %} +
{{ form.notes.errors }}
{% endif %} +
+ {{ form.notes.label_tag }} {{ form.notes }} +
+
+
+ {% if form.supported_languages.errors %} +
{{ form.supported_languages.errors }}
{% endif %} +
+ {{ form.supported_languages.label_tag }} {{ form.supported_languages }} +
+
+
+ {% if form.supported_currencies.errors %} +
{{ form.supported_currencies.errors }}
{% endif %} +
+ {{ form.supported_currencies.label_tag }} {{ form.supported_currencies }} +
+
+
+
+
+ {% if form.location_categories.errors %} +
{{ form.location_categories.errors }}
{% endif %} +
+ {{ form.location_categories.label_tag }} {{ form.location_categories }} +
+
+
+ {% if form.minimum_withdrawal.errors %} +
{{ form.minimum_withdrawal.errors }}
{% endif %} +
+ {{ form.minimum_withdrawal.label_tag }} {{ form.minimum_withdrawal }} +
+
+
+ {% if form.site_name.errors %} +
{{ form.site_name.errors }}
{% endif %} +
+ {{ form.site_name.label_tag }} {{ form.site_name }} +
+
+
+
+
+ {% if form.branch_identification.errors %} +
{{ form.branch_identification.errors }}
{% endif %} +
+ {{ form.branch_identification.label_tag }} {{ form.branch_identification }} +
+
+
+ {% if form.site_identification.errors %} +
{{ form.site_identification.errors }}
{% endif %} +
+ {{ form.site_identification.label_tag }} {{ form.site_identification }} +
+
+
+ {% if form.cash_withdrawal_national_fee.errors %} +
{{ form.cash_withdrawal_national_fee.errors }}
{% endif %} +
+ {{ form.cash_withdrawal_national_fee.label_tag }} {{ form.cash_withdrawal_national_fee }} +
+
+
+
+
+ {% if form.balance_inquiry_fee.errors %} +
{{ form.balance_inquiry_fee.errors }}
{% endif %} +
+ {{ form.balance_inquiry_fee.label_tag }} {{ form.balance_inquiry_fee }} +
+
+
+ {% if form.cash_withdrawal_international_fee.errors %} +
{{ form.cash_withdrawal_international_fee.errors }}
{% endif %} +
+ {{ form.cash_withdrawal_international_fee.label_tag }} {{ form.cash_withdrawal_international_fee }} +
+
+
+
+ +
+ {% if form.address.errors %} +
{{ form.address.errors }}
{% endif %} +
+ {{ form.address.label_tag }} {{ form.address }} +
+
+ +
+ {% if form.lobby.errors %} +
{{ form.lobby.errors }}
{% endif %} +
+ {{ form.lobby.label_tag }} {{ form.lobby }} +
+
+
+ + +
+
+{% endblock content %} {% block extrajs %} {% comment %} + + +{% endcomment %} {% endblock extrajs %} {% block extracss %} + {% endblock extracss %} \ No newline at end of file diff --git a/apimanager/accounts/tests.py b/apimanager/accounts/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/apimanager/accounts/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/apimanager/accounts/urls.py b/apimanager/accounts/urls.py new file mode 100644 index 0000000..d8e49e1 --- /dev/null +++ b/apimanager/accounts/urls.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +""" +URLs for metrics app +""" + +from django.conf.urls import url +from .views import IndexAccountsView +#UpdateAccountsView + +urlpatterns = [ + url(r'^create', + IndexAccountsView.as_view(), + name='accounts-create'), + +] +"""url(r'^update/(?P[ 0-9\w|\W\@\.\+-]+)/bank/(?P[0-9\w\@\.\+-]+)/$', + UpdateAccountsView.as_view(), + name='accounts_update'),""" \ No newline at end of file diff --git a/apimanager/accounts/views.py b/apimanager/accounts/views.py new file mode 100644 index 0000000..378985d --- /dev/null +++ b/apimanager/accounts/views.py @@ -0,0 +1,242 @@ + +from django.shortcuts import render + +# Create your views here. +# -*- coding: utf-8 -*- +""" +Views of Accounts app +""" +from django.contrib import messages +from django.contrib.auth.mixins import LoginRequiredMixin +import json +from django.urls import reverse_lazy +from django.views.generic import FormView +from obp.api import API, APIError +from .forms import CreateAccountForm +from django.utils.translation import ugettext_lazy as _ + +class IndexAccountsView(LoginRequiredMixin, FormView): + + """Index view for Accounts""" + template_name = "accounts/index.html" + form_class = CreateAccountForm + success_url = reverse_lazy('accounts-create') + + def dispatch(self, request, *args, **kwargs): + self.api = API(request.session.get('obp')) + return super(IndexAccountsView, self).dispatch(request, *args, **kwargs) + + def get_form(self, *args, **kwargs): + form = super(IndexAccountsView, self).get_form(*args, **kwargs) + # Cannot add api in constructor: super complains about unknown kwarg + form.api = self.api + fields = form.fields + try: + fields['bank_id'].choices = self.api.get_bank_id_choices() + except APIError as err: + messages.error(self.request, err) + except Exception as err: + messages.error(self.request, err) + return form + + def form_valid(self, form): + try: + data = form.cleaned_data + urlpath = '/banks/{}/accounts/{}'.format(data['bank_id'], data['account_id']) + payload ={ + "user_id": data["user_id"], + "label": data["label"], + "product_code": data["product_code"], + "balance": { + "currency": data["balance_currency"] if data["balance_currency"] is not None else "EUR", + "amount": data["balance_amount"] if data["balance_amount"] is not None else 0 + }, + "account_routings": [{ + "scheme": data["account_routings_scheme"] if data["account_routings_scheme"] !="" else "scheme", + "address": data["account_routings_address"] if data["account_routings_address"]!="" else "address" + }], + } + result = self.api.put(urlpath, payload=payload) + except APIError as err: + messages.error(self.request, "Unknown Error") + return super(IndexAccountsView, self).form_invalid(form) + except Exception as err: + messages.error(self.request, err, "Unknown Error") + return super(IndexAccountsView, self).form_invalid(form) + if 'code' in result and result['code']>=400: + messages.error(self.request, result['message']) + return super(IndexAccountsView, self).form_valid(form) + msg = 'Account has been created successfully!' + messages.success(self.request, msg) + return super(IndexAccountsView, self).form_valid(form) + +"""class UpdateAccountsView(LoginRequiredMixin, FormView): + template_name = "accounts/update.html" + success_url = '/atms/list' + form_class = CreateAccountForm + + def dispatch(self, request, *args, **kwargs): + self.api = API(request.session.get('obp')) + return super(UpdateAccountsView, self).dispatch(request, *args, **kwargs) + + def get_form(self, *args, **kwargs): + form = super(UpdateAccountsView, self).get_form(*args, **kwargs) + # Cannot add api in constructor: super complains about unknown kwarg + form.api = self.api + fields = form.fields + urlpath = "/banks/{}/atms/{}".format(self.kwargs['bank_id'], self.kwargs['atm_id']) + try: + fields['bank_id'].choices = self.api.get_bank_id_choices() + except APIError as err: + messages.error(self.request, err) + except: + messages.error(self.request, "Unknown Error") + try: + result = self.api.get(urlpath) + fields['bank_id'].initial = self.kwargs['bank_id'] + fields['atm_id'].initial = self.kwargs['atm_id'] + fields['name'].initial = result['name'] + fields['address'].initial = json.dumps(result['address'], indent=4) + fields['location_latitude'].initial = result['location']['latitude'] + fields['location_longitude'].initial = result['location']['longitude'] + fields['meta_license_id'].initial = result['meta']['license']['id'] + fields['meta_license_name'].initial = result['meta']['license']['name'] + fields['minimum_withdrawal'].initial = result['minimum_withdrawal'] + fields['branch_identification'].initial = result['branch_identification'] + if result['is_accessible'].lower()=='true': + fields['is_accessible'].choices = [(True, True), (False, False)] + else: + fields['is_accessible'].choices = [(False, False), (True, True)] + if result['has_deposit_capability'].lower()=='true': + fields['has_deposit_capability'].choices = [(True, True), (False, False)] + else: + fields['has_deposit_capability'].choices = [(False, False), (True, True)] + fields['has_deposit_capability'].initial = result['accessibility_features'] + fields['site_identification'].initial = result['site_identification'] + fields['site_name'].initial = result['site_name'] + fields['cash_withdrawal_national_fee'].initial = result['cash_withdrawal_national_fee'] + fields['cash_withdrawal_international_fee'].initial = result['cash_withdrawal_international_fee'] + fields['balance_inquiry_fee'].initial = result['balance_inquiry_fee'] + fields['services'].initial = result['services'] + fields['located_at'].initial = result['located_at'] + fields['more_info'].initial = result['more_info'] + fields['located_at'].initial = result['located_at'] + if result['supported_languages'][0].lower()=='en': + fields['supported_languages'].choices = [("en", "en"), ("fr", "fr"), ("de", "de")] + elif result['supported_languages'][0].lower()=='fr': + fields['supported_languages'].choices = [("fr", "fr"), ("en", "en"), ("de", "de")] + else: + fields['supported_languages'].choices = [("de", "de"),("fr", "fr"), ("en", "en")] + fields['supported_languages'].initial = result['supported_languages'] + if result['supported_currencies'][0].lower()=='EUR': + fields['supported_currencies'].choices = [("EUR", "EUR"), ("MXN", "MXN"), ("USD", "USD")] + elif result['supported_currencies'][0].lower()=='MXN': + fields['supported_currencies'].choices = [("MXN", "MXN"), ("EUR", "EUR"), ("USD", "USD")] + else: + fields['supported_currencies'].choices = [("USD", "USD"),("MXN", "MXN"), ("EUR", "EUR")] + fields['supported_currencies'].initial = result['supported_currencies'] + if result['notes'][0].lower()=='string1': + fields['notes'].choices = [("String1", "String1"),("String2", "String2")] + else: + fields['notes'].choices = [("String2", "String2"),("String1", "String1")] + fields['notes'].initial = result['notes'] + if result['location_categories'][0].lower()=='atbi': + fields['location_categories'].choices = [("ATBI", "ATBI"),("ATBE", "ATBE")] + else: + fields['location_categories'].choices = [("ATBE", "ATBE"),("ATBI", "ATBI")] + fields['location_categories'].initial = result['location_categories'] + except APIError as err: + messages.error(self.request, err) + except Exception as err: + messages.error(self.request, "Unknown Error {}".format(err)) + return form + def form_valid(self, form): + data = form.cleaned_data + urlpath = '/banks/{}/atms/{}'.format(data["bank_id"],data["atm_id"]) + payload = { + "id": data["atm_id"], + "bank_id": data["bank_id"], + "name": data["name"], + "address": json.loads(data['address']), + "location": { + "latitude": float(data["location_latitude"]) if data["location_latitude"] is not None else "", + "longitude": float(data["location_longitude"]) if data["location_longitude"] is not None else "" + }, + "meta": { + "license": { + "id": "ODbL-1.0", + "name": data["meta_license_name"] if data["meta_license_name"]!="" else "license name" + } + }, + "monday": { + "opening_time": " ", + "closing_time": " " + }, + "tuesday": { + "opening_time": " ", + "closing_time": " " + }, + "wednesday": { + "opening_time": " ", + "closing_time": " " + }, + "thursday": { + "opening_time": " ", + "closing_time": " " + }, + "friday": { + "opening_time": " ", + "closing_time": " " + }, + "saturday": { + "opening_time": " ", + "closing_time": " " + }, + "sunday": { + "opening_time": " ", + "closing_time": " " + }, + "is_accessible": data["is_accessible"] if data["is_accessible"]!="" else "false", + "located_at": data["located_at"] if data["located_at"]!="no-example-provided" else " ", + "more_info": data["more_info"] if data["more_info"]!="" else "false", + "has_deposit_capability": data["has_deposit_capability"] if data["has_deposit_capability"]!="" else "false", + "supported_languages":[data["supported_languages"]], + "services":[data["services"]], + "accessibility_features":[data["accessibility_features"]], + "supported_currencies":[data["supported_currencies"]], + "notes":[data["notes"]], + "location_categories":[data["location_categories"]], + "minimum_withdrawal": data["minimum_withdrawal"] if data["minimum_withdrawal"]!="" else "false", + "branch_identification": data["branch_identification"] if data["branch_identification"]!="" else "false", + "site_identification": data["site_identification"] if data["site_identification"]!="" else "false", + "site_name": data["site_name"] if data["site_name"]!="" else "false", + "cash_withdrawal_national_fee": data["cash_withdrawal_national_fee"] if data["cash_withdrawal_national_fee"]!="" else "false", + "cash_withdrawal_international_fee": data["cash_withdrawal_international_fee"] if data["cash_withdrawal_international_fee"]!="" else "false", + "balance_inquiry_fee": data["balance_inquiry_fee"] if data["balance_inquiry_fee"]!="" else "false", + } + try: + result = self.api.put(urlpath, payload=payload) + if 'code' in result and result['code']>=400: + messages.error(self.request, result['message']) + return super(UpdateAccountsView, self).form_invalid(form) + except APIError as err: + messages.error(self.request, err) + return super(UpdateAccountsView, self).form_invalid(form) + except Exception as e: + messages.error(self.request, e) + return super(UpdateAccountsView, self).form_invalid(form) + msg = 'Atm {} for Bank {} has been updated successfully!'.format( # noqa + data["atm_id"], data["bank_id"]) + messages.success(self.request, msg) + return super(UpdateAccountsView, self).form_valid(form) + + def get_context_data(self, **kwargs): + context = super(UpdateAccountsView, self).get_context_data(**kwargs) + self.bank_id = self.kwargs['bank_id'] + self.atm_id = self.kwargs['atm_id'] + context.update({ + 'atm_id': self.atm_id, + 'bank_id': self.bank_id + }) + return context +""" diff --git a/apimanager/apimanager/settings.py b/apimanager/apimanager/settings.py index 251309d..d9f1922 100644 --- a/apimanager/apimanager/settings.py +++ b/apimanager/apimanager/settings.py @@ -51,6 +51,7 @@ INSTALLED_APPS = [ 'base', 'obp', 'consumers', + 'accounts', 'systemviews', 'users', 'branches', diff --git a/apimanager/apimanager/urls.py b/apimanager/apimanager/urls.py index 4ed38b9..8e84678 100644 --- a/apimanager/apimanager/urls.py +++ b/apimanager/apimanager/urls.py @@ -35,6 +35,7 @@ urlpatterns += i18n_patterns( url(r'^logout$', LogoutView.as_view(), name='oauth-logout'), url(r'^systemviews/', include('systemviews.urls')), + url(r'^accounts/', include('accounts.urls')), url(r'^consumers/', include('consumers.urls')), url(r'^entitlementrequests/', include('entitlementrequests.urls')), url(r'^users/', include('users.urls')), diff --git a/apimanager/base/templates/base.html b/apimanager/base/templates/base.html index 40fe4e9..f599dcf 100644 --- a/apimanager/base/templates/base.html +++ b/apimanager/base/templates/base.html @@ -59,12 +59,13 @@
  • {% trans "KPI Dashboard" %}
  • - {% url "system_view" as system_view_url %} {% url "branches_list" as branches_list_url %} {% url "customers-create" as customers_create_url %} {% url "customer-list" as customer_list_url %} {% url "atms_create" as atms_create_url %} {% url "atm-list" as atm_list_url %} {% url "product-list" as product_list_url %} {% url "products-create" as product_create_url %} + {% url "system_view" as system_view_url %} {% url "accounts-create" as accounts_create_url %} {% url "branches_list" as branches_list_url %} {% url "customers-create" as customers_create_url %} {% url "customer-list" as customer_list_url %} {% url "atms_create" as atms_create_url %} {% url "atm-list" as atm_list_url %} {% url "product-list" as product_list_url %} {% url "products-create" as product_create_url %}