diff --git a/apimanager/apimanager/settings.py b/apimanager/apimanager/settings.py index 597a9ff..f60d7f0 100644 --- a/apimanager/apimanager/settings.py +++ b/apimanager/apimanager/settings.py @@ -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', diff --git a/apimanager/apimanager/urls.py b/apimanager/apimanager/urls.py index b5673bf..abc8540 100644 --- a/apimanager/apimanager/urls.py +++ b/apimanager/apimanager/urls.py @@ -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')), diff --git a/apimanager/atmlist/forms.py b/apimanager/atmlist/forms.py index 348195a..e69de29 100644 --- a/apimanager/atmlist/forms.py +++ b/apimanager/atmlist/forms.py @@ -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) diff --git a/apimanager/atmlist/urls.py b/apimanager/atmlist/urls.py index 7a1aad4..b41d66d 100644 --- a/apimanager/atmlist/urls.py +++ b/apimanager/atmlist/urls.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -URLs for metrics app +URLs for ATM list app """ from django.conf.urls import url diff --git a/apimanager/atms/static/atms/css/atms.css b/apimanager/atms/static/atms/css/atms.css index 587b75c..0718557 100644 --- a/apimanager/atms/static/atms/css/atms.css +++ b/apimanager/atms/static/atms/css/atms.css @@ -1,4 +1,4 @@ -#atms_list div { +#atms div { margin: 5px 0; } diff --git a/apimanager/atms/templates/atms/index.html b/apimanager/atms/templates/atms/index.html index 9d9ad11..ef521a7 100644 --- a/apimanager/atms/templates/atms/index.html +++ b/apimanager/atms/templates/atms/index.html @@ -1,5 +1,5 @@ {% extends 'base.html' %} {% load static %} {% load i18n %} {% block page_title %}{{ block.super }} / Atms{% endblock page_title %} {% block content %} -
+

{% trans "ATM Create" %}

diff --git a/apimanager/atms/views.py b/apimanager/atms/views.py index 9dc2f58..34051da 100644 --- a/apimanager/atms/views.py +++ b/apimanager/atms/views.py @@ -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"], diff --git a/apimanager/base/templates/base.html b/apimanager/base/templates/base.html index a35c1ca..4617c13 100644 --- a/apimanager/base/templates/base.html +++ b/apimanager/base/templates/base.html @@ -30,7 +30,7 @@
diff --git a/apimanager/locale/es/LC_MESSAGES/django.mo b/apimanager/locale/es/LC_MESSAGES/django.mo index b634012..7423b4f 100644 Binary files a/apimanager/locale/es/LC_MESSAGES/django.mo and b/apimanager/locale/es/LC_MESSAGES/django.mo differ diff --git a/apimanager/locale/es/LC_MESSAGES/django.po b/apimanager/locale/es/LC_MESSAGES/django.po index 12f6d42..2e18ec3 100644 --- a/apimanager/locale/es/LC_MESSAGES/django.po +++ b/apimanager/locale/es/LC_MESSAGES/django.po @@ -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 \n" "Language-Team: LANGUAGE \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" diff --git a/apimanager/productlist/__init__.py b/apimanager/productlist/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/apimanager/productlist/admin.py b/apimanager/productlist/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/apimanager/productlist/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/apimanager/productlist/apps.py b/apimanager/productlist/apps.py new file mode 100644 index 0000000..2c7234f --- /dev/null +++ b/apimanager/productlist/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class ProductsConfig(AppConfig): + name = 'products_list' diff --git a/apimanager/productlist/forms.py b/apimanager/productlist/forms.py new file mode 100644 index 0000000..e69de29 diff --git a/apimanager/productlist/models.py b/apimanager/productlist/models.py new file mode 100644 index 0000000..3b5ea8d --- /dev/null +++ b/apimanager/productlist/models.py @@ -0,0 +1,4 @@ +from django.db import models + +# Create your models here. +# -*- coding: utf-8 -*- diff --git a/apimanager/productlist/static/productlist/css/productlist.css b/apimanager/productlist/static/productlist/css/productlist.css new file mode 100644 index 0000000..32f6735 --- /dev/null +++ b/apimanager/productlist/static/productlist/css/productlist.css @@ -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; +} diff --git a/apimanager/productlist/static/productlist/js/productlist.js b/apimanager/productlist/static/productlist/js/productlist.js new file mode 100644 index 0000000..338fe9e --- /dev/null +++ b/apimanager/productlist/static/productlist/js/productlist.js @@ -0,0 +1,5 @@ +$(document).ready(function($) { + $('#info').click(function() { + alert("Hello World") + }); +}); diff --git a/apimanager/productlist/templates/productlist/productlist.html b/apimanager/productlist/templates/productlist/productlist.html new file mode 100644 index 0000000..f7f98c6 --- /dev/null +++ b/apimanager/productlist/templates/productlist/productlist.html @@ -0,0 +1,45 @@ +{% extends 'base.html' %} {% load static %} {% load i18n %} +{% block page_title %} {{ block.super }} / {% trans "Product List" %}{% endblock page_title %} {% block content %} +
+

{% trans "Product List" %}

+ + + +
+ + + + + + + + + {% for product in products_list %} + + + + + + + + + + {% endfor %} + + +
{% trans "Product Code" %}{% trans "Bank Id" %}{% trans "Product Name" %}{% trans "More info" %}
{{ product.code }}{{ product.bank_id }}{{ product.name }} +
+
    +
  • {% trans "Description" %}: +
      +
    • {{product.Description.more_info_url}}
    • +
    +
  • + +
+
+
{% trans "View" %}
+
+
+{% endblock %} {% block extrajs %} {% endblock extrajs %} {% block extracss %} + {% endblock extracss %} \ No newline at end of file diff --git a/apimanager/productlist/tests.py b/apimanager/productlist/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/apimanager/productlist/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/apimanager/productlist/urls.py b/apimanager/productlist/urls.py new file mode 100644 index 0000000..82cadbe --- /dev/null +++ b/apimanager/productlist/urls.py @@ -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') +] diff --git a/apimanager/productlist/views.py b/apimanager/productlist/views.py new file mode 100644 index 0000000..bed8740 --- /dev/null +++ b/apimanager/productlist/views.py @@ -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) + diff --git a/apimanager/products/__init__.py b/apimanager/products/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/apimanager/products/admin.py b/apimanager/products/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/apimanager/products/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/apimanager/products/apps.py b/apimanager/products/apps.py new file mode 100644 index 0000000..3d454ed --- /dev/null +++ b/apimanager/products/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class BranchesConfig(AppConfig): + name = 'products' diff --git a/apimanager/products/forms.py b/apimanager/products/forms.py new file mode 100644 index 0000000..e01da52 --- /dev/null +++ b/apimanager/products/forms.py @@ -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) diff --git a/apimanager/products/models.py b/apimanager/products/models.py new file mode 100644 index 0000000..3b5ea8d --- /dev/null +++ b/apimanager/products/models.py @@ -0,0 +1,4 @@ +from django.db import models + +# Create your models here. +# -*- coding: utf-8 -*- diff --git a/apimanager/products/static/products/css/products.css b/apimanager/products/static/products/css/products.css new file mode 100644 index 0000000..b088e91 --- /dev/null +++ b/apimanager/products/static/products/css/products.css @@ -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; +} diff --git a/apimanager/products/static/products/js/products.js b/apimanager/products/static/products/js/products.js new file mode 100644 index 0000000..338fe9e --- /dev/null +++ b/apimanager/products/static/products/js/products.js @@ -0,0 +1,5 @@ +$(document).ready(function($) { + $('#info').click(function() { + alert("Hello World") + }); +}); diff --git a/apimanager/products/templates/products/index.html b/apimanager/products/templates/products/index.html new file mode 100644 index 0000000..8a6ae7b --- /dev/null +++ b/apimanager/products/templates/products/index.html @@ -0,0 +1,95 @@ +{% extends 'base.html' %} +{% load static %} +{% load i18n %} +{% block page_title %}{{ block.super }} / Products {% endblock page_title %} +{% block content %} + +
+

{% trans "Product Create" %}

+ +
+ {% csrf_token %} + {% if form.non_field_errors %} +
+ {{ form.non_field_errors }} +
+ {% endif %} +
+
+ {% if form.parent_product_code.errors %}
{{ form.parent_product_code.errors }}
{% endif %} +
+ {{ form.parent_product_code.label_tag }} + {{ form.parent_product_code }} +
+
+
+ {% if form.name.errors %}
{{ form.name.errors }}
{% endif %} +
+ {% trans "name" %} + {{ form.name }} +
+
+
+ {% if form.more_info_url.errors %}
{{ form.more_info_url.errors }}
{% endif %} +
+ {{ form.more_info_url.label_tag }} + {{ form.more_info_url }} +
+
+
+ +
+
+ {% if form.terms_and_conditions_url.errors %}
{{ form.terms_and_conditions_url.errors }}
{% endif %} +
+ {{ form.terms_and_conditions_url.label_tag }} + {{ form.terms_and_conditions_url }} +
+
+
+ {% if form.description.errors %}
{{ form.description.errors }}
{% endif %} +
+ {% trans "description" %} + {{ form.description }} +
+
+
+ {% if form.meta_license_name.errors %}
{{ form.meta_license_name.errors }}
{% endif %} +
+ {{ form.meta_license_name.label_tag }} + {{ form.meta_license_name }} +
+
+
+
+
+ {% if form.meta_license_id.errors %}
{{ form.meta_license_id.errors }}
{% endif %} +
+ {{ form.meta_license_id.label_tag }} + {{ form.meta_license_id }} +
+
+
+
+ +
+
+
+{% endblock %} + +{% block extrajs %} +{% comment %} + + +{% endcomment %} +{% endblock extrajs %} + + +{% block extracss %} + +{% endblock extracss %} diff --git a/apimanager/products/templates/products/update.html b/apimanager/products/templates/products/update.html new file mode 100644 index 0000000..2ed347e --- /dev/null +++ b/apimanager/products/templates/products/update.html @@ -0,0 +1,80 @@ +{% extends 'base.html' %} +{% load static %} +{% load i18n %} +{% block page_title %}{{ block.super }} / Products {% endblock page_title %} +{% block content %} + +
+

{% trans "ATM Detail" %}

+

{{ bank_id }} : {{ product_code }}

+
+ {% csrf_token %} + {% if form.non_field_errors %} +
+ {{ form.non_field_errors }} +
+ {% endif %} + + +
+
+ {% if form.terms_and_conditions_url.errors %}
{{ form.terms_and_conditions_url.errors }}
{% endif %} +
+ {{ form.terms_and_conditions_url.label_tag }} + {{ form.terms_and_conditions_url }} +
+
+
+ {% if form.description.errors %}
{{ form.description.errors }}
{% endif %} +
+ {% trans "description" %} + {{ form.description }} +
+
+
+ {% if form.meta_license_name.errors %}
{{ form.meta_license_name.errors }}
{% endif %} +
+ {{ form.meta_license_name.label_tag }} + {{ form.meta_license_name }} +
+
+
+ +
+
+{% endblock %} + +{% block extrajs %} +{% comment %} + + +{% endcomment %} +{% endblock extrajs %} + + +{% block extracss %} + +{% endblock extracss %} diff --git a/apimanager/products/tests.py b/apimanager/products/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/apimanager/products/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/apimanager/products/urls.py b/apimanager/products/urls.py new file mode 100644 index 0000000..6cae8bd --- /dev/null +++ b/apimanager/products/urls.py @@ -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[0-9\w\@\.\+-]+)/bank/(?P[0-9\w\@\.\+-]+)/$', + UpdateProductView.as_view(), + name='products_update') +] diff --git a/apimanager/products/views.py b/apimanager/products/views.py new file mode 100644 index 0000000..04aaedc --- /dev/null +++ b/apimanager/products/views.py @@ -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 + + + +