Merge pull request #235 from Reena-cell/develop

format navbar and add product list page
This commit is contained in:
Simon Redfern 2022-10-04 16:43:58 +02:00 committed by GitHub
commit 5e0bb554c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 903 additions and 550 deletions

View File

@ -48,7 +48,6 @@ INSTALLED_APPS = [
'bootstrap3',
'bootstrap_datepicker_plus',
'mathfilters',
'base',
'obp',
'consumers',
@ -56,6 +55,8 @@ INSTALLED_APPS = [
'branches',
'atms',
'atmlist',
'products',
'productlist',
'entitlementrequests',
'customers',
'metrics',

View File

@ -40,6 +40,8 @@ urlpatterns += i18n_patterns(
url(r'^branches/', include('branches.urls')),
url(r'^atms/', include('atms.urls')),
url(r'^atms/list', include('atmlist.urls')),
url(r'^products/', include('products.urls')),
url(r'^products/list', include('productlist.urls')),
url(r'^customers/', include('customers.urls')),
url(r'^metrics/', include('metrics.urls')),
url(r'^config/', include('config.urls')),

View File

@ -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)

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
"""
URLs for metrics app
URLs for ATM list app
"""
from django.conf.urls import url

View File

@ -1,4 +1,4 @@
#atms_list div {
#atms div {
margin: 5px 0;
}

View File

@ -1,5 +1,5 @@
{% extends 'base.html' %} {% load static %} {% load i18n %} {% block page_title %}{{ block.super }} / Atms{% endblock page_title %} {% block content %}
<div id="atms_list">
<div id="atms">
<h1>{% trans "ATM Create" %}</h1>
<form method="post">

View File

@ -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'))
@ -31,6 +31,7 @@ class IndexAtmsView(LoginRequiredMixin, FormView):
# Cannot add api in constructor: super complains about unknown kwarg
form.api = self.api
fields = form.fields
print(fields, "These are fields")
try:
fields['bank_id'].choices = self.api.get_bank_id_choices()
fields['is_accessible'].choices = [('',_('Choose...')),(True, True), (False, False)]
@ -104,6 +105,7 @@ class IndexAtmsView(LoginRequiredMixin, FormView):
def form_valid(self, form):
try:
data = form.cleaned_data
print(data, "This is a data")
urlpath = '/banks/{}/atms'.format(data['bank_id'])
payload ={
"id": data["atm_id"],

View File

@ -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 %}
@ -59,7 +59,7 @@
<li {% if metrics_summary_url in request.path %} class="active" {% endif %}><a href="{{ metrics_summary_url }}">{% trans "KPI Dashboard" %}</a></li>
</ul>
</li>
{% url "branches_list" as branches_list_url %} {% url "customers-create" as customers_create_url %} {% url "atms_create" as atms_create_url %} {% url "atm-list" as atm_list_url %}
{% url "branches_list" as branches_list_url %} {% url "customers-create" as customers_create_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">
@ -68,6 +68,8 @@
<li {% if branches_list_url in request.path %} class="active" {% endif %}><a href="{{ branches_list_url }}">{% trans "Branches" %}</a></li>
<li {% if atms_create_url in request.path %} class="active" {% endif %}><a href="{{ atms_create_url }}">{% trans "ATM Create" %}</a></li>
<li {% if atm_list_url in request.path %} class="active" {% endif %}><a href="{{ atm_list_url }}">{% trans "ATM List" %}</a></li>
<li {% if product_create_url in request.path %} class="active" {% endif %}><a href="{{ product_create_url }}">{% trans "Product Create" %}</a></li>
<li {% if product_list_url in request.path %} class="active" {% endif %}><a href="{{ product_list_url }}">{% trans "Product List" %}</a></li>
</ul>
</li>
{% url "config-index" as config_index_url %} {% url "webui-index" as webui_props_index_url %} {% url "methodrouting-index" as methodrouting_index_url %} {% url "connectormethod" as connectormethod_url %} {% url "dynamicendpoints-index" as dynamic_endpoints_index_url %} {% url "apicollections-index" as api_collections_index_url %}
@ -94,17 +96,16 @@
</li>
{% endif %}
<!--<ul class="nav navbar-nav navbar-right" style="padding-top:13px; margin-left:12rem">-->
<li><a style="text-decoration: none; color:#fff; ">Language
<span id="uk" style="cursor:pointer">EN</span>
|
<span id="es" style="cursor:pointer">ES</span></a></li>
<li style="margin-left:20rem; position:static">
<li style="margin-left:50%; position:fixed">
{% if user.is_authenticated %}
<p class="navbar-right" style="margin-top:8px"><span id="navbar-login-username">{{API_USERNAME}}</span>&nbsp;&nbsp;<a href="/logout" class="btn btn-default">{% trans "Logout" %} </a></p>
{% endif %}
</li>
<!--</ul>-->
<li style="text-decoration: none; color:#fff; cursor:pointer; margin-left:50rem"><a style="color:#fff;">Language
<span id="uk">EN</span>
|
<span id="es">ES</span></a></li>
</ul>
<!--/.nav-collapse -->
</div>

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-09-20 13:08+0200\n"
"POT-Creation-Date: 2022-09-29 14:00+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -70,208 +70,210 @@ msgstr "francés"
msgid "Spanish"
msgstr "español"
#: atmlist/forms.py:14 atmlist/templates/atmlist/atmlist.html:11
#: atms/forms.py:14
msgid "ATM Id"
msgstr "ID del cajero automático"
#: atmlist/forms.py:25 atmlist/templates/atmlist/atmlist.html:12
#: atms/forms.py:25 branches/templates/branches/index.html:161
#: users/templates/users/detail.html:97
#: users/templates/users/invitation.html:22
msgid "Bank Id"
msgstr "Id del banco"
#: atmlist/forms.py:35 atms/forms.py:35 branches/forms.py:33
#: consumers/templates/consumers/index.html:58
msgid "Name"
msgstr "Nombre"
#: atmlist/forms.py:38 atms/forms.py:38
msgid "The name of the ATM"
msgstr "La configuración de la API"
#: atmlist/forms.py:46 atmlist/templates/atmlist/atmlist.html:27
#: atms/forms.py:46 branches/forms.py:43
#: branches/templates/branches/index.html:176
#: branches/templates/branches/index.html:203
msgid "Address"
msgstr "Dirección"
#: atmlist/forms.py:56 atms/forms.py:56 branches/forms.py:53
msgid "Latitude"
msgstr "Latitud"
#: atmlist/forms.py:67 atms/forms.py:67 branches/forms.py:64
msgid "Longitude"
msgstr "Longitud"
#: atmlist/forms.py:78 atms/forms.py:78
msgid "Meta License Id"
msgstr "Meta Licencia"
#: atmlist/forms.py:89 atms/forms.py:89
msgid "Meta License Name"
msgstr "Nombre de la Licencia"
#: atmlist/forms.py:100 atms/forms.py:100
msgid "Opening Hours"
msgstr "Horario de atención"
#: atmlist/forms.py:110 atms/forms.py:110
msgid "Monday"
msgstr "Lunes"
#: atmlist/forms.py:120 atms/forms.py:120
msgid "Tuesday"
msgstr "Martes"
#: atmlist/forms.py:130 atms/forms.py:130
msgid "Wednesday"
msgstr "Wednesday"
#: atmlist/forms.py:140 atms/forms.py:140
msgid "Thursday"
msgstr "Jueves"
#: atmlist/forms.py:150 atms/forms.py:150
msgid "Friday"
msgstr "Viernes"
#: atmlist/forms.py:160 atms/forms.py:160
msgid "Saturday"
msgstr "Sábado"
#: atmlist/forms.py:170 atms/forms.py:170
msgid "Sunday"
msgstr "Sunday"
#: atmlist/forms.py:180 atms/forms.py:180
msgid "Is Accessible"
msgstr "Producción y validación es"
#: atmlist/forms.py:189 atms/forms.py:189
msgid "ATM location"
msgstr "Ubicación"
#: atmlist/forms.py:199 atms/forms.py:199 branches/forms.py:166
msgid "More information"
msgstr "Más información"
#: atmlist/forms.py:202 atms/forms.py:202 branches/forms.py:169
msgid "short walk to the lake from here"
msgstr "corto paseo hasta el lago desde aquí"
#: atmlist/forms.py:209 atms/forms.py:209
msgid "Deposit Capabilities"
msgstr "Tiene capacidad de depósito"
#: atmlist/forms.py:218 atms/forms.py:218
msgid "Supported Languages"
msgstr "Idiomas admitidos"
#: atmlist/forms.py:227 atms/forms.py:227
msgid "Services"
msgstr "Servicios"
#: atmlist/forms.py:230 atms/forms.py:230
msgid "Service store"
msgstr "Servicios"
#: atmlist/forms.py:237 atms/forms.py:237 branches/forms.py:146
#: branches/templates/branches/index.html:209
msgid "Accessible Features"
msgstr "Características accesibles"
#: atmlist/forms.py:240 atms/forms.py:240
msgid "wheelchair, atm usuable by the visually impaired"
msgstr "Rollstuhl, für Sehbehinderte nutzbar"
#: atmlist/forms.py:247 atms/forms.py:247
msgid "Supported Currencies"
msgstr "Divisas Soportadas"
#: atmlist/forms.py:256 atms/forms.py:256
msgid "Write Notes"
msgstr "Notas:"
#: atmlist/forms.py:265 atms/forms.py:265
msgid "Write location Category"
msgstr "Categorías de ubicación"
#: atmlist/forms.py:274 atms/forms.py:274
msgid "Minimum Withdrawal"
msgstr "El retiro mínimo"
#: atmlist/forms.py:284 atms/forms.py:284
msgid "Branch Identification"
msgstr "Identificación de la sucursal"
#: atmlist/forms.py:287 atms/forms.py:287
msgid "Enter your Branch Identification"
msgstr "Identificación de la sucursal"
#: atmlist/forms.py:294 atms/forms.py:294
msgid "Site Identification"
msgstr "IDENTIFICACIÓN DEL LUGAR"
#: atmlist/forms.py:297 atms/forms.py:297
msgid "Enter your Site Identification"
msgstr "IDENTIFICACIÓN DEL LUGAR"
#: atmlist/forms.py:304 atms/forms.py:304
msgid "Site Name"
msgstr "Nobre del sitio"
#: atmlist/forms.py:307 atms/forms.py:307
msgid "Enter your Site Name "
msgstr "Nobre del sitio"
#: atmlist/forms.py:314 atms/forms.py:314
msgid "Cash Withdrawal National fee"
msgstr "Cargo Nacional por Retiro de Efectivo"
#: atmlist/forms.py:317 atms/forms.py:317
msgid "Cash withdrawal national fee"
msgstr "Cargo Nacional por Retiro de Efectivo"
#: atmlist/forms.py:324 atms/forms.py:324
msgid "Cash Withdrawal international fee"
msgstr "Cargo internacional por retiro de efectivo"
#: atmlist/forms.py:327 atms/forms.py:327
msgid "Cash withdrawal international fee"
msgstr "Cargo internacional por retiro de efectivo"
#: atmlist/forms.py:334 atmlist/forms.py:337 atms/forms.py:334
#: atms/forms.py:337
msgid "Balance Inquiry Fee"
msgstr "Cargo por consulta de saldo"
#: atmlist/templates/atmlist/atmlist.html:2
#: atmlist/templates/atmlist/atmlist.html:4 base/templates/base.html:70
msgid "ATM List"
msgstr "Vista de Cajeros Automáticos"
#: atmlist/templates/atmlist/atmlist.html:6
#: productlist/templates/productlist/productlist.html:6
#: users/templates/users/includes/filter_pagination.html:12
msgid "Export CSV"
msgstr "Exportar CSV"
#: atmlist/templates/atmlist/atmlist.html:11 atms/forms.py:14
msgid "ATM Id"
msgstr "ID del cajero automático"
#: atmlist/templates/atmlist/atmlist.html:12 atms/forms.py:25
#: branches/templates/branches/index.html:161
#: productlist/templates/productlist/productlist.html:12
#: users/templates/users/detail.html:97
#: users/templates/users/invitation.html:22
msgid "Bank Id"
msgstr "Id del banco"
#: atmlist/templates/atmlist/atmlist.html:13
msgid "ATM Name"
msgstr "Nombre del cajero automático"
#: atmlist/templates/atmlist/atmlist.html:14
#: productlist/templates/productlist/productlist.html:14
msgid "More info"
msgstr "Más información"
#: atmlist/templates/atmlist/atmlist.html:27 atms/forms.py:46
#: branches/forms.py:43 branches/templates/branches/index.html:176
#: branches/templates/branches/index.html:203
#: productlist/templates/productlist/productlist.html:27
msgid "Address"
msgstr "Dirección"
#: atmlist/templates/atmlist/atmlist.html:36
#: consumers/templates/consumers/index.html:76
#: productlist/templates/productlist/productlist.html:36
#: users/templates/users/index.html:69
msgid "View"
msgstr "Ver"
#: atms/forms.py:35 branches/forms.py:33
#: consumers/templates/consumers/index.html:58
msgid "Name"
msgstr "Nombre"
#: atms/forms.py:38
msgid "The name of the ATM"
msgstr "La configuración de la API"
#: atms/forms.py:56 branches/forms.py:53
msgid "Latitude"
msgstr "Latitud"
#: atms/forms.py:67 branches/forms.py:64
msgid "Longitude"
msgstr "Longitud"
#: atms/forms.py:78
msgid "Meta License Id"
msgstr "Meta Licencia"
#: atms/forms.py:89
msgid "Meta License Name"
msgstr "Nombre de la Licencia"
#: atms/forms.py:100
msgid "Opening Hours"
msgstr "Horario de atención"
#: atms/forms.py:110
msgid "Monday"
msgstr "Lunes"
#: atms/forms.py:120
msgid "Tuesday"
msgstr "Martes"
#: atms/forms.py:130
msgid "Wednesday"
msgstr "Wednesday"
#: atms/forms.py:140
msgid "Thursday"
msgstr "Jueves"
#: atms/forms.py:150
msgid "Friday"
msgstr "Viernes"
#: atms/forms.py:160
msgid "Saturday"
msgstr "Sábado"
#: atms/forms.py:170
msgid "Sunday"
msgstr "Sunday"
#: atms/forms.py:180
msgid "Is Accessible"
msgstr "Producción y validación es"
#: atms/forms.py:189
msgid "ATM location"
msgstr "Ubicación"
#: atms/forms.py:199 branches/forms.py:166
msgid "More information"
msgstr "Más información"
#: atms/forms.py:202 branches/forms.py:169
msgid "short walk to the lake from here"
msgstr "corto paseo hasta el lago desde aquí"
#: atms/forms.py:209
msgid "Deposit Capabilities"
msgstr "Tiene capacidad de depósito"
#: atms/forms.py:218
msgid "Supported Languages"
msgstr "Idiomas admitidos"
#: atms/forms.py:227
msgid "Services"
msgstr "Servicios"
#: atms/forms.py:230
msgid "Service store"
msgstr "Servicios"
#: atms/forms.py:237 branches/forms.py:146
#: branches/templates/branches/index.html:209
msgid "Accessible Features"
msgstr "Características accesibles"
#: atms/forms.py:240
msgid "wheelchair, atm usuable by the visually impaired"
msgstr "Rollstuhl, für Sehbehinderte nutzbar"
#: atms/forms.py:247
msgid "Supported Currencies"
msgstr "Divisas Soportadas"
#: atms/forms.py:256
msgid "Write Notes"
msgstr "Notas:"
#: atms/forms.py:265
msgid "Write location Category"
msgstr "Categorías de ubicación"
#: atms/forms.py:274
msgid "Minimum Withdrawal"
msgstr "El retiro mínimo"
#: atms/forms.py:284
msgid "Branch Identification"
msgstr "Identificación de la sucursal"
#: atms/forms.py:287
msgid "Enter your Branch Identification"
msgstr "Identificación de la sucursal"
#: atms/forms.py:294
msgid "Site Identification"
msgstr "IDENTIFICACIÓN DEL LUGAR"
#: atms/forms.py:297
msgid "Enter your Site Identification"
msgstr "IDENTIFICACIÓN DEL LUGAR"
#: atms/forms.py:304
msgid "Site Name"
msgstr "Nobre del sitio"
#: atms/forms.py:307
msgid "Enter your Site Name "
msgstr "Nobre del sitio"
#: atms/forms.py:314
msgid "Cash Withdrawal National fee"
msgstr "Cargo Nacional por Retiro de Efectivo"
#: atms/forms.py:317
msgid "Cash withdrawal national fee"
msgstr "Cargo Nacional por Retiro de Efectivo"
#: atms/forms.py:324
msgid "Cash Withdrawal international fee"
msgstr "Cargo internacional por retiro de efectivo"
#: atms/forms.py:327
msgid "Cash withdrawal international fee"
msgstr "Cargo internacional por retiro de efectivo"
#: atms/forms.py:334 atms/forms.py:337
msgid "Balance Inquiry Fee"
msgstr "Cargo por consulta de saldo"
#: atms/templates/atms/index.html:3 base/templates/base.html:69
msgid "ATM Create"
msgstr "Creada"
@ -357,42 +359,48 @@ msgstr "Consumidores"
msgid "Branches"
msgstr "Sucursales"
#: base/templates/base.html:75
#: base/templates/base.html:71
#: productlist/templates/productlist/productlist.html:2
#: productlist/templates/productlist/productlist.html:4
msgid "Product List"
msgstr "Produkt Liste"
#: base/templates/base.html:76
msgid "Configurations"
msgstr "Configuraciones"
#: base/templates/base.html:77 config/templates/config/index.html:8
#: base/templates/base.html:78 config/templates/config/index.html:8
msgid "Config"
msgstr "Configuraciones"
#: base/templates/base.html:79
#: base/templates/base.html:80
msgid "Webui Props"
msgstr "Accesorios webui"
#: base/templates/base.html:81
#: base/templates/base.html:82
msgid "Method Routings"
msgstr "Enrutamiento de métodos"
#: base/templates/base.html:83
#: base/templates/base.html:84
#: connectormethod/templates/connectormethod/detail.html:6
#: connectormethod/templates/connectormethod/index.html:6
msgid "Connector Methods"
msgstr "Métricas del conector"
#: base/templates/base.html:85
#: base/templates/base.html:86
#: dynamicendpoints/templates/dynamicendpoints/index.html:7
msgid "Dynamic Endpoints"
msgstr "Puntos finales dinámicos"
#: base/templates/base.html:88
#: base/templates/base.html:89
msgid "My API Collections"
msgstr "Mis colecciones de API"
#: base/templates/base.html:93
#: base/templates/base.html:94
msgid "API Tester"
msgstr "Métricas de la API"
#: base/templates/base.html:99
#: base/templates/base.html:100
msgid "Logout"
msgstr "Cerrar la sesión"
@ -438,7 +446,7 @@ msgstr "Autentificar"
msgid "Choose ..."
msgstr "Seleccione..."
#: base/templates/home.html:32
#: base/templates/home.html:36
msgid "Proceed to authentication server"
msgstr "Weiter zum Authentifizierungsserver"
@ -1497,6 +1505,16 @@ msgstr "Maximo de llamadas por día"
msgid "Calls per month"
msgstr "llamadas por mes"
#: productlist/templates/productlist/productlist.html:11
msgid "Product Code"
msgstr ""
#: productlist/templates/productlist/productlist.html:13
#, fuzzy
#| msgid "Function Name"
msgid "Product Name"
msgstr "Nombre de la función"
#: users/forms.py:15 users/templates/users/detail.html:67
#: users/templates/users/detail.html:96
msgid "Role name"
@ -1649,8 +1667,6 @@ msgid "Web UI Props Value"
msgstr "Accesorios webui"
#: webui/templates/webui/index.html:18
#, fuzzy
#| msgid "Web UI Props Id"
msgid "Props Id"
msgstr "Accesorios webui"

View File

View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

View File

@ -0,0 +1,5 @@
from django.apps import AppConfig
class ProductsConfig(AppConfig):
name = 'products_list'

View File

View File

@ -0,0 +1,4 @@
from django.db import models
# Create your models here.
# -*- coding: utf-8 -*-

View File

@ -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;
}

View File

@ -0,0 +1,5 @@
$(document).ready(function($) {
$('#info').click(function() {
alert("Hello World")
});
});

View File

@ -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 "Product Code" %}</th>
<th scope="col">{% trans "Bank Id" %}</th>
<th scope="col">{% trans "Product Name" %}</th>
<th scope="col">{% trans "More info" %}</th>
</thead>
<tbody>
{% for product in products_list %}
<!--{% url 'atms_update' atm.id atm.bank_id as url_atm_update %}-->
<tr data-product-code="{{ product.code }}">
<td>{{ product.code }}</td>
<td>{{ product.bank_id }}</td>
<td>{{ product.name }}</td>
<td>
<div class="popuptext">
<ul>
<li>{% trans "Description" %}:
<ul>
<li>{{product.Description.more_info_url}}</li>
</ul>
</li>
</ul>
</div>
</td>
<td><a href="{{ url_product_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 'productlist/css/product.css' %}" rel="stylesheet"> {% endblock extracss %}

View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

View File

@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
"""
URLs for Product list app
"""
from django.conf.urls import url
from .views import ProductListView, ExportCsvView
urlpatterns = [
url(r'^$',
ProductListView.as_view(),
name='product-list'),
url(r'^export_csv$',
ExportCsvView.as_view(),
name='export-csv')
]

View File

@ -0,0 +1,100 @@
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 products.views import IndexProductView
from obp.api import API, APIError
import csv
class ProductListView(IndexProductView, LoginRequiredMixin, FormView ):
template_name = "productlist/productlist.html"
success_url = '/products/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_products(self, context):
api = API(self.request.session.get('obp'))
try:
self.bankids = self.get_banks()
products_list = []
for bank_id in self.bankids:
urlpath = '/banks/{}/products'.format(bank_id)
result = api.get(urlpath)
#print(result, "This is a result")
if 'products' in result:
products_list.extend(result['products'])
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 products_list
def get_context_data(self, **kwargs):
context = super(IndexProductView, self).get_context_data(**kwargs)
products_list = self.get_products(context)
context.update({
'products_list': products_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()
products_list = []
for bank_id in self.bankids:
urlpath = '/banks/{}/products'.format(bank_id)
result = api.get(urlpath)
#print(result)
if 'products' in result:
products_list.extend(result['products'])
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(["product_code","bank_id","name","parent_product_code","more_info_url","terms_and_conditions_url","description", "license", "id", "name"])
for user in atms_list:
writer.writerow([user['product_code'],user['bank_id'], user['name'], user["parent_product_code"], user["more_info_url"],
user["terms_and_conditions_url"], user["description"], user["license"]['id'], user["license"]['name']])
return response
#print(atms_list)

View File

View File

@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

View File

@ -0,0 +1,5 @@
from django.apps import AppConfig
class BranchesConfig(AppConfig):
name = 'products'

View File

@ -0,0 +1,109 @@
"""
Forms of branches app
"""
from django import forms
from django.utils.translation import ugettext_lazy as _
import random
class CreateProductForm(forms.Form):
product_code = forms.CharField(
label=_('Product Code'),
widget=forms.TextInput(
attrs={
'placeholder': 'Product-Code-{}'.format(random.randint(1,1000)),
'class': 'form-control',
}
),
initial='Product-Code-{}'.format(random.randint(1,1000)),
)
bank_id = forms.ChoiceField(
label=_('Bank'),
widget=forms.Select(
attrs={
'class': 'form-control',
}
),
choices=[],
)
parent_product_code = forms.CharField(
label=_('parent_product_code'),
widget=forms.TextInput(
attrs={
'placeholder': _('parent_product_code'),
'class': 'form-control',
}
),
required=False
)
name = forms.CharField(
label=_('Name'),
widget=forms.TextInput(
attrs={
'placeholder': _('The name of the branch'),
'class': 'form-control',
}
),
required=True
)
more_info_url = forms.CharField(
label=_('more_info_url'),
widget=forms.TextInput(
attrs={
'placeholder': _('The name of the branch'),
'class': 'form-control',
}
),
required=False
)
terms_and_conditions_url = forms.CharField(
label=_('terms_and_conditions_url'),
widget=forms.TextInput(
attrs={
'placeholder': _('terms_and_conditions_url'),
'class': 'form-control',
}
),
required=False
)
description = forms.CharField(
label=_('description'),
widget=forms.TextInput(
attrs={
'placeholder': _('description'),
'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,
)
def __init__(self, *args, **kwargs):
kwargs.setdefault('label_suffix', '')
super(CreateProductForm, self).__init__(*args, **kwargs)

View File

@ -0,0 +1,4 @@
from django.db import models
# Create your models here.
# -*- coding: utf-8 -*-

View File

@ -0,0 +1,18 @@
#products 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;
}

View File

@ -0,0 +1,5 @@
$(document).ready(function($) {
$('#info').click(function() {
alert("Hello World")
});
});

View File

@ -0,0 +1,95 @@
{% extends 'base.html' %}
{% load static %}
{% load i18n %}
{% block page_title %}{{ block.super }} / Products {% endblock page_title %}
{% block content %}
<div id="products">
<h1>{% trans "Product Create" %}</h1>
<form method="post">
{% csrf_token %}
{% if form.non_field_errors %}
<div class="alert alert-danger">
{{ form.non_field_errors }}
</div>
{% endif %}
<div class="row">
<div class="col-xs-12 col-sm-4">
{% if form.parent_product_code.errors %}<div class="alert alert-danger">{{ form.parent_product_code.errors }}</div>{% endif %}
<div class="form-group">
{{ form.parent_product_code.label_tag }}
{{ form.parent_product_code }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.name.errors %}<div class="alert alert-danger">{{ form.name.errors }}</div>{% endif %}
<div class="form-group">
<strong>{% trans "name" %} </strong>
{{ form.name }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.more_info_url.errors %}<div class="alert alert-danger">{{ form.more_info_url.errors }}</div>{% endif %}
<div class="form-group">
{{ form.more_info_url.label_tag }}
{{ form.more_info_url }}
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-4">
{% if form.terms_and_conditions_url.errors %}<div class="alert alert-danger">{{ form.terms_and_conditions_url.errors }}</div>{% endif %}
<div class="form-group">
{{ form.terms_and_conditions_url.label_tag }}
{{ form.terms_and_conditions_url }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.description.errors %}<div class="alert alert-danger">{{ form.description.errors }}</div>{% endif %}
<div class="form-group">
<strong>{% trans "description" %} </strong>
{{ form.description }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.meta_license_name.errors %}<div class="alert alert-danger">{{ form.meta_license_name.errors }}</div>{% endif %}
<div class="form-group">
{{ form.meta_license_name.label_tag }}
{{ form.meta_license_name }}
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-4">
{% if form.meta_license_id.errors %}<div class="alert alert-danger">{{ form.meta_license_id.errors }}</div>{% endif %}
<div class="form-group">
{{ form.meta_license_id.label_tag }}
{{ form.meta_license_id }}
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12 hidden-xs">
<div class="form-group">
<button type="submit" class="btn btn-primary btn-green">{% trans "Add" %}</button>
</div>
</div>
</div>
</form>
</div>
{% endblock %}
{% block extrajs %}
{% comment %}
<script type="text/javascript" src="{% static 'products/js/products.js' %}"></script>
<script type="text/javascript">
</script>
{% endcomment %}
{% endblock extrajs %}
{% block extracss %}
<link href="{% static 'products/css/products.css' %}" rel="stylesheet">
{% endblock extracss %}

View File

@ -0,0 +1,80 @@
{% extends 'base.html' %}
{% load static %}
{% load i18n %}
{% block page_title %}{{ block.super }} / Products {% endblock page_title %}
{% block content %}
<div id="products">
<h1>{% trans "ATM Detail" %}</h1>
<h2>{{ bank_id }} : {{ product_code }}</h2>
<form method="post">
{% csrf_token %}
{% if form.non_field_errors %}
<div class="alert alert-danger">
{{ form.non_field_errors }}
</div>
{% endif %}
<div class="row" style="display: None">
<div class="col-xs-12 col-sm-4">
{% if form.parent_product_code.errors %}<div class="alert alert-danger">{{ form.parent_product_code.errors }}</div>{% endif %}
<div class="form-group">
{{ form.parent_product_code.label_tag }}
{{ form.parent_product_code }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.name.errors %}<div class="alert alert-danger">{{ form.name.errors }}</div>{% endif %}
<div class="form-group">
<strong>{% trans "name" %} </strong>
{{ form.name }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.more_info_url.errors %}<div class="alert alert-danger">{{ form.more_info_url.errors }}</div>{% endif %}
<div class="form-group">
{{ form.more_info_url.label_tag }}
{{ form.more_info_url }}
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-4">
{% if form.terms_and_conditions_url.errors %}<div class="alert alert-danger">{{ form.terms_and_conditions_url.errors }}</div>{% endif %}
<div class="form-group">
{{ form.terms_and_conditions_url.label_tag }}
{{ form.terms_and_conditions_url }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.description.errors %}<div class="alert alert-danger">{{ form.description.errors }}</div>{% endif %}
<div class="form-group">
<strong>{% trans "description" %} </strong>
{{ form.description }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.meta_license_name.errors %}<div class="alert alert-danger">{{ form.meta_license_name.errors }}</div>{% endif %}
<div class="form-group">
{{ form.meta_license_name.label_tag }}
{{ form.meta_license_name }}
</div>
</div>
</div>
<input type="submit" value="Update" class="btn btn-primary" />
</form>
</div>
{% endblock %}
{% block extrajs %}
{% comment %}
<script type="text/javascript" src="{% static 'products/js/products.js' %}"></script>
<script type="text/javascript">
</script>
{% endcomment %}
{% endblock extrajs %}
{% block extracss %}
<link href="{% static 'products/css/products.css' %}" rel="stylesheet">
{% endblock extracss %}

View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

View File

@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
"""
URLs for metrics app
"""
from django.conf.urls import url
from .views import IndexProductView, UpdateProductView
urlpatterns = [
url(r'^create',
IndexProductView.as_view(),
name='products-create'),
url(r'^update/(?P<product_code>[0-9\w\@\.\+-]+)/bank/(?P<bank_id>[0-9\w\@\.\+-]+)/$',
UpdateProductView.as_view(),
name='products_update')
]

View File

@ -0,0 +1,139 @@
from django.shortcuts import render
# Create your views here.
# -*- coding: utf-8 -*-
"""
Views of Product 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 CreateProductForm
class IndexProductView(LoginRequiredMixin, FormView):
"""Index view for Product"""
template_name = "products/index.html"
form_class = CreateProductForm
success_url = reverse_lazy('products-create')
def dispatch(self, request, *args, **kwargs):
self.api = API(request.session.get('obp'))
return super(IndexProductView, self).dispatch(request, *args, **kwargs)
def get_form(self, *args, **kwargs):
form = super(IndexProductView, 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:
messages.error(self.request, "Unknown Error")
return form
def form_valid(self, form):
try:
pass
#result = self.api.put(urlpath, payload=payload)
except APIError as err:
messages.error(self.request, err)
return super(IndexProductView, self).form_invalid(form)
except Exception as err:
messages.error(self.request, "Unknown Error")
return super(IndexProductView, self).form_invalid(form)
if 'code' in result and result['code']>=400:
messages.error(self.request, result['message'])
return super(IndexProductView, self).form_valid(form)
msg = 'Product {} for Bank {} has been created successfully!'.format(result['product_code'], result['bank_id'])
messages.success(self.request, msg)
return super(IndexProductView, self).form_valid(form)
class UpdateProductView(LoginRequiredMixin, FormView):
template_name = "products/update.html"
success_url = '/products/list'
form_class = CreateProductForm
def dispatch(self, request, *args, **kwargs):
self.api = API(request.session.get('obp'))
return super(UpdateProductView, self).dispatch(request, *args, **kwargs)
def get_form(self, *args, **kwargs):
form = super(UpdateProductView, self).get_form(*args, **kwargs)
# Cannot add api in constructor: super complains about unknown kwarg
form.api = self.api
fields = form.fields
urlpath = "/banks/{}/products/{}".format(self.kwargs['bank_id'], self.kwargs['product_code'])
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['parent_product_code'].initial = self.kwargs['parent_product_code']
fields['name'].initial = result['name']
fields['more_info_url'].initial = result['more_info_url']
fields['terms_and_conditions_url'].initial = result['terms_and_conditions_url']
fields['description'].initial = result['description']
fields['meta_license_id'].initial = result['meta']['license']['id']
fields['meta_license_name'].initial = result['meta']['license']['name']
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/{}/products/{}'.format(data["bank_id"], data["product_code"])
payload = {
#"product_code": data["product_code"],
"parent_product_code": data["parent_product_code"],
#"bank_id": data["bank_id"],
"name": data["name"],
"more_info_url": data["more_info_url"],
"terms_and_conditions_url": data["terms_and_conditions_url"],
"description": data["description"],
"meta": {
"license": {
"id": "PDDL",
"name": data["meta_license_name"] if data["meta_license_name"]!="" else "license name"
}
},
}
try:
result = self.api.put(urlpath, payload=payload)
print(result, "This is result")
if 'code' in result and result['code']>=400:
error_once_only(self.request, result['message'])
return super(UpdateProductView, self).form_invalid(form)
except APIError as err:
messages.error(self.request, err)
return super(UpdateProductView, self).form_invalid(form)
except Exception as err:
messages.error(self.request, err)
return super(UpdateProductView, self).form_invalid(form)
msg = 'Product {} for Bank {} has been Update successfully!'.format( # noqa
data["product_code"], data["bank_id"])
messages.success(self.request, msg)
return super(UpdateProductView, self).form_valid(form)
def get_context_data(self, **kwargs):
context = super(UpdateProductView, self).get_context_data(**kwargs)
self.bank_id = self.kwargs['bank_id']
self.branch_id = self.kwargs['product_code']
context.update({
'product_code': self.product_code,
'bank_id': self.bank_id
})
return context