mirror of
https://github.com/OpenBankProject/API-Manager.git
synced 2026-02-06 19:26:53 +00:00
Merge branch 'add_product_list' into develop
This commit is contained in:
commit
d147637388
@ -1,346 +0,0 @@
|
||||
"""
|
||||
Forms of ATMs app
|
||||
"""
|
||||
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import random
|
||||
|
||||
|
||||
class CreateAtmForm(forms.Form):
|
||||
|
||||
atm_id = forms.CharField(
|
||||
label=_('ATM Id'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'atm-id-{}'.format(random.randint(1,1000)),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
initial='atm-id-{}'.format(random.randint(1,1000)),
|
||||
)
|
||||
|
||||
bank_id = forms.ChoiceField(
|
||||
label=_('Bank Id'),
|
||||
widget=forms.Select(
|
||||
attrs={
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
choices=[],
|
||||
)
|
||||
|
||||
name = forms.CharField(
|
||||
label=_('Name'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('The name of the ATM'),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=True
|
||||
)
|
||||
|
||||
address = forms.CharField(
|
||||
label=_('Address'),
|
||||
widget=forms.Textarea(
|
||||
attrs={
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False
|
||||
)
|
||||
|
||||
location_latitude = forms.FloatField(
|
||||
label=_('Latitude'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': " ",
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
|
||||
location_longitude = forms.FloatField(
|
||||
label=_('Longitude'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': " ",
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
|
||||
meta_license_id = forms.CharField(
|
||||
label=_('Meta License Id'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'PDDL',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
|
||||
meta_license_name = forms.CharField(
|
||||
label=_('Meta License Name'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'Open Data Commons Public Domain Dedication and License',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
|
||||
lobby = forms.CharField(
|
||||
label=_('Opening Hours'),
|
||||
widget=forms.Textarea(
|
||||
attrs={
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
monday = forms.CharField(
|
||||
label=_('Monday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
tuesday = forms.CharField(
|
||||
label=_('Tuesday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
wednesday = forms.CharField(
|
||||
label=_('Wednesday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
thursday = forms.CharField(
|
||||
label=_('Thursday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
friday = forms.CharField(
|
||||
label=_('Friday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
saturday = forms.CharField(
|
||||
label=_('Saturday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
sunday = forms.CharField(
|
||||
label=_('Sunday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
is_accessible = forms.ChoiceField(
|
||||
label=_('Is Accessible'),
|
||||
widget=forms.Select(
|
||||
attrs={
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
located_at = forms.CharField(
|
||||
label=_('ATM location'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'OBP',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
more_info = forms.CharField(
|
||||
label=_('More information'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('short walk to the lake from here'),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
has_deposit_capability = forms.ChoiceField(
|
||||
label=_('Deposit Capabilities'),
|
||||
widget=forms.Select(
|
||||
attrs={
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
supported_languages = forms.ChoiceField(
|
||||
label=_('Supported Languages'),
|
||||
widget=forms.Select(
|
||||
attrs={
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
services = forms.CharField(
|
||||
label=_('Services'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('Service store'),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
accessibility_features = forms.CharField(
|
||||
label=_('Accessible Features'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('wheelchair, atm usuable by the visually impaired'),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
supported_currencies = forms.ChoiceField(
|
||||
label=_('Supported Currencies'),
|
||||
widget=forms.Select(
|
||||
attrs={
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
notes = forms.ChoiceField(
|
||||
label=_('Write Notes'),
|
||||
widget=forms.Select(
|
||||
attrs={
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
location_categories = forms.ChoiceField(
|
||||
label=_('Write location Category'),
|
||||
widget=forms.Select(
|
||||
attrs={
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
minimum_withdrawal = forms.CharField(
|
||||
label=_('Minimum Withdrawal'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': '5',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
branch_identification = forms.CharField(
|
||||
label=_('Branch Identification'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('Enter your Branch Identification'),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
site_identification = forms.CharField(
|
||||
label=_('Site Identification'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('Enter your Site Identification'),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
site_name = forms.CharField(
|
||||
label=_('Site Name'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('Enter your Site Name '),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
cash_withdrawal_national_fee = forms.CharField(
|
||||
label=_('Cash Withdrawal National fee'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('Cash withdrawal national fee'),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
cash_withdrawal_international_fee = forms.CharField(
|
||||
label=_('Cash Withdrawal international fee'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('Cash withdrawal international fee'),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
balance_inquiry_fee = forms.CharField(
|
||||
label=_('Balance Inquiry Fee'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('Balance Inquiry Fee'),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs.setdefault('label_suffix', '')
|
||||
super(CreateAtmForm, self).__init__(*args, **kwargs)
|
||||
@ -1,4 +1,4 @@
|
||||
#atms_list div {
|
||||
#atms div {
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
|
||||
@ -20,7 +20,7 @@ class IndexAtmsView(LoginRequiredMixin, FormView):
|
||||
"""Index view for ATMs"""
|
||||
template_name = "atms/index.html"
|
||||
form_class = CreateAtmForm
|
||||
success_url = reverse_lazy('atms_list')
|
||||
success_url = reverse_lazy('atms_create')
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
self.api = API(request.session.get('obp'))
|
||||
|
||||
@ -30,7 +30,7 @@
|
||||
</button>
|
||||
</div>
|
||||
<div id="navbar" class="collapse navbar-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<ul class="nav navbar-nav" style="margin-left:8rem">
|
||||
<li> <a href="{% url 'home' %}" style="position:absolute; margin-left: -70px !important; top:-5px"><img src="{{ logo_url }}" alt="brand"></a></li>
|
||||
<li><a href="{{ API_PORTAL }}">{% trans "Home" %}</a></li>
|
||||
{% url "consumers-index" as consumers_index_url %}
|
||||
|
||||
0
apimanager/productlist/__init__.py
Normal file
0
apimanager/productlist/__init__.py
Normal file
3
apimanager/productlist/admin.py
Normal file
3
apimanager/productlist/admin.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
5
apimanager/productlist/apps.py
Normal file
5
apimanager/productlist/apps.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ProductsConfig(AppConfig):
|
||||
name = 'products_list'
|
||||
346
apimanager/productlist/forms.py
Normal file
346
apimanager/productlist/forms.py
Normal file
@ -0,0 +1,346 @@
|
||||
"""
|
||||
Forms of ATMs app
|
||||
"""
|
||||
|
||||
from django import forms
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
import random
|
||||
|
||||
|
||||
class CreateAtmForm(forms.Form):
|
||||
|
||||
atm_id = forms.CharField(
|
||||
label=_('ATM Id'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'atm-id-{}'.format(random.randint(1,1000)),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
initial='atm-id-{}'.format(random.randint(1,1000)),
|
||||
)
|
||||
|
||||
bank_id = forms.ChoiceField(
|
||||
label=_('Bank Id'),
|
||||
widget=forms.Select(
|
||||
attrs={
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
choices=[],
|
||||
)
|
||||
|
||||
name = forms.CharField(
|
||||
label=_('Name'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('The name of the ATM'),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=True
|
||||
)
|
||||
|
||||
address = forms.CharField(
|
||||
label=_('Address'),
|
||||
widget=forms.Textarea(
|
||||
attrs={
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False
|
||||
)
|
||||
|
||||
location_latitude = forms.FloatField(
|
||||
label=_('Latitude'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': " ",
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
|
||||
location_longitude = forms.FloatField(
|
||||
label=_('Longitude'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': " ",
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
|
||||
meta_license_id = forms.CharField(
|
||||
label=_('Meta License Id'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'PDDL',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
|
||||
meta_license_name = forms.CharField(
|
||||
label=_('Meta License Name'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'Open Data Commons Public Domain Dedication and License',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
|
||||
lobby = forms.CharField(
|
||||
label=_('Opening Hours'),
|
||||
widget=forms.Textarea(
|
||||
attrs={
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
monday = forms.CharField(
|
||||
label=_('Monday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
tuesday = forms.CharField(
|
||||
label=_('Tuesday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
wednesday = forms.CharField(
|
||||
label=_('Wednesday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
thursday = forms.CharField(
|
||||
label=_('Thursday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
friday = forms.CharField(
|
||||
label=_('Friday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
saturday = forms.CharField(
|
||||
label=_('Saturday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
sunday = forms.CharField(
|
||||
label=_('Sunday'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'None',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
is_accessible = forms.ChoiceField(
|
||||
label=_('Is Accessible'),
|
||||
widget=forms.Select(
|
||||
attrs={
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
located_at = forms.CharField(
|
||||
label=_('ATM location'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': 'OBP',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
more_info = forms.CharField(
|
||||
label=_('More information'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('short walk to the lake from here'),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
has_deposit_capability = forms.ChoiceField(
|
||||
label=_('Deposit Capabilities'),
|
||||
widget=forms.Select(
|
||||
attrs={
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
supported_languages = forms.ChoiceField(
|
||||
label=_('Supported Languages'),
|
||||
widget=forms.Select(
|
||||
attrs={
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
services = forms.CharField(
|
||||
label=_('Services'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('Service store'),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
accessibility_features = forms.CharField(
|
||||
label=_('Accessible Features'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('wheelchair, atm usuable by the visually impaired'),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
supported_currencies = forms.ChoiceField(
|
||||
label=_('Supported Currencies'),
|
||||
widget=forms.Select(
|
||||
attrs={
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
notes = forms.ChoiceField(
|
||||
label=_('Write Notes'),
|
||||
widget=forms.Select(
|
||||
attrs={
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
location_categories = forms.ChoiceField(
|
||||
label=_('Write location Category'),
|
||||
widget=forms.Select(
|
||||
attrs={
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
minimum_withdrawal = forms.CharField(
|
||||
label=_('Minimum Withdrawal'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': '5',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
branch_identification = forms.CharField(
|
||||
label=_('Branch Identification'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('Enter your Branch Identification'),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
site_identification = forms.CharField(
|
||||
label=_('Site Identification'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('Enter your Site Identification'),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
site_name = forms.CharField(
|
||||
label=_('Site Name'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('Enter your Site Name '),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
cash_withdrawal_national_fee = forms.CharField(
|
||||
label=_('Cash Withdrawal National fee'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('Cash withdrawal national fee'),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
cash_withdrawal_international_fee = forms.CharField(
|
||||
label=_('Cash Withdrawal international fee'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('Cash withdrawal international fee'),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
balance_inquiry_fee = forms.CharField(
|
||||
label=_('Balance Inquiry Fee'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': _('Balance Inquiry Fee'),
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
required=False,
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
kwargs.setdefault('label_suffix', '')
|
||||
super(CreateAtmForm, self).__init__(*args, **kwargs)
|
||||
4
apimanager/productlist/models.py
Normal file
4
apimanager/productlist/models.py
Normal file
@ -0,0 +1,4 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
# -*- coding: utf-8 -*-
|
||||
@ -0,0 +1,18 @@
|
||||
#product_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,5 @@
|
||||
$(document).ready(function($) {
|
||||
$('#info').click(function() {
|
||||
alert("Hello World")
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,45 @@
|
||||
{% extends 'base.html' %} {% load static %} {% load i18n %}
|
||||
{% block page_title %} {{ block.super }} / {% trans "Product List" %}{% endblock page_title %} {% block content %}
|
||||
<div id="products">
|
||||
<h1>{% trans "Product 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' %}';">
|
||||
</form>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover tablesorter" id="product-list" aria-describedby="atms list">
|
||||
<thead>
|
||||
<th scope="col">{% trans "ATM Id" %}</th>
|
||||
<th scope="col">{% trans "Bank Id" %}</th>
|
||||
<th scope="col">{% trans "ATM Name" %}</th>
|
||||
<th scope="col">{% trans "More info" %}</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for atm in atms_list %}
|
||||
|
||||
{% url 'atms_update' atm.id atm.bank_id as url_atm_update %}
|
||||
<tr data-atm-id="{{ atm.id }}">
|
||||
<td>{{ atm.id }}</td>
|
||||
<td>{{ atm.bank_id }}</td>
|
||||
<td>{{ atm.name }}</td>
|
||||
<td>
|
||||
<div class="popuptext">
|
||||
<ul>
|
||||
<li>{% trans "Address" %}:
|
||||
<ul>
|
||||
<li>line1: {{atm.address.line_1}}</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 'atms/css/atms.css' %}" rel="stylesheet"> {% endblock extracss %}
|
||||
3
apimanager/productlist/tests.py
Normal file
3
apimanager/productlist/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
||||
16
apimanager/productlist/urls.py
Normal file
16
apimanager/productlist/urls.py
Normal file
@ -0,0 +1,16 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
URLs for metrics app
|
||||
"""
|
||||
|
||||
from django.conf.urls import url
|
||||
from .views import AtmListView, ExportCsvView
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$',
|
||||
AtmListView.as_view(),
|
||||
name='atm-list'),
|
||||
url(r'^export_csv$',
|
||||
ExportCsvView.as_view(),
|
||||
name='export-csv')
|
||||
]
|
||||
103
apimanager/productlist/views.py
Normal file
103
apimanager/productlist/views.py
Normal file
@ -0,0 +1,103 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Views of atms 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 atms.views import IndexAtmsView
|
||||
from obp.api import API, APIError
|
||||
import csv
|
||||
|
||||
|
||||
|
||||
class AtmListView(IndexAtmsView, LoginRequiredMixin, FormView ):
|
||||
template_name = "atmlist/atmlist.html"
|
||||
success_url = '/atms/list'
|
||||
def get_banks(self):
|
||||
api = API(self.request.session.get('obp'))
|
||||
try:
|
||||
urlpath = '/banks'
|
||||
result = api.get(urlpath)
|
||||
if 'banks' in result:
|
||||
return [bank['id'] for bank in sorted(result['banks'], key=lambda d: d['id'])]
|
||||
else:
|
||||
return []
|
||||
except APIError as err:
|
||||
messages.error(self.request, err)
|
||||
return []
|
||||
|
||||
def get_atms(self, context):
|
||||
api = API(self.request.session.get('obp'))
|
||||
try:
|
||||
self.bankids = self.get_banks()
|
||||
atms_list = []
|
||||
for bank_id in self.bankids:
|
||||
urlpath = '/banks/{}/atms'.format(bank_id)
|
||||
result = api.get(urlpath)
|
||||
#print(result)
|
||||
if 'atms' in result:
|
||||
atms_list.extend(result['atms'])
|
||||
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 atms_list
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(IndexAtmsView, self).get_context_data(**kwargs)
|
||||
atms_list = self.get_atms(context)
|
||||
context.update({
|
||||
'atms_list': atms_list,
|
||||
'bankids': self.bankids
|
||||
})
|
||||
return context
|
||||
class ExportCsvView(LoginRequiredMixin, View):
|
||||
"""View to export the user to csv"""
|
||||
def get_banks(self):
|
||||
api = API(self.request.session.get('obp'))
|
||||
try:
|
||||
urlpath = '/banks'
|
||||
result = api.get(urlpath)
|
||||
if 'banks' in result:
|
||||
return [bank['id'] for bank in sorted(result['banks'], key=lambda d: d['id'])]
|
||||
else:
|
||||
return []
|
||||
except APIError as err:
|
||||
messages.error(self.request, err)
|
||||
return []
|
||||
def get(self, request, *args, **kwargs):
|
||||
api = API(self.request.session.get('obp'))
|
||||
try:
|
||||
self.bankids = self.get_banks()
|
||||
atms_list = []
|
||||
for bank_id in self.bankids:
|
||||
urlpath = '/banks/{}/atms'.format(bank_id)
|
||||
result = api.get(urlpath)
|
||||
#print(result)
|
||||
if 'atms' in result:
|
||||
atms_list.extend(result['atms'])
|
||||
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= Atms'+ str(datetime.datetime.now())+'.csv'
|
||||
writer = csv.writer(response)
|
||||
writer.writerow(["id","name","notes","line_1","line_2","line_3","city", "county", "state", "postcode","country_code", "longitude","latitude","more_info"])
|
||||
for user in atms_list:
|
||||
writer.writerow([user['id'],user['name'], user['notes'], user["address"]['line_1'], user["address"]['line_2'],
|
||||
user["address"]['line_3'], user["address"]['city'], user["address"]['county'], user["address"]['state'], user["address"]['postcode'], user["address"]['country_code'], user["location"]['longitude'], user["location"]['latitude'], user['more_info']])
|
||||
return response
|
||||
|
||||
#print(atms_list)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user