mirror of
https://github.com/OpenBankProject/API-Manager.git
synced 2026-02-06 18:56:48 +00:00
commit
82dc76559f
0
apimanager/accountlist/__init__.py
Normal file
0
apimanager/accountlist/__init__.py
Normal file
3
apimanager/accountlist/admin.py
Normal file
3
apimanager/accountlist/admin.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
5
apimanager/accountlist/apps.py
Normal file
5
apimanager/accountlist/apps.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class AccountConfig(AppConfig):
|
||||
name = 'account-list'
|
||||
0
apimanager/accountlist/forms.py
Normal file
0
apimanager/accountlist/forms.py
Normal file
4
apimanager/accountlist/models.py
Normal file
4
apimanager/accountlist/models.py
Normal file
@ -0,0 +1,4 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
# -*- coding: utf-8 -*-
|
||||
@ -0,0 +1,18 @@
|
||||
#accounts_list 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;
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
{% extends 'base.html' %} {% load static %} {% load i18n %}
|
||||
{% block page_title %} {{ block.super }} / {% trans "Account List" %}{% endblock page_title %} {% block content %}
|
||||
<div id="accounts_list">
|
||||
<h1>{% trans "Account List" %}</h1>
|
||||
<form class="form-inline" method="get">
|
||||
<input type="submit" class="btn btn-default" value ='{% trans "Export CSV" %}' onclick="javascript: form.action='{% url 'export-csv-account' %}';">
|
||||
</form>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover tablesorter" id="accounts-list" aria-describedby="accounts list">
|
||||
<thead>
|
||||
<th scope="col">{% trans "Account Id" %}</th>
|
||||
<th scope="col">{% trans "Bank Id" %}</th>
|
||||
<th scope="col">{% trans "Label" %}</th>
|
||||
<th scope="col">{% trans "More info" %}</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for account in accounts_list %}
|
||||
{% url 'account_update' account.id account.bank_id as url_account_update %}
|
||||
<tr data-account-id="{{ account.id }}">
|
||||
<td>{{ account.id }}</td>
|
||||
<td>{{ account.bank_id }}</td>
|
||||
<td>{{ account.label }}</td>
|
||||
<td>
|
||||
<div class="popuptext">
|
||||
<ul>
|
||||
<li>{% trans "Other Info" %}:
|
||||
<ul>
|
||||
<li>{{account.account_type}}</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</td>
|
||||
<td><a href="{{ url_atm_update }}" class="btn btn-primary">{% trans "View" %}</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %} {% block extrajs %} {% endblock extrajs %} {% block extracss %}
|
||||
<link href="{% static 'accountlist/css/accountlist.css' %}" rel="stylesheet"> {% endblock extracss %}
|
||||
3
apimanager/accountlist/tests.py
Normal file
3
apimanager/accountlist/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
16
apimanager/accountlist/urls.py
Normal file
16
apimanager/accountlist/urls.py
Normal file
@ -0,0 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
URLs for Account list app
|
||||
"""
|
||||
|
||||
from django.conf.urls import url
|
||||
from .views import AccountListView, ExportCsvView
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$',
|
||||
AccountListView.as_view(),
|
||||
name='account-list'),
|
||||
url(r'^export_csv$',
|
||||
ExportCsvView.as_view(),
|
||||
name='export-csv-account')
|
||||
]
|
||||
75
apimanager/accountlist/views.py
Normal file
75
apimanager/accountlist/views.py
Normal file
@ -0,0 +1,75 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Views of Account List app
|
||||
"""
|
||||
import datetime
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
import json
|
||||
from django.urls import reverse_lazy
|
||||
from django.http import HttpResponse
|
||||
from django.views.generic import FormView,TemplateView, View
|
||||
from accounts.views import IndexAccountsView
|
||||
from obp.api import API, APIError
|
||||
from base.views import get_banks
|
||||
import csv
|
||||
|
||||
class AccountListView(IndexAccountsView, LoginRequiredMixin, FormView ):
|
||||
template_name = "accountlist/accountlist.html"
|
||||
success_url = '/accounts/list'
|
||||
|
||||
def get_accountlist(self, context):
|
||||
api = API(self.request.session.get('obp'))
|
||||
try:
|
||||
#self.bankids = self.get_banks()
|
||||
accounts_list = []
|
||||
#for bank_id in self.bankids:
|
||||
urlpath = '/my/accounts'
|
||||
result = api.get(urlpath)
|
||||
if 'accounts' in result:
|
||||
accounts_list.extend(result['accounts'])
|
||||
except APIError as err:
|
||||
messages.error(self.request, err)
|
||||
return []
|
||||
except Exception as inst:
|
||||
messages.error(self.request, "Unknown Error {}".format(type(inst).__name__))
|
||||
return []
|
||||
return accounts_list
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(IndexAccountsView, self).get_context_data(**kwargs)
|
||||
accounts_list = self.get_accountlist(context)
|
||||
context.update({
|
||||
'accounts_list': accounts_list,
|
||||
#'bankids': bankids
|
||||
})
|
||||
return context
|
||||
class ExportCsvView(LoginRequiredMixin, View):
|
||||
"""View to export the user to csv"""
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
api = API(self.request.session.get('obp'))
|
||||
try:
|
||||
self.bankids = get_banks(self.request)
|
||||
accounts_list = []
|
||||
for bank_id in self.bankids:
|
||||
urlpath = 'banks/{}/accounts'.format(bank_id)
|
||||
result = api.get(urlpath)
|
||||
if 'accounts' in result:
|
||||
accounts_list.extend(result['accounts'])
|
||||
except APIError as err:
|
||||
messages.error(self.request, err)
|
||||
except Exception as inst:
|
||||
messages.error(self.request, "Unknown Error {}".format(type(inst).__name__))
|
||||
response = HttpResponse(content_type = 'text/csv')
|
||||
response['Content-Disposition'] = 'attachment;filename= Account'+ str(datetime.datetime.now())+'.csv'
|
||||
writer = csv.writer(response)
|
||||
writer.writerow(["id","label","bank_id","account_type","scheme","address","id", "short_name", "description", "is_public"])
|
||||
for user in accounts_list:
|
||||
writer.writerow([user['id'],user['label'], user['bank_id'], user["account_type"], user["scheme"], user["address"], user["views"]['id'],
|
||||
user["views"]['short_name'], user["views"]['description'], user["views"]['is_public']])
|
||||
return response
|
||||
|
||||
|
||||
@ -52,6 +52,7 @@ INSTALLED_APPS = [
|
||||
'obp',
|
||||
'consumers',
|
||||
'accounts',
|
||||
'accountlist',
|
||||
'systemviews',
|
||||
'users',
|
||||
'branches',
|
||||
|
||||
@ -36,6 +36,7 @@ urlpatterns += i18n_patterns(
|
||||
LogoutView.as_view(), name='oauth-logout'),
|
||||
url(r'^systemviews/', include('systemviews.urls')),
|
||||
url(r'^accounts/', include('accounts.urls')),
|
||||
url(r'^account/list', include('accountlist.urls')),
|
||||
url(r'^consumers/', include('consumers.urls')),
|
||||
url(r'^entitlementrequests/', include('entitlementrequests.urls')),
|
||||
url(r'^users/', include('users.urls')),
|
||||
|
||||
@ -59,13 +59,14 @@
|
||||
<li {% if metrics_summary_url in request.path %} class="active" {% endif %}><a href="{{ metrics_summary_url }}">{% trans "KPI Dashboard" %}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
{% 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 %}
|
||||
{% url "system_view" as system_view_url %} {% url "accounts-create" as accounts_create_url %} {% url "account-list" as accounts_list_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 %}
|
||||
<li class="dropdown{% if customers_create_url in request.path %} active{% endif %}">
|
||||
<a href="#" data-toggle="dropdown" class="dropdown-toggle">{% trans "Resources" %}</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li {% if system_view_url in request.path %} class="active" {% endif %}><a href="{{ system_view_url }}">{% trans "System View" %}</a></li>
|
||||
<hr class="dropdown-hr">
|
||||
<li {% if accounts_create_url in request.path %} class="active" {% endif %}><a href="{{ accounts_create_url }}">{% trans "Account Create" %}</a></li>
|
||||
<li {% if accounts_list_url in request.path %} class="active" {% endif %}><a href="{{ accounts_list_url }}">{% trans "Account List" %}</a></li>
|
||||
<li {% if customers_create_url in request.path %} class="active" {% endif %}><a href="{{ customers_create_url }}">{% trans "Customers" %}</a></li>
|
||||
<li {% if customer_list_url in request.path %} class="active" {% endif %}><a href="{{ customer_list_url }}">{% trans "Customer List" %}</a></li>
|
||||
<li {% if branches_list_url in request.path %} class="active" {% endif %}><a href="{{ branches_list_url }}">{% trans "Branches" %}</a></li>
|
||||
|
||||
@ -17,8 +17,6 @@ from obp.api import API, APIError
|
||||
from base.views import get_banks
|
||||
import csv
|
||||
|
||||
|
||||
|
||||
class CustomerListView(CreateView, LoginRequiredMixin, FormView ):
|
||||
template_name = "customerlist/customerlist.html"
|
||||
success_url = '/customers/list'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user