feature ATMs

This commit is contained in:
Reena-cell 2022-05-23 09:58:51 +02:00
parent f6da0ae100
commit f5e76978f0
16 changed files with 255 additions and 148 deletions

View File

@ -1,6 +1,7 @@
git {% extends 'base.html' %} {% load static %} {% block page_title %}{{ block.super }} / atms{% endblock page_title %} {% block content %}
{% extends 'base.html' %} {% load static i18n %}
{% block page_title %}{{ block.super }} / atms{% endblock page_title %} {% block content %}
<div id="atms_list">
<h1>ATMs</h1>
<h1>{% trans "ATMs" %}</h1>
<form method="post">
{% csrf_token %} {% if form.non_field_errors %}
@ -13,21 +14,21 @@ git {% extends 'base.html' %} {% load static %} {% block page_title %}{{ block.s
{% if form.atm_id.errors %}
<div class="alert alert-danger">{{ form.atm_id.errors }}</div>{% endif %}
<div class="form-group">
{{ form.atm_id.label_tag }} {{ form.atm_id }}
<strong>{% trans "ATM Id" %} </strong>{{ form.atm_id }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.bank_id.errors %}
<div class="alert alert-danger">{{ form.bank_id.errors }}</div>{% endif %}
<div class="form-group">
{{ form.bank_id.label_tag }} {{ form.bank_id }}
<strong>{% trans "ATM Id" %}</strong> {{ form.bank_id }}
</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">
{{ form.name.label_tag }} {{ form.name }}
<strong>{% trans "name" %}</strong> {{ form.name }}
</div>
</div>
</div>
@ -36,7 +37,7 @@ git {% extends 'base.html' %} {% load static %} {% block page_title %}{{ block.s
{% if form.services.errors %}
<div class="alert alert-danger">{{ form.services.errors }}</div>{% endif %}
<div class="form-group">
{{ form.services.label_tag }} {{ form.services }}
<strong>{% trans "services" %}</strong> {{ form.services }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
@ -44,7 +45,7 @@ git {% extends 'base.html' %} {% load static %} {% block page_title %}{{ block.s
<div class="alert alert-danger">{{ form.location_latitude.errors }}
</div>{% endif %}
<div class="form-group">
{{ form.location_latitude.label_tag }} {{ form.location_latitude }}
<strong>{% trans "location_latitude" %}</strong> {{ form.location_latitude }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
@ -52,7 +53,7 @@ git {% extends 'base.html' %} {% load static %} {% block page_title %}{{ block.s
<div class="alert alert-danger">{{ form.location_longitude.errors }}
</div>{% endif %}
<div class="form-group">
{{ form.location_longitude.label_tag }} {{ form.location_longitude }}
<strong>{% trans "location_longitude" %}</strong> {{ form.location_longitude }}
</div>
</div>
</div>
@ -62,21 +63,21 @@ git {% extends 'base.html' %} {% load static %} {% block page_title %}{{ block.s
<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 }}
<strong>{% trans "meta_license_name" %}</strong> {{ form.meta_license_name }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.located_at.errors %}
<div class="alert alert-danger">{{ form.located_at.errors }}</div>{% endif %}
<div class="form-group">
{{ form.located_at.label_tag }} {{ form.located_at }}
<strong>{% trans "located_at" %}</strong> {{ form.located_at }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.has_deposit_capability.errors %}
<div class="alert alert-danger">{{ form.has_deposit_capability.errors }}</div>{% endif %}
<div class="form-group">
{{ form.has_deposit_capability.label_tag }} {{ form.has_deposit_capability }}
<strong>{% trans "has_deposit_capability" %}</strong> {{ form.has_deposit_capability }}
</div>
</div>
</div>
@ -86,7 +87,7 @@ git {% extends 'base.html' %} {% load static %} {% block page_title %}{{ block.s
<div class="alert alert-danger">{{ form.is_accessible.errors }}</div>
{% endif %}
<div class="form-group">
{{ form.is_accessible.label_tag }} {{ form.is_accessible }}
<strong>{% trans "is_accessible" %}</strong> {{ form.is_accessible }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
@ -94,14 +95,14 @@ git {% extends 'base.html' %} {% load static %} {% block page_title %}{{ block.s
<div class="alert alert-danger">{{ form.accessibility_features.errors }}
</div>{% endif %}
<div class="form-group">
{{ form.accessibility_features.label_tag }} {{ form.accessibility_features }}
<strong>{% trans "accessibility_features" %}</strong> {{ form.accessibility_features }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.more_info.errors %}
<div class="alert alert-danger">{{ form.more_info.errors }}</div>{% endif %}
<div class="form-group">
{{ form.more_info.label_tag }} {{ form.more_info }}
<strong>{% trans "more_info" %}</strong> {{ form.more_info }}
</div>
</div>
</div>
@ -110,21 +111,21 @@ git {% extends 'base.html' %} {% load static %} {% block page_title %}{{ block.s
{% if form.notes.errors %}
<div class="alert alert-danger">{{ form.notes.errors }}</div>{% endif %}
<div class="form-group">
{{ form.notes.label_tag }} {{ form.notes }}
<strong>{% trans "notes" %}</strong> {{ form.notes }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.supported_languages.errors %}
<div class="alert alert-danger">{{ form.supported_languages.errors }}</div>{% endif %}
<div class="form-group">
{{ form.supported_languages.label_tag }} {{ form.supported_languages }}
<strong>{% trans "supported_languages" %}</strong> {{ form.supported_languages }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.supported_currencies.errors %}
<div class="alert alert-danger">{{ form.supported_currencies.errors }}</div>{% endif %}
<div class="form-group">
{{ form.supported_currencies.label_tag }} {{ form.supported_currencies }}
<strong>{% trans "supported_currencies" %}</strong> {{ form.supported_currencies }}
</div>
</div>
</div>
@ -133,7 +134,7 @@ git {% extends 'base.html' %} {% load static %} {% block page_title %}{{ block.s
{% if form.location_categories.errors %}
<div class="alert alert-danger">{{ form.location_categories.errors }}</div>{% endif %}
<div class="form-group">
{{ form.location_categories.label_tag }} {{ form.location_categories }}
<strong>{% trans "location_categories" %}</strong> {{ form.location_categories }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
@ -141,14 +142,14 @@ git {% extends 'base.html' %} {% load static %} {% block page_title %}{{ block.s
<div class="alert alert-danger">{{ form.minimum_withdrawal.errors }}
</div>{% endif %}
<div class="form-group">
{{ form.minimum_withdrawal.label_tag }} {{ form.minimum_withdrawal }}
<strong>{% trans "minimum_withdrawal" %}</strong> {{ form.minimum_withdrawal }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.site_name.errors %}
<div class="alert alert-danger">{{ form.site_name.errors }}</div>{% endif %}
<div class="form-group">
{{ form.site_name.label_tag }} {{ form.site_name }}
<strong>{% trans "site_name" %}</strong> {{ form.site_name }}
</div>
</div>
</div>
@ -157,19 +158,19 @@ git {% extends 'base.html' %} {% load static %} {% block page_title %}{{ block.s
{% if form.branch_identification.errors %}
<div class="alert alert-danger">{{ form.branch_identification.errors }}</div>{% endif %}
<div class="form-group">
{{ form.branch_identification.label_tag }} {{ form.branch_identification }}
<strong>{% trans "branch_identification" %}</strong> {{ form.branch_identification }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.site_identification.errors %}
<div class="alert alert-danger">{{ form.site_identification.errors }}</div>{% endif %}
<div class="form-group">
{{ form.site_identification.label_tag }} {{ form.site_identification }}
<strong>{% trans "site_identification" %}</strong> {{ form.site_identification }}
</div>
</div>
<div class="col-xs-12 col-sm-4"> {% if form.cash_withdrawal_national_fee.errors %}
<div class="alert alert-danger">{{ form.cash_withdrawal_national_fee.errors }}</div>{% endif %}
<div class="form-group">{{ form.cash_withdrawal_national_fee.label_tag }} {{ form.cash_withdrawal_national_fee }}
<div class="form-group"><strong>{% trans "cash_withdrawal_national_fee" %}</strong> {{ form.cash_withdrawal_national_fee }}
</div>
</div>
@ -179,14 +180,14 @@ git {% extends 'base.html' %} {% load static %} {% block page_title %}{{ block.s
{% if form.balance_inquiry_fee.errors %}
<div class="alert alert-danger">{{ form.balance_inquiry_fee.errors }}</div>{% endif %}
<div class="form-group">
{{ form.balance_inquiry_fee.label_tag }} {{ form.balance_inquiry_fee }}
<strong>{% trans "balance_inquiry_fee" %}</strong> {{ form.balance_inquiry_fee }}
</div>
</div>
<div class="col-xs-12 col-sm-4">
{% if form.cash_withdrawal_international_fee.errors %}
<div class="alert alert-danger">{{ form.cash_withdrawal_international_fee.errors }}</div>{% endif %}
<div class="form-group">
{{ form.cash_withdrawal_international_fee.label_tag }} {{ form.cash_withdrawal_international_fee }}
<strong>{% trans "cash_withdrawal_international_fee" %}</strong> {{ form.cash_withdrawal_international_fee }}
</div>
</div>
</div>
@ -195,14 +196,14 @@ git {% extends 'base.html' %} {% load static %} {% block page_title %}{{ block.s
{% if form.address.errors %}
<div class="alert alert-danger">{{ form.address.errors }}</div>{% endif %}
<div class="form-group">
{{ form.address.label_tag }} {{ form.address }}
<strong>{% trans "address" %}</strong> {{ form.address }}
</div>
</div>
<div class="col-xs-12 col-sm-6">
{% if form.lobby.errors %}
<div class="alert alert-danger">{{ form.lobby.errors }}</div>{% endif %}
<div class="form-group">
{{ form.lobby.label_tag }} {{ form.lobby }}
<strong>{% trans "lobby" %}</strong> {{ form.lobby }}
</div>
</div>
</div>
@ -218,15 +219,17 @@ git {% extends 'base.html' %} {% load static %} {% block page_title %}{{ block.s
<div class="table-responsive">
<table class="table table-hover tablesorter" id="atms-list" aria-describedby="atms list">
<thead>
<th scope="col">ATM Id</th>
<th scope="col">Bank Id</th>
<th scope="col">ATM Name</th>
<th scope="col">More_info</th>
<th scope="col">Update Button</th>
<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>
<th scope="col">{% trans "Update Button" %}</th>
</thead>
<tbody>
{% for atm in atms_list %} {% url 'atms_update' atm.id atm.bank_id as url_atm_update %}
<tr data-atm-id="{{ branch.id }}">
{% 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>
@ -269,12 +272,13 @@ git {% extends 'base.html' %} {% load static %} {% block page_title %}{{ block.s
</ul>
</div>
</td>
<td><a href="{{ url_branch_update }}" class="btn btn-primary">Update</a></td>
<td><a href="{{ url_atm_update }}" class="btn btn-primary">Update</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 %}

View File

@ -11,7 +11,7 @@ urlpatterns = [
url(r'^$',
IndexAtmsView.as_view(),
name='atms_list'),
url(r'^update/(?P<atm_id>[0-9\w\@\.\+-]+)/bank/(?P<bank_id>[0-9\w\@\.\+-]+)/$',
url(r'^update/(?P<atm_id>[ 0-9\w|\W\@\.\+-]+)/bank/(?P<bank_id>[0-9\w\@\.\+-]+)/$',
UpdateAtmsView.as_view(),
name='atms_update')
]

View File

@ -106,7 +106,7 @@ class IndexAtmsView(LoginRequiredMixin, FormView):
data = form.cleaned_data
urlpath = '/banks/{}/atms'.format(data['bank_id'])
payload ={
"id": data["atm_id"],
"id": data["atm_id"],
"bank_id": data["bank_id"],
"name": data["name"],
"address": json.loads(data['address']),
@ -226,7 +226,6 @@ class IndexAtmsView(LoginRequiredMixin, FormView):
class UpdateAtmsView(LoginRequiredMixin, FormView):
template_name = "atms/update.html"
success_url = '/atms/'
print(success_url)
form_class = CreateAtmForm
def dispatch(self, request, *args, **kwargs):
@ -235,6 +234,7 @@ class UpdateAtmsView(LoginRequiredMixin, FormView):
def get_form(self, *args, **kwargs):
form = super(UpdateAtmsView, self).get_form(*args, **kwargs)
print("Hello World")
# Cannot add api in constructor: super complains about unknown kwarg
form.api = self.api
fields = form.fields
@ -275,27 +275,27 @@ class UpdateAtmsView(LoginRequiredMixin, FormView):
fields['located_at'].initial = result['located_at']
fields['more_info'].initial = result['more_info']
fields['located_at'].initial = result['located_at']
fields['lobby'].initial = json.dumps(result['lobby'], indent=4)
if result['supported_languages'].lower()=='en':
#lofields['lobby'].initial = json.dumps(result['lobby'], indent=4)
if result['supported_languages'][0].lower()=='en':
fields['supported_languages'].choices = [("en", "en"), ("fr", "fr"), ("de", "de")]
elif result['supported_languages'].lower()=='fr':
elif result['supported_languages'][0].lower()=='fr':
fields['supported_languages'].choices = [("fr", "fr"), ("en", "en"), ("de", "de")]
else:
fields['supported_languages'].choices = [("de", "de"),("fr", "fr"), ("en", "en")]
fields['supported_languages'].initial = result['supported_languages']
if result['supported_currencies'].lower()=='eur':
if result['supported_currencies'][0].lower()=='eur':
fields['supported_currencies'].choices = [("EUR", "EUR"), ("MXN", "MXN"), ("USD", "USD")]
elif result['supported_currencies'].lower()=='mxn':
elif result['supported_currencies'][0].lower()=='mxn':
fields['supported_currencies'].choices = [("MXN", "MXN"), ("EUR", "EUR"), ("USD", "USD")]
else:
fields['supported_currencies'].choices = [("USD", "USD"),("MXN", "MXN"), ("EUR", "EUR")]
fields['supported_currencies'].initial = result['supported_currencies']
if result['notes'].lower()=='string1':
if result['notes'][0].lower()=='string1':
fields['notes'].choices = [("String1", "String1"),("String2", "String2")]
else:
fields['notes'].choices = [("String2", "String2"),("String1", "String1")]
fields['notes'].initial = result['notes']
if result['location_categories'].lower()=='atbi':
if result['location_categories'][0].lower()=='atbi':
fields['location_categories'].choices = [("ATBI", "ATBI"),("ATBE", "ATBE")]
else:
fields['location_categories'].choices = [("ATBE", "ATBE"),("ATBI", "ATBI")]
@ -309,48 +309,76 @@ class UpdateAtmsView(LoginRequiredMixin, FormView):
data = form.cleaned_data
urlpath = '/banks/{}/atms/{}'.format(data["bank_id"],data["atm_id"])
payload = {
#"id": data["atm_id"],
"id": data["atm_id"],
"bank_id": data["bank_id"],
"name": data["name"],
"address": json.loads(data['address']),
"location": {
"latitude": float(data["location_latitude"]),
"longitude": float(data["location_longitude"])
"latitude": float(data["location_latitude"]) if data["location_latitude"] is not None else 37.0,
"longitude": float(data["location_longitude"]) if data["location_longitude"] is not None else 110.0
},
"meta": {
"license": {
"id": data["meta_license_id"],
"name": data["meta_license_name"]
"id": "ODbL-1.0",
"name": data["meta_license_name"] if data["meta_license_name"]!="" else "license name"
}
},
"has_deposit_capability": data["has_deposit_capability"],
"accessibility_features": data["accessibility_features"],
"minimum_withdrawal": data["minimum_withdrawal"],
"branch_identification": data["branch_identification"],
"site_identification": data["site_identification"],
"site_name": data["site_name"],
"cash_withdrawal_national_fee": data["cash_withdrawal_national_fee"],
"cash_withdrawal_international_fee": data["cash_withdrawal_international_fee"],
"balance_inquiry_fee": data["balance_inquiry_fee"],
"services": data["services"],
"more_info": data["more_info"],
"located_at": data["located_at"],
"phone_number": data["phone_number"],
"supported_languages": data["supported_languages"],
"supported_currencies": data["supported_currencies"],
"notes": data["notes"],
"location_categories": data["location_categories"]
"monday": {
"opening_time": "10:00",
"closing_time": "18:00"
},
"tuesday": {
"opening_time": "10:00",
"closing_time": "18:00"
},
"wednesday": {
"opening_time": "10:00",
"closing_time": "18:00"
},
"thursday": {
"opening_time": "10:00",
"closing_time": "18:00"
},
"friday": {
"opening_time": "10:00",
"closing_time": "18:00"
},
"saturday": {
"opening_time": "10:00",
"closing_time": "18:00"
},
"sunday": {
"opening_time": "10:00",
"closing_time": "18:00"
},
"is_accessible": data["is_accessible"] if data["is_accessible"]!="" else "false",
"located_at": data["located_at"] if data["located_at"]!="no-example-provided" else " ",
"more_info": data["more_info"] if data["more_info"]!="" else "false",
"has_deposit_capability": data["has_deposit_capability"] if data["has_deposit_capability"]!="" else "false",
"supported_languages":[data["supported_languages"]],
"services":[data["services"]],
"accessibility_features":[data["accessibility_features"]],
"supported_currencies":[data["supported_currencies"]],
"notes":[data["notes"]],
"location_categories":[data["location_categories"]],
"minimum_withdrawal": data["minimum_withdrawal"] if data["minimum_withdrawal"]!="" else "false",
"branch_identification": data["branch_identification"] if data["branch_identification"]!="" else "false",
"site_identification": data["site_identification"] if data["site_identification"]!="" else "false",
"site_name": data["site_name"] if data["site_name"]!="" else "false",
"cash_withdrawal_national_fee": data["cash_withdrawal_national_fee"] if data["cash_withdrawal_national_fee"]!="" else "false",
"cash_withdrawal_international_fee": data["cash_withdrawal_international_fee"] if data["cash_withdrawal_international_fee"]!="" else "false",
"balance_inquiry_fee": data["balance_inquiry_fee"] if data["balance_inquiry_fee"]!="" else "false",
}
try:
result = self.api.put(urlpath, payload=payload)
if 'code' in result and result['code']>=400:
error_once_only(self.request, result['message'])
messages.error(self.request, result['message'])
return super(UpdateAtmsView, self).form_invalid(form)
except APIError as err:
messages.error(self.request, err)
return super(UpdateAtmsView, self).form_invalid(form)
except:
messages.error(self.request, "Unknown Error")
except Exception as e:
messages.error(self.request, e)
return super(UpdateAtmsView, self).form_invalid(form)
msg = 'Atm {} for Bank {} has been created successfully!'.format( # noqa
data["atm_id"], data["bank_id"])

View File

@ -8,7 +8,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="An application consuming the Open Bank Project API to manage consumers, users, customers, metrics and config">
<meta name="author" content="TESOBE, Sebastian Henschel">
<title>{% block page_title %}API Manager{% endblock page_title %}</title>
<title>{% block page_title %} {% trans "API Manager" %}{% endblock page_title %}</title>
<link rel="icon" type="image/png" href="{% static 'img/favicon.ico' %}" />
<link href="{% static 'css/bootstrap.min.css' %}" rel="stylesheet">
<link href="{% static 'css/base.css' %}" rel="stylesheet">
@ -122,6 +122,15 @@
<div class="container" id="body-container">
{% block content %}{% endblock content %}
<div class="footer-content-wrapper" data-lift="WebUI.homePage">
<span>Language </span>
<span> | </span>
<a id="uk" href="/en" >EN</a>
<span> | </span>
<a id="es" href="/es" >ES</a>
<span> | </span>
<a id="fr" href="/fr" >FR</a>
</div>
</div>
<footer>

View File

@ -7,7 +7,7 @@
<!--<h1>Welcome to API Manager</h1>-->
<div class="well" id="intro">
<p>
This app gives you access to management functionality for the sandbox at <a href="{{ API_HOST }}">{{ API_HOST }}</a>. You have to <a href="{{ API_HOST }}/user_mgt/sign_up" title="Register at {{ API_HOST }}">register</a> an account before being able to proceed. The logged-in user needs to have specific roles granted to use the functionality.
{% trans "This app gives you access to management functionality for the sandbox at" %} <a href="{{ API_HOST }}">{{ API_HOST }}</a>. {% trans "You have to" %}<a href="{{ API_HOST }}/user_mgt/sign_up" title="Register at {{ API_HOST }}">{% trans "register" %}</a> {% trans "an account before being able to proceed. The logged-in user needs to have specific roles granted to use the functionality." %}
</p>
</div>

View File

@ -234,7 +234,6 @@ class UpdateBranchesView(LoginRequiredMixin, FormView):
urlpath = "/banks/{}/branches/{}".format(self.kwargs['bank_id'], self.kwargs['branch_id'])
try:
fields['bank_id'].choices = self.api.get_bank_id_choices()
except APIError as err:
messages.error(self.request, err)
except:
@ -265,9 +264,7 @@ class UpdateBranchesView(LoginRequiredMixin, FormView):
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/{}/branches/{}'.format(data["bank_id"], data["branch_id"])

View File

@ -1,3 +1,4 @@
<a href="?app_type=Web&time={{ request.GET.time }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_app_type_Web %} active{% endif %}">Web</a>
<a href="?app_type=Mobile&time={{ request.GET.time }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_app_type_Mobile %} active{% endif %}">Mobile</a>
<a href="?app_type=All&time={{ request.GET.time }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_app_type_all %} active{% endif %}">All</a>
{% load i18n %}
<a href="?app_type=Web&time={{ request.GET.time }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_app_type_Web %} active{% endif %}">{% trans "Web" %}</a>
<a href="?app_type=Mobile&time={{ request.GET.time }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_app_type_Mobile %} active{% endif %}">{% trans "Mobile" %}</a>
<a href="?app_type=All&time={{ request.GET.time }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_app_type_all %} active{% endif %}">{% trans "All" %}</a>

View File

@ -1,3 +1,4 @@
<a href="?enabled=true&app_type={{ request.GET.app_type }}&time={{ request.GET.time }}" class="btn btn-default{% if active_enabled_true %} active{% endif %}">Enabled</a>
<a href="?enabled=false&app_type={{ request.GET.app_type }}&time={{ request.GET.time }}" class="btn btn-default{% if active_enabled_false %} active{% endif %}">Disabled</a>
<a href="?enabled=All&app_type={{ request.GET.app_type }}&time={{ request.GET.time }}" class="btn btn-default{% if active_enabled_all %} active{% endif %}">All</a>
{% load i18n %}
<a href="?enabled=true&app_type={{ request.GET.app_type }}&time={{ request.GET.time }}" class="btn btn-default{% if active_enabled_true %} active{% endif %}">{% trans "Enabled" %}</a>
<a href="?enabled=false&app_type={{ request.GET.app_type }}&time={{ request.GET.time }}" class="btn btn-default{% if active_enabled_false %} active{% endif %}">{% trans "Disabled" %}</a>
<a href="?enabled=All&app_type={{ request.GET.app_type }}&time={{ request.GET.time }}" class="btn btn-default{% if active_enabled_all %} active{% endif %}">{% trans "All" %}</a>

View File

@ -1,6 +1,7 @@
<a href="?time=hour&app_type={{ request.GET.app_type }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_time_hour %} active{% endif %}">Last Hour</a>
<a href="?time=day&app_type={{ request.GET.app_type }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_time_day %} active{% endif %}">Last Day</a>
<a href="?time=week&app_type={{ request.GET.app_type }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_time_week %} active{% endif %}">Last Week</a>
<a href="?time=month&app_type={{ request.GET.app_type }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_time_month %} active{% endif %}">Last Month</a>
<a href="?time=year&app_type={{ request.GET.app_type }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_time_year %} active{% endif %}">Last Year</a>
<a href="?time=All&app_type={{ request.GET.app_type }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_time_all %} active{% endif %}">All</a>
{% load i18n %}
<a href="?time=hour&app_type={{ request.GET.app_type }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_time_hour %} active{% endif %}">{% trans "Last Hour" %}</a>
<a href="?time=day&app_type={{ request.GET.app_type }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_time_day %} active{% endif %}">{% trans "Last Day" %}</a>
<a href="?time=week&app_type={{ request.GET.app_type }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_time_week %} active{% endif %}">{% trans "Last Week" %}</a>
<a href="?time=month&app_type={{ request.GET.app_type }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_time_month %} active{% endif %}">{% trans "Last Month" %}</a>
<a href="?time=year&app_type={{ request.GET.app_type }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_time_year %} active{% endif %}">{% trans "Last Year" %}</a>
<a href="?time=All&app_type={{ request.GET.app_type }}&enabled={{ request.GET.enabled }}" class="btn btn-default{% if active_time_all %} active{% endif %}">{% trans "All" %}</a>

View File

@ -1,11 +1,13 @@
{% extends 'base.html' %}
{% load i18n %}
{% load humanize static %}
{% block page_title %}{{ block.super }} / Consumers{% endblock page_title %}
{% block content %}
<div id="consumers">
<h1>Consumers</h1>
<h1>{% trans "Consumers" %}</h1>
<div class="row">
<div class="col-xs-12 col-md-6">
@ -42,21 +44,21 @@
</div>
</div>
<h4>Statistics</h4>
<h4>{% trans "Statistics" %}</h4>
<ul id="statistics">
<li>Total number of consumers: {{ statistics.consumers_num }}</li>
<li>Total number of unique developer email addresses: {{ statistics.unique_developer_email_num }}</li>
<li>Total number of unique consumer names: {{ statistics.unique_name_num }}</li>
<li>{% trans "Total number of consumers" %}: {{ statistics.consumers_num }} </li>
<li>{% trans "Total number of unique developer email addresses" %}: {{ statistics.unique_developer_email_num }}</li>
<li>{% trans "Total number of unique consumer names" %}: {{ statistics.unique_name_num }}</li>
</ul>
<div class="table-responsive">
<table class="table table-hover tablesorter" id="consumer-list" aria-describedby="consumer list">
<thead>
<th scope="col">ID</th>
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col">Created</th>
<th scope="col">Action</th>
<th scope="col">{% trans "ID" %}</th>
<th scope="col">{% trans "Name" %}</th>
<th scope="col">{% trans "Description" %}</th>
<th scope="col">{% trans "Created" %}</th>
<th scope="col">{% trans "Action" %}</th>
</thead>
<tbody>

View File

@ -1,6 +1,7 @@
<a href="?time=hour" class="btn btn-default{% if active_time_hour %} active{% endif %}">Last Hour</a>
<a href="?time=day" class="btn btn-default{% if active_time_day %} active{% endif %}">Last Day</a>
<a href="?time=week" class="btn btn-default{% if active_time_week %} active{% endif %}">Last Week</a>
<a href="?time=month" class="btn btn-default{% if active_time_month %} active{% endif %}">Last Month</a>
<a href="?time=year" class="btn btn-default{% if active_time_year %} active{% endif %}">Last Year</a>
<a href="?time=All" class="btn btn-default{% if active_time_all %} active{% endif %}">All</a>
{% load i18n %}
<a href="?time=hour" class="btn btn-default{% if active_time_hour %} active{% endif %}">{% trans "Last Hour" %}</a>
<a href="?time=day" class="btn btn-default{% if active_time_day %} active{% endif %}">{% trans "Last Day" %}</a>
<a href="?time=week" class="btn btn-default{% if active_time_week %} active{% endif %}">{% trans "Last Week" %}</a>
<a href="?time=month" class="btn btn-default{% if active_time_month %} active{% endif %}">{% trans "Last Month" %}</a>
<a href="?time=year" class="btn btn-default{% if active_time_year %} active{% endif %}">{% trans "Last Year" %}</a>
<a href="?time=All" class="btn btn-default{% if active_time_all %} active{% endif %}">{% trans "All" %}</a>

View File

@ -1,11 +1,11 @@
{% extends 'base.html' %}
{% load humanize static %}
{% load i18n %}
{% block page_title %}{{ block.super }} / Entitlement Requests {% endblock page_title %}
{% block content %}
<div id="entitlementrequests">
<h1>Entitlement Requests</h1>
<h1>{% trans "Entitlement Requests" %}</h1>
<div class="row">
<div class="col-xs-12 col-md-6">
@ -24,12 +24,12 @@
<div class="table-responsive">
<table class="table table-hover tablesorter" id="entitementrequests-list" aria-describedby="entitlement requests list">
<thead>
<th scope="col">Role Name</th>
<th scope="col">User name</th>
<th scope="col">Bank ID</th>
<th scope="col">Created</th>
<th scope="col">Action</th>
<th scope="col">Action</th>
<th scope="col">{% trans "Role Name" %}</th>
<th scope="col">{% trans "User name" %}</th>
<th scope="col">{% trans "Bank ID" %}</th>
<th scope="col">{% trans "Created" %}</th>
<th scope="col">{% trans "Action" %}</th>
<th scope="col">{% trans "Action" %}</th>
</thead>
<tbody>

View File

@ -0,0 +1,64 @@
from translate import Translator # Convert one language to another
from concurrent.futures import ThreadPoolExecutor as tpe # Multithreading
from threading import Lock # Locking Purpose
lock=Lock() # Intializing Lock
languages=['de','es','fr','hi'] # Defining languages
# This class is used for converting languages
class clsTranslate():
def translateText(self, strString, strTolang):
"""
This function translates one language into another language. It takes two
parameters
1. strString :=> String that you want to convert
2. strTolang :=> Languages(fr,hi,es etc)
"""
self.strString = strString
self.strTolang = strTolang
translator = Translator(to_lang=self.strTolang)
translation = translator.translate(self.strString)
return (str(translation))
# This is method for writing file
def writeFile(language):
print(language,"Started")
fileName=f'locale/{language}/LC_MESSAGES/django.po' # Openning a file
try:
with open(fileName,encoding='utf-8') as f: # Reading from the file
a=[i.replace("\n","") for i in f.readlines()] # Reading everyline from a file and store it into a
except Exception as e:
print(fileName, e)
b=0
for i in range(len(a)):
if 'msgid' in a[i] and a[i]!='msgid ""':
b=i
break
if b!=0:
trans=clsTranslate() # Creating object for translation class
for i in range(b-1,len(a),4):
comment,msgid,msgstr=a[i],a[i+1],a[i+2]
if msgstr == 'msgstr ""':
ms=msgid[7:len(msgid)-1]
val=trans.translateText(ms,language)
a[i+2]=f'msgstr "{val}"'
try:
lock.acquire()
with open(fileName,'w',encoding='utf-8') as f:
for i in a:
f.write(f"{i}\n")
print(language,"is completed")
lock.release()
except Exception as e:
print(e)
lock.release()
else:
print(language,"is completed")
with tpe() as e:
e.map(writeFile,languages)

View File

@ -1,39 +1,39 @@
{% extends 'base.html' %}
{% load static %}
{% load i18n %}
{% block page_title %}{{ block.super }} / {{ apiuser.username }}{% endblock page_title %}
{% block content %}
<div id="users-detail">
<h1>User {{ apiuser.username }}</h1>
<h1>{% trans "User" %} {{ apiuser.username }}</h1>
<div id="users-detail-user_id">
<strong>User ID</strong><br />
<strong>{% trans "User ID" %}</strong><br />
<span>{{ apiuser.user_id }}</span>
</div>
<div id="users-detail-email">
<strong>Email</strong><br />
<strong>{% trans "Email" %}</strong><br />
<span>{{ apiuser.email }}</span>
</div>
<div id="users-detail-provider">
<strong>Provider</strong><br />
<strong>{% trans "Provider" %}</strong><br />
<span>{{ apiuser.provider }}</span>
</div>
<div id="users-detail-provider_id">
<strong>Provider ID</strong><br />
<strong>{% trans "Provider ID" %}</strong><br />
<span>{{ apiuser.provider_id }}</span>
</div>
<div id="users-detail-deleted">
<strong>Deleted</strong><br />
<strong>{% trans "Deleted" %}</strong><br />
<span>{{ apiuser.is_deleted }}</span>
</div>
<div id="users-detail-locked">
<strong>Locked</strong><br />
<strong>{% trans "Locked" %}</strong><br />
<span>{{ apiuser.is_locked }}</span>
</div>
@ -44,11 +44,11 @@
{% if apiuser.is_deleted %}
{% else %}
<button type="submit" class="btn btn-primary btn-red" value ="Delete" name ="Delete">Delete User</button>
<button type="submit" class="btn btn-primary btn-red" value ="Delete" name ="Delete">{% trans "Delete User" %}</button>
{% endif %}
{% if apiuser.is_locked %}
<button type="submit" class="btn btn-primary btn-green" value ="Unlock" name ="Unlock">Unlock User</button>
<button type="submit" class="btn btn-primary btn-green" value ="Unlock" name ="Unlock">{% trans "Unlock User" %}</button>
{% else %}
{% endif %}
@ -59,7 +59,7 @@
{% if apiuser.user_id %}
<div id="users-detail-entitlements">
<h2>Add Entitlement</h2>
<h2>{% trans "Add Entitlement" %}</h2>
<form class="form" action="" method="post">
{% csrf_token %}
{{ form.user_id }}
@ -80,24 +80,24 @@
<div class="row">
<div class="col-xs-12 hidden-sm hidden-md hidden-lg">
<div class="form-group">
<button type="submit" class="btn btn-primary btn-green form-control">Add</button>
<button type="submit" class="btn btn-primary btn-green form-control">{% trans "Add" %}</button>
</div>
</div>
<div class="col-sm-12 hidden-xs">
<div class="form-group">
<button type="submit" class="btn btn-primary btn-green">Add</button>
<button type="submit" class="btn btn-primary btn-green">{% trans "Add" %}</button>
</div>
</div>
</div>
</form>
<h2>Entitlements</h2>
<h2>{% trans "Entitlements" %}</h2>
<div class="table-responsive">
<table class="table table-striped" aria-describedby="uses table">
<thead>
<th scope="col">Role name</th>
<th scope="col">Bank Id</th>
<th scope="col">Action</th>
<th scope="col">{% trans "Role name" %}</th>
<th scope="col">{% trans "Bank Id" %}</th>
<th scope="col">{% trans "Action" %}</th>
</thead>
<tbody>
{% for entitlement in apiuser.entitlements.list %}
@ -111,7 +111,7 @@
{% csrf_token %}
<input type="hidden" name="next" value="{{ request.path }}" />
<input type="hidden" name="role_name" value="{{ entitlement.role_name }}" />
<button type="submit" class="btn btn-primary btn-red">Delete</button>
<button type="submit" class="btn btn-primary btn-red">{% trans "Delete" %}</button>
</form>
{% endif %}
</td>

View File

@ -1,14 +1,14 @@
{% extends 'base.html' %}
{% load static %}
{% load i18n %}
{% block page_title %}{{ block.super }} / Users{% endblock page_title %}
{% block content %}
<div id="users">
<h1>Users</h1>
<h1>{% trans "Users" %}</h1>
<div id="users-filters">
<h4>Filters</h4>
<h4>{% trans "Filters" %}</h4>
<div class="hidden-xs">
{% include "users/includes/filter_role.html" %}
{% include "users/includes/filter_email.html" %}
@ -41,23 +41,23 @@
<div class="row">
<div class="col-xs-12">
<h4>Pagination</h4>
<h4>{% trans "Pagination" %}</h4>
{% include "users/includes/filter_pagination.html" %}
</div>
</div>
<h4>Statistics</h4>
<h4>{% trans "Statistics" %}</h4>
<ul id="statistics">
<li>Total number of users: {{ statistics.users_num }}
<li>{% trans "Total number of users" %}: {{ statistics.users_num }}
</ul>
<div class="table-responsive">
<table class="table table-hover tablesorter" id="users-list" aria-describedby="users list">
<thead>
<th scope="col">User Id</th>
<th scope="col">Username</th>
<th scope="col">Email</th>
<th scope="col">Action</th>
<th scope="col">{% trans "User Id" %}</th>
<th scope="col">{% trans "Username" %}</th>
<th scope="col">{% trans "Email" %}</th>
<th scope="col">{% trans "Action" %}</th>
</thead>
<tbody>
{% for user in users %}

View File

@ -1,12 +1,11 @@
{% extends 'base.html' %}
{% load static %}
{% load i18n %}
{% block page_title %}{{ block.super }} / Users{% endblock page_title %}
{% block content %}
<div id="user-invitation">
<h1>Invite Developer</h1>
<h1>{% trans "Invite Developer" %}</h1>
<form action="{% url 'my-user-invitation' %}" method="post">
{% csrf_token %}
@ -67,12 +66,12 @@
<div class="table-responsive">
<table class="table table-hover tablesorter" id="invitation-list" aria-describedby="invitation list">
<thead>
<th scope="col">First Name</th>
<th scope="col">Last Name</th>
<th scope="col">Email</th>
<th scope="col">company</th>
<th scope="col">country</th>
<th scope="col">status</th>
<th scope="col">{% trans "First Name" %}</th>
<th scope="col">{% trans "Last Name" %}</th>
<th scope="col">{% trans "Email" %}</th>
<th scope="col">{% trans "company" %}</th>
<th scope="col">{% trans "country" %}</th>
<th scope="col">{% trans "status" %}</th>
</thead>
<tbody>
{% for invitation in invitations %}