Merge branch 'develop' into bugfix/sonarcloud

This commit is contained in:
mark-tesobe 2022-12-23 01:23:59 +08:00 committed by GitHub
commit 27f62384d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
41 changed files with 214 additions and 197 deletions

View File

@ -137,6 +137,13 @@ DATABASE = {
"PORT": "5432",
}
}
# This is an optional setting.
# CALLBACK_BASE_URL can be used to explicitly set the redirect base url that API Manager uses during OAuth authentication.
# If CALLBACK_BASE_URL is not set, API Manager (this applicaiton) in the function "get_redirect_url" will use the Django HTTP_HOST environ field (see here: https://docs.djangoproject.com/en/4.1/ref/request-response/). Note, this might be modified by NGINX via the directive: proxy_set_header Host $http_host;
# In order to be explicit you can set it here e.g.
# CALLBACK_BASE_URL="https://apimanager.example.com"
```

View File

@ -1,25 +1,25 @@
{% extends 'base.html' %} {% load static %} {% load i18n %}
{% block page_title %} {{ block.super }} / {% trans "Customer List" %}{% endblock page_title %} {% block content %}
<div id="apicollectionlist">
<h1>{% trans "My API Collection List" %}</h1>
<h1>{% trans " All API Collections" %}</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-apicollection' %}';">
</form>
<div class="table-responsive">
<table class="table table-hover tablesorter" id="apicollectionlist" aria-describedby="apicollectionlist list">
<thead>
<th scope="col">{% trans "API Collection Id" %}</th>
<th scope="col">{% trans "User Id" %}</th>
<th scope="col">{% trans "API Collection" %}</th>
<th scope="col">{% trans "User Name" %}</th>
<th scope="col">{% trans "API Collection Name" %}</th>
<th scope="col">{% trans "More info" %}</th>
</thead>
<tbody>
{% for apicollection in apicollections_list %}
{% url 'apicollection_update' apicollection.api_collection_id apicollection.user_id as url_apicollection_update %}
{% url 'my-api-collection-detail' apicollection.api_collection_id as url_collection_detail %}
<tr id="{{ apicollection.api_collection_id }}">
<td>{{ apicollection.api_collection_id }}</td>
<td>{{ apicollection.user_id }}</td>
<td>{{ apicollection.username }}</td>
<td>{{ apicollection.api_collection_name }}</td>
<td>
<div class="popuptext">
@ -32,7 +32,7 @@
</ul>
</div>
</td>
<td><a href="{{ url_apicollection_update }}" class="btn btn-primary">{% trans "View" %}</a></td>
<td><a type= "button" class="btn btn-primary" href= "{{ url_collection_detail }}">{% trans "View" %}</a></td>
</tr>
{% endfor %}
</tbody>

View File

@ -23,13 +23,21 @@ class ApiCollectionListView(IndexView, LoginRequiredMixin, FormView ):
success_url = '/apicollections/list'
def get_apicollections(self, context):
"""Get All user """
api = API(self.request.session.get('obp'))
try:
apicollections_list = []
urlpath = '/my/api-collections'
result = api.get(urlpath)
if 'api_collections' in result:
apicollections_list.extend(result['api_collections'])
#TODO: NOTE- THIS RETURNS ALL USER. THIS IS A POTENTIAL PERFORMANCE ISSUE. WE NEED ENDPOINT FOR COLLECTION.
#Endpoint will return users.
get_all_users_url_path = '/users'
user = api.get(get_all_users_url_path)
for i in user["users"]:
# Returns the APIs collections for a user.
api_collections_for_user_url_path = '/users/{}/api-collections'.format(i["user_id"])
api_collections_for_user = api.get(api_collections_for_user_url_path)
if 'api_collections' in api_collections_for_user:
apicollections_list.extend(api_collections_for_user['api_collections'])
except APIError as err:
messages.error(self.request, err)
return []
@ -40,8 +48,16 @@ class ApiCollectionListView(IndexView, LoginRequiredMixin, FormView ):
return apicollections_list
def get_context_data(self, **kwargs):
api = API(self.request.session.get('obp'))
context = super(IndexView, self).get_context_data(**kwargs)
apicollections_list = self.get_apicollections(context)
try:
for final_collection_list in apicollections_list:
url_path = "/users/user_id/{}".format(final_collection_list["user_id"])
result = api.get(url_path)
final_collection_list["username"] = result["username"]
except Exception as e:
messages.error(self.request, "Unknown Error {}".format(str(e)))
context.update({
'apicollections_list': apicollections_list,
})

View File

@ -1,11 +1,10 @@
$(document).ready(function($) {
$('.runner button.forSave').click(function(e) {
e.preventDefault();
var t = $(this);
var runner = t.parent().parent().parent();
var api_collection_name = $(runner).find('.api_collection_name').val();
var api_collection_is_sharable = $(runner).find('.api_collection_is_sharable').val();
var api_collection_description = $(runner).find('.api_collection_description').val();
let runner = $(this).parent().parent().parent();
let api_collection_name = $(runner).find('.api_collection_name').val();
let api_collection_is_sharable = $(runner).find('.api_collection_is_sharable').val();
let api_collection_description = $(runner).find('.api_collection_description').val();
$('.runner button.forSave').attr("disabled","disabled");
$('.runner button.forDelete').attr("disabled","disabled");
@ -20,9 +19,8 @@ $(document).ready(function($) {
$('.runner button.forDelete').click(function(e) {
e.preventDefault();
var t = $(this);
var runner = t.parent().parent().parent();
var api_collection_id = $(runner).find('.api_collection_id').html();
let runner = $(this).parent().parent().parent();
let api_collection_id = $(runner).find('.api_collection_id').html();
$('.runner button.forSave').attr("disabled","disabled");
$('.runner button.forDelete').attr("disabled","disabled");
$.post('delete/apicollection', {

View File

@ -26,20 +26,31 @@
<div class="row">
<div class="col-xs-12 col-sm-2">
<div class="form-group" cols="1" rows="1">
<a class="api_collection_id" href="{{ url_collection_detail }}">{{ api_collection.api_collection_id }}</a></div>
{% if api_collection.api_collection_id %}
<a class="api_collection_id btn btn-primary" onclick="api_explorer_url_locale('{{api_collection.collection_on_api_explorer_url}}')">Try It</a>
{% endif %}
</div>
</div>
{% if api_collection.api_collection_id %}
<div class="col-xs-12 col-sm-2">
<div class="form-group" cols="1" rows="1">
<div>{{ api_collection.api_collection_name }}</div></div>
<div>
<input class="api_collection_is_sharable form-control" value="{{ api_collection.api_collection_name }}">
</div>
</div>
</div>
<div class="col-xs-12 col-sm-2">
<div class="form-group" cols="1" rows="1">
<div>{{ api_collection.is_sharable }}</div>
<div>
<select class="api_collection_is_sharable form-control">
<option value="{{ api_collection.is_sharable }}" selected="selected" hidden>{{ api_collection.is_sharable }}</option>
<option value="True">True</option>
<option value="False">False</option>
</select></div>
</div>
</div>
<div class="col-xs-12 col-sm-4">
<div cols="40" rows="1" class="form-control">{{api_collection.description}}</div>
<div class="col-xs-6 col-sm-3">
<textarea cols="40" rows="1" class="form-control api_collection_method_body_update" style="margin: 5px -2px 5px 0px; height: 138px; width: 100%;">{{api_collection.description}}</textarea>
</div>
{% else %}
<div class="col-xs-12 col-sm-2">
@ -55,19 +66,29 @@
</select>
</div>
</div>
<div class="col-xs-12 col-sm-4">
<textarea cols="40" rows="1" class="form-control api_collection_description">{% trans "Describe the purpose of the collection" %}</textarea>
<div class="col-xs-6 col-sm-3">
<textarea cols="40" rows="1" class="form-control api_collection_description">{% trans "Enter the Description" %}</textarea>
</div>
{% endif %}
{% if forloop.counter0 == 0 %}
<div class="col-sm-12 col-sm-2">
<div class="col-sm-6 col-sm-2">
<div class="form-group">
<button class="btn btn-primary btn-green forSave">{% trans "Create" %}</button>
</div>
</div>
{% endif %}
{% if forloop.counter0 > 0 %}
<div class="col-sm-12 col-sm-2">
<div class="col-sm-3 col-sm-1">
<div class="form-group">
<a type= "button" class="btn btn-primary" href="{{ url_collection_detail }}">{% trans "Edit" %}</a>
</div>
</div>
<!--<div class="col-sm-3 col-sm-1">
<div class="form-group">
<button class="btn btn-primary forUpdate">{% trans "Update" %}</button>
</div>
</div>-->
<div class="col-sm-3 col-sm-1">
<div class="form-group">
<button class="btn btn-primary btn-red forDelete">{% trans "Delete" %}</button>
</div>
@ -81,5 +102,16 @@
{% block extrajs %}
<script>
function api_explorer_url_locale(collection_on_api_explorer_url) {
var currentURL = window.location.href.split("/");
if (currentURL[3] == "en") {
location.href = collection_on_api_explorer_url + "&locale=en_GB";
}
else {
location.href = collection_on_api_explorer_url + "&locale=es_ES";
}
}
</script>
<script type="text/javascript" src="{% static 'apicollections/js/apicollections.js' %}"></script>
{% endblock extrajs %}

View File

@ -13,7 +13,7 @@ from django.urls import reverse, reverse_lazy
from base.utils import exception_handle, error_once_only
from .forms import ApiCollectionsForm, ApiCollectionEndpointsForm
from django.views.decorators.csrf import csrf_exempt
from django.conf import settings
class IndexView(LoginRequiredMixin, FormView):
"""Index view for API Collection"""
@ -32,6 +32,8 @@ class IndexView(LoginRequiredMixin, FormView):
error_once_only(self.request, response['message'])
else:
api_collections=response['api_collections']
for locale in api_collections:
locale["collection_on_api_explorer_url"] = f"{settings.API_EXPLORER}/?api-collection-id={locale['api_collection_id']}"
except APIError as err:
messages.error(self.request, err)
except BaseException as err:
@ -71,8 +73,8 @@ class DetailView(LoginRequiredMixin, FormView):
except APIError as err:
messages.error(self.request, err)
return super(DetailView, self).form_invalid(form)
except:
messages.error(self.request, 'Unknown Error')
except BaseException as err:
error_once_only(self.request, (Exception("Unknown Error. Details:" + str(err))))
return super(DetailView, self).form_invalid(form)
if 'code' in api_collection_endpoint and api_collection_endpoint['code']>=400:
messages.error(self.request, api_collection_endpoint['message'])
@ -113,6 +115,8 @@ class DeleteCollectionEndpointView(LoginRequiredMixin, FormView):
"""Deletes api collection endpoint from API"""
api = API(self.request.session.get('obp'))
try:
get_api_collection_by_id_url = "/my/api-collections/{}".format(kwargs["api_collection_id"])
result = api.get(get_api_collection_by_id_url)
urlpath = '/my/api-collections/{}/api-collection-endpoints/{}'.format(kwargs['api_collection_name'],kwargs['operation_id'])
result = api.delete(urlpath)
if result is not None and 'code' in result and result['code']>=400:
@ -122,8 +126,8 @@ class DeleteCollectionEndpointView(LoginRequiredMixin, FormView):
messages.success(request, msg)
except APIError as err:
messages.error(request, err)
except:
messages.error(self.request, 'Unknown Error')
except BaseException as err:
messages.error(self.request, 'Unknown Error', err)
redirect_url = reverse('my-api-collection-detail',kwargs={"api_collection_id":kwargs['api_collection_id']})
return HttpResponseRedirect(redirect_url)
@ -140,6 +144,21 @@ def apicollections_save(request):
result = api.post(urlpath, payload = payload)
return result
@exception_handle
@csrf_exempt
def connectormethod_update(request):
connector_method_id = request.POST.get('api_collection_id').strip()
urlpath = '/management/api-collection/{}'.format(connector_method_id) #TODO : Wainting for URL
api = API(request.session.get('obp'))
#Update Endpoint Payload define
payload = {
'api_collection_is_sharable': request.POST.get('api_collection_is_sharable'),
'method_body': request.POST.get('api_collection_method_body_update').strip()
}
result = api.put(urlpath, payload=payload)
return result
@exception_handle
@csrf_exempt

View File

@ -253,6 +253,7 @@ API_MANAGER_DATE_FORMAT= '%Y-%m-%d'
API_HOST = 'http://127.0.0.1:8080'
API_EXPLORER = 'http://127.0.0.1:8082'
# Only override this if you have a separate portal instance
API_PORTAL = API_HOST
API_BASE_PATH = '/obp/v'
@ -301,13 +302,14 @@ LOGO_URL = 'https://static.openbankproject.com/images/OBP/favicon.png'
OVERRIDE_CSS_URL = None
VERIFY = True
CALLBACK_BASE_URL = ""
# Local settings can override anything in here
# Local settings can replace any value ABOVE
try:
from apimanager.local_settings import * # noqa
except ImportError:
pass
# EVERYTHING BELOW HERE WILL NOT BE OVERWRITTEN BY LOCALSETTINGS!
# EVERYTHING BELOW HERE WILL *NOT* BE OVERWRITTEN BY LOCALSETTINGS!
# DO NOT TRY TO DO SO YOU WILL BE IGNORED!
# Settings here might use parts overwritten in local settings

View File

@ -54,7 +54,7 @@ urlpatterns += i18n_patterns(
url(r'^connectormethod/', include('connectormethod.urls')),
url(r'^dynamicendpoints/', include('dynamicendpoints.urls')),
url(r'^apicollections/', include('apicollections.urls')),
url(r'^apicollections/list', include('apicollectionlist.urls')),
url(r'^apicollections-list', include('apicollectionlist.urls')),
)
#prefix_default_language=False,
#)+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

View File

@ -208,13 +208,17 @@ table.tablesorter thead tr .headerSortDown, table.tablesorter thead tr .headerSo
}
.language-select {
text-decoration: none;
color:#fff;
margin-left:5rem;
text-decoration: none !important;
}
#uk {
cursor:pointer;
}
#es {
cursor:pointer;
}1
}
.language_underline_format > a > span:hover
{
text-decoration: underline;
font-weight: bold !important;
}

View File

@ -2,7 +2,7 @@ $(document).ready(function($) {
$('table.tablesorter').tablesorter();
$('#authentication-select').change(function() {
$('.authentication-method').hide();
var method = $(this).val();
let method = $(this).val();
$(`#authenticate-${method}`).show();
});
});

View File

@ -14,7 +14,6 @@
<link href="{% static 'css/base.css' %}" rel="stylesheet">
<link href="{% static 'css/jsoneditor.min.css' %}" rel="stylesheet">
<link href="{% static 'css/obpjsoneditor.css' %}" rel="stylesheet">
<!--<link href="{{ override_css_url }}" rel="stylesheet">-->
{% block extracss %}{% endblock extracss %}
</head>
@ -63,7 +62,7 @@
<li class="dropdown{% if customers_create_url in request.path %} active{% endif %}">
<a href="#" data-toggle="dropdown" class="dropdown-toggle">{% trans "Resources" %}</a>
<ul class="dropdown-menu">
<li {% if system_view_url in request.path %} class="active" {% endif %}><a href="{{ system_view_url }}">{% trans "System View" %}</a></li>
<li {% if system_view_url in request.path %} class="active" {% endif %}><a href="{{ system_view_url }}">{% trans "System Views" %}</a></li>
<hr class="dropdown-hr">
<li {% if accounts_create_url in request.path %} class="active" {% endif %}><a href="{{ accounts_create_url }}">{% trans "Account Create" %}</a></li>
<li {% if accounts_list_url in request.path %} class="active" {% endif %}><a href="{{ accounts_list_url }}">{% trans "Account List" %}</a></li>
@ -92,7 +91,8 @@
</li>
<hr class="dropdown-hr">
<li {% if api_collections_index_url in request.path %} class="active" {% endif %}><a href="{{ api_collections_index_url }}">{% trans "My API Collections" %}</a></li>
<li {% if api_collections_list_url in request.path %} class="active" {% endif %}><a href="{{ api_collections_list_url }}">{% trans "My API Collection List" %}</a></li>
<hr class="dropdown-hr">
<li {% if api_collections_list_url in request.path %} class="active" {% endif %}><a href="{{ api_collections_list_url }}">{% trans "All API Collections" %}</a></li>
</ul>
</li>
{% if SHOW_API_TESTER %}
@ -100,19 +100,16 @@
<a href="{{ API_TESTER_URL }}">{% trans "API Tester" %}</a>
</li>
{% endif %}
<!--<ul class="nav navbar-nav navbar-right" style="padding-top:13px; margin-left:12rem">-->
<li>
{% if user.is_authenticated %}
<p class="navbar-right button-select"><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 class="language-select"><a style="color:#fff;">Language
<li class="language-select language_underline_format"><a style="color:#fff; text-decoration: none !important;">Language
<span id="uk">EN</span>
|
<span id="es">ES</span></a></li>
</ul>
<!--/.nav-collapse -->
</div>
</div>
</nav>

View File

@ -46,10 +46,6 @@
<label for="password">Password:</label>
{{ directlogin_form.password }}
</div>
<!--<div class="form-group"style="visibility:hidden">
<label for="consumer-key">Consumer Key:</label>
{{ directlogin_form.consumer_key }}
</div>-->
<button class="btn btn-primary">Login</button>
</form>
</div>

View File

@ -24,7 +24,6 @@ def get_cache_key_for_current_call(request, urlpath):
"""we will generate the cache key by login username+urlpath
url path may contain lots of special characters, here we use the hash method first.
"""
#TODO, we need the obp user.provide there.
return context_processors.api_username(request).get('API_USERNAME') + str(hash(urlpath))

View File

@ -1,11 +1,10 @@
$(document).ready(function($) {
$('.runner button.forSave').click(function(e) {
e.preventDefault();
var t = $(this);
var runner = t.parent().parent().parent();
var connector_method_name = $(runner).find('.connector_method_name').val();
var connector_method_programming_lang = $(runner).find('.connector_method_programming_lang').val();
var connector_method_body = $(runner).find('.connector_method_body').val();
let runner = $(this).parent().parent().parent();
let connector_method_name = $(runner).find('.connector_method_name').val();
let connector_method_programming_lang = $(runner).find('.connector_method_programming_lang').val();
let connector_method_body = $(runner).find('.connector_method_body').val();
$('.runner button.forSave').attr("disabled", "disabled");
$('.runner button.forDelete').attr("disabled", "disabled");
@ -20,11 +19,10 @@ $(document).ready(function($) {
$('.runner button.forUpdate').click(function(e) {
e.preventDefault();
var t = $(this);
var runner = t.parent().parent().parent();
var connector_method_id = $(runner).find('.connector_method_id').html();
var connector_method_programming_lang_update = $(runner).find('.connector_method_programming_lang_update').val();
var connector_method_body_update = $(runner).find('.connector_method_body_update').val();
let runner = $(this).parent().parent().parent();
let connector_method_id = $(runner).find('.connector_method_id').html();
let connector_method_programming_lang_update = $(runner).find('.connector_method_programming_lang_update').val();
let connector_method_body_update = $(runner).find('.connector_method_body_update').val();
$('.runner button.forSave').attr("disabled", "disabled");
$('.runner button.forUpdate').attr("disabled", "disabled");

View File

@ -73,6 +73,5 @@ def connectormethod_update(request):
'programming_lang': request.POST.get('connector_method_programming_lang_update'),
'method_body': request.POST.get('connector_method_body_update').strip()
}
result = HttpResponse(content_type = 'application/json')
result = api.put(urlpath, payload=payload)
return result

View File

@ -16,9 +16,6 @@ from base.filters import BaseFilter, FilterTime
from .forms import ApiConsumersForm
# import logging
# logger = logging.getLogger(__name__)
class FilterAppType(BaseFilter):
"""Filter consumers by application type"""
@ -129,7 +126,6 @@ class DetailView(LoginRequiredMixin, FormView):
'per_week_call_limit': data['per_week_call_limit'],
'per_month_call_limit': data['per_month_call_limit']
}
user = self.api.put(urlpath, payload=payload)
except APIError as err:
messages.error(self.request, err)
return super(DetailView, self).form_invalid(api_consumers_form)
@ -191,8 +187,8 @@ class EnableDisableView(LoginRequiredMixin, RedirectView):
messages.success(self.request, self.success)
except APIError as err:
messages.error(self.request, err)
except:
messages.error(self.request, "Unknown")
except APIError as err:
messages.error(self.request, err)
urlpath = self.request.POST.get('next', reverse('consumers-index'))
query = self.request.GET.urlencode()

View File

@ -26,9 +26,7 @@ class CustomerListView(CreateView, LoginRequiredMixin, FormView ):
try:
self.bankids = get_banks(self.request)
customers_list = []
#for bank_id in self.bankids:
urlpath = '/customers'
#urlpath = 'http://127.0.0.1:8080/obp/v4.0.0/my/customers'
result = api.get(urlpath)
if 'customers' in result:
customers_list.extend(result['customers'])

View File

@ -9,12 +9,12 @@ $(document).ready(function($) {
//and will use the data from click `save` button.
var json_editors = []
$('.parameters').click(function() {
var runner = $(this).parent().parent().parent();
var json_editor_id= $(runner).find('.jsoneditor_div')[0].id;
var json_editor_number = json_editor_id.replace("jsoneditor","");
var container = $("#"+json_editor_id);
parameters = JSON.parse($(runner).find('textarea[name="parameters"]').text());
var jsoneditor_div = $(runner).find('.jsoneditor_div');
let runner = $(this).parent().parent().parent();
let json_editor_id= $(runner).find('.jsoneditor_div')[0].id;
let json_editor_number = json_editor_id.replace("jsoneditor","");
let container = $("#"+json_editor_id);
let parameters = JSON.parse($(runner).find('textarea[name="parameters"]').text());
let jsoneditor_div = $(runner).find('.jsoneditor_div');
//make sure only create one jsoneditor_div block
if(!(jsoneditor_div.css("display") ==="block")){
json_editors[json_editor_number] = new JSONEditor(container[0], options, parameters);
@ -27,11 +27,10 @@ $(document).ready(function($) {
});
$('.runner button.forSave').click(function() {
var t = $(this);
var runner = $(this).parent().parent().parent();
var jsoneditor_id= $(runner).find('.jsoneditor_div')[0].id
var json_editor_number = jsoneditor_id.replace("jsoneditor","")
parameters_Json_editor = JSON.stringify(json_editors[json_editor_number].get());
let runner = $(this).parent().parent().parent();
let jsoneditor_id= $(runner).find('.jsoneditor_div')[0].id
let json_editor_number = jsoneditor_id.replace("jsoneditor","")
let parameters_Json_editor = JSON.stringify(json_editors[json_editor_number].get());
console.log("parameters_Json_editor:"+parameters_Json_editor)
$('.runner button.forSave').attr("disabled","disabled");
$('.runner button.forDelete').attr("disabled","disabled");
@ -45,9 +44,8 @@ $(document).ready(function($) {
});
$('.runner button.forDelete').click(function() {
var t = $(this);
var runner = $(this).parent().parent().parent();
dynamic_endpoint_id = $(runner).find('.dynamic_endpoint_id').text();
let runner = $(this).parent().parent().parent();
let dynamic_endpoint_id = $(runner).find('.dynamic_endpoint_id').text();
$('.runner button.forSave').attr("disabled","disabled");
$('.runner button.forDelete').attr("disabled","disabled");
$.post('dynamicendpoints/delete/dynamicendpoint', {

View File

@ -4,6 +4,7 @@ Views of config app
"""
import json
from django.contrib import messages
from django.contrib.auth.mixins import LoginRequiredMixin
from django.views.generic import FormView
from obp.api import API, APIError
@ -273,10 +274,10 @@ class IndexView(LoginRequiredMixin, FormView):
@exception_handle
@csrf_exempt
def dynamicendpoints_save(request):
parameters_Json_editor = request.POST.get('parameters_Json_editor')
parameters_Json_editor_dynamic = request.POST.get('parameters_Json_editor')
api = API(request.session.get('obp'))
urlpath = '/management/dynamic-endpoints'
result = api.post(urlpath, payload=json.loads(parameters_Json_editor) )
result = api.post(urlpath, payload=json.loads(parameters_Json_editor_dynamic) )
return result

View File

@ -1,7 +1,6 @@
import requests
import os
import dotenv
#from deepl_translation_fun import trasnlator
BASE_DIR = os.getcwd() #method tells us the location of current working directory

View File

@ -7,29 +7,27 @@ languages=['de','es','fr','hi'] # Defining languages
# This class is used for converting languages
class clsTranslate():
def translateText(self, strString, strTolang):
class languageConverting():
def parametersTextConverte(self, stString, prevlangToNewlang):
"""
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)
1. prevStrToNewString :=> String that you want to convert
2. prevlangToNewlang :=> Languages(fr,hi,es etc)
"""
self.strString = strString
self.strTolang = strTolang
translator = translator(text=self.strString, language=self.strTolang)
self.prevStrToNewString = prevStrToNewString
self.prevlangToNewlang = prevlangToNewlang
translator = translator(text=self.prevStrToNewString, language=self.prevlangToNewlang)
return (str(translator))
# This is method for writing file
def writeFile(language):
print(language,"Started")
def localeWriteFile(language):
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: # same like try block.
print(fileName, e)
b=0
for i in range(len(a)):
if 'msgid' in a[i] and a[i]!='msgid ""':
@ -37,29 +35,25 @@ def writeFile(language):
break
if b!=0:
trans=clsTranslate() # Creating object for translation class
trans=languageConverting() # Creating object for translation class
for i in range(b-1,len(a)):
try:
if "msgid" in a[i]:
msgid,msgstr=a[i],a[i+1]
if msgstr == 'msgstr ""':
ms=msgid[7:len(msgid)-1]
val=trans.translateText(ms,language)
val=trans.parametersTextConverte(ms,language)
a[i+1]=f'msgstr "{val}"'
# print(a[i])
except: pass
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)
e.map(localeWriteFile,languages)

View File

@ -7,14 +7,14 @@ $(document).ready(function($) {
//each method_routing will have each own json_editor, and will put data into it when click `parameter` box
//and will use the data from click `save` button.
var json_editors = []
let json_editors = []
$('.parameters').click(function() {
var runner = $(this).parent().parent().parent();
var json_editor_id= $(runner).find('.jsoneditor_div')[0].id;
var json_editor_number = json_editor_id.replace("jsoneditor","");
var container = $("#"+json_editor_id);
parameters = JSON.parse($(runner).find('textarea[name="parameters"]').text());
var jsoneditor_div = $(runner).find('.jsoneditor_div');
let runner = $(this).parent().parent().parent();
let json_editor_id= $(runner).find('.jsoneditor_div')[0].id;
let json_editor_number = json_editor_id.replace("jsoneditor","");
let container = $("#"+json_editor_id);
let parameters = JSON.parse($(runner).find('textarea[name="parameters"]').text());
let jsoneditor_div = $(runner).find('.jsoneditor_div');
//make sure only create one jsoneditor_div block, click once to open and then close the block.
if (typeof json_editors[json_editor_number] === 'undefined') {
json_editors[json_editor_number] = new JSONEditor(container[0], options, parameters);
@ -30,21 +30,20 @@ $(document).ready(function($) {
});
$('.runner button.forSave').click(function() {
var t = $(this);
var runner = $(this).parent().parent().parent();
method_routing_id = $(runner).find('.method_routing_id').text();
method_name = $(runner).find('.method_name').text();
connector_name = $(runner).find('.connector_name').val();
bank_id_pattern = $(runner).find('textarea[name="bank_id_pattern"]').val();
is_bank_id_exact_match = $(runner).find('.is_bank_id_exact_match').val();
parameters = $(runner).find('textarea[name="parameters"]').val();
var jsoneditor_id= $(runner).find('.jsoneditor_div')[0].id;
var json_editor_number = jsoneditor_id.replace("jsoneditor","");
let runner = $(this).parent().parent().parent();
let method_routing_id = $(runner).find('.method_routing_id').text();
let method_name = $(runner).find('.method_name').text();
let connector_name = $(runner).find('.connector_name').val();
let bank_id_pattern = $(runner).find('textarea[name="bank_id_pattern"]').val();
let is_bank_id_exact_match = $(runner).find('.is_bank_id_exact_match').val();
let parameters = $(runner).find('textarea[name="parameters"]').val();
let jsoneditor_id= $(runner).find('.jsoneditor_div')[0].id;
let json_editor_number = jsoneditor_id.replace("jsoneditor","");
//if the user do not click the `parameters` box, then there is no json_editors here,so we use the parameters directly.
if (typeof json_editors[json_editor_number] === 'undefined') {
parameters_Json_editor = parameters;
let parameters_Json_editor = parameters;
} else {
parameters_Json_editor = JSON.stringify(json_editors[json_editor_number].get());
let parameters_Json_editor = JSON.stringify(json_editors[json_editor_number].get());
}
$('.runner button.forSave').attr("disabled","disabled");
$('.runner button.forDelete').attr("disabled","disabled");
@ -63,9 +62,8 @@ $(document).ready(function($) {
});
$('.runner button.forDelete').click(function() {
var t = $(this);
var runner = $(this).parent().parent().parent();
method_routing_id = $(runner).find('.method_routing_id').text();
let runner = $(this).parent().parent().parent();
let method_routing_id = $(runner).find('.method_routing_id').text();
$('.runner button.forSave').attr("disabled","disabled");
$('.runner button.forDelete').attr("disabled","disabled");
$.post('methodrouting/delete/method', {

View File

@ -71,11 +71,11 @@
<option value="stored_procedure_vDec2019">{% trans "stored_procedure_vDec2019" %}</option>
{% elif method_routing.connector_name == "rest_vMar2019" %}
<option value="rest_vMar2019">{% trans "rest_vMar2019" %}</option> # This will be selected
<option value="kafka_vSept2018">{% trans "kafka_vSept2018</option>
<option value="mapped">{% trans "mapped</option>
<option value="akka_vDec2018">{% trans "akka_vDec2018</option>
<option value="kafka_vMay2019">{% trans "kafka_vMay2019</option>
<option value="stored_procedure_vDec2019">{% trans "stored_procedure_vDec2019</option>
<option value="kafka_vSept2018">{% trans "kafka_vSept2018" %}</option>
<option value="mapped">{% trans "mapped" %}</option>
<option value="akka_vDec2018">{% trans "akka_vDec2018" %}</option>
<option value="kafka_vMay2019">{% trans "kafka_vMay2019" %}</option>
<option value="stored_procedure_vDec2019">{% trans "stored_procedure_vDec2019" %}</option>
{% elif method_routing.connector_name == "kafka_vMay2019" %}
<option value="kafka_vMay2019">{% trans "kafka_vMay2019" %}</option> # This will be selected
<option value="rest_vMar2019">{% trans "rest_vMar2019" %}</option>
@ -99,7 +99,7 @@
<textarea class="form-control" rows="1"
name="bank_id_pattern">{{ method_routing.bank_id_pattern }}</textarea>
</div>
<div class="col-xs-12 col-sm-1" align="center">
<div class="col-xs-12 col-sm-1" style="align:center;">
<select class="is_bank_id_exact_match form-control">
{% if method_routing.is_bank_id_exact_match == False %}
<option value="False">{% trans "False" %}</option>

View File

@ -5,7 +5,6 @@ URLs for config app
from django.conf.urls import url
#from .views import IndexView, methodrouting_save, methodrouting_delete
from methodrouting.views import IndexView, methodrouting_save, methodrouting_delete
urlpatterns = [

View File

@ -51,13 +51,13 @@ class IndexView(LoginRequiredMixin, FormView):
method_routings[i]['parameters'] = json.dumps(method_routings[i]['parameters'], sort_keys=False)
if(str(settings.API_ROOT).find("127.0.0.1") == -1):
methodSwaggerUrl = '{}/message-docs?connector=stored_procedure_vDec2019#'.format(settings.API_HOST.replace(".openbankproject.", "-explorer.openbankproject."))
method_Swagger_Url = '{}/message-docs?connector=stored_procedure_vDec2019#'.format(settings.API_HOST.replace(".openbankproject.", "-explorer.openbankproject."))
else:
methodSwaggerUrl = "http://127.0.0.1:8082/message-docs?connector=stored_procedure_vDec2019#"
method_Swagger_Url = "http://127.0.0.1:8082/message-docs?connector=stored_procedure_vDec2019#"
context.update({
'method_routings': method_routings,
"methodSwaggerUrl": methodSwaggerUrl
"method_Swagger_Url": method_Swagger_Url
})
return context
@ -68,7 +68,6 @@ def methodrouting_save(request):
connector_name = request.POST.get('connector_name')
bank_id_pattern = request.POST.get('bank_id_pattern')
is_bank_id_exact_match = request.POST.get('is_bank_id_exact_match')
parameters = request.POST.get('parameters')
method_routing_id = request.POST.get('method_routing_id')
parameters_Json_editor = request.POST.get('parameters_Json_editor')
#from sonarcloud: Dynamic code execution should not be vulnerable to injection attacks

View File

@ -68,7 +68,7 @@ class APIMetricsForm(MetricsForm):
('true', 'Yes'),
('false', 'No'),
)
VERB = (
SELECT_VERB = (
('', _('Any')),
('DELETE', 'DELETE'),
('GET', 'GET'),
@ -125,9 +125,9 @@ class APIMetricsForm(MetricsForm):
),
required=False,
)
verb = forms.ChoiceField(
label=_('Verb'),
choices=VERB,
verb_selection = forms.ChoiceField(
label=_('Verb Select'),
choices=SELECT_VERB,
widget=forms.Select(
attrs={
'class': 'form-control',
@ -213,31 +213,15 @@ class ConnectorMetricsForm(MetricsForm):
class CustomSummaryForm(forms.Form):
to_date = forms.DateField(
label=_('To Date'),
# input_formats=[settings.API_DATEFORMAT],
# widget=forms.DateTimeInput(
# attrs={
# 'placeholder': 'yyyy-mm-ddThh:mm:ss',
# 'class': 'form-control',
# }
# ),
widget=DatePickerInput(format='%Y-%m-%d'),
required=True,
# initial=str(datetime.now().strftime('%Y-%m-%dT%H:%M:%S.%fZ')),
initial=str(datetime.now().strftime('%Y-%m-%d')),
)
from_date_custom = forms.DateField(
label=_('From Date'),
#input_formats=[settings.API_DATEFORMAT],
# widget=forms.DateTimeInput(
# attrs={
# 'placeholder': 'yyyy-mm-ddThh:mm:ss',
# 'class': 'form-control',
# }
# )
widget=DatePickerInput(format='%Y-%m-%d'),
required=True,
#initial=str(datetime.now().strftime('%Y-%m-%d')),
initial=(datetime.now() - timedelta(6)).strftime('%Y-%m-%d'),
)
exclude_app_names = forms.CharField(
@ -259,16 +243,8 @@ class CustomSummaryForm(forms.Form):
class MonthlyMetricsSummaryForm(forms.Form):
to_date = forms.DateField(
label=_('To Date'),
# input_formats=[settings.API_DATEFORMAT],
# widget=forms.DateTimeInput(
# attrs={
# 'placeholder': 'yyyy-mm-ddThh:mm:ss',
# 'class': 'form-control',
# }
# ),
widget=DatePickerInput(format='%Y-%m-%d'),
required=True,
# initial=str(datetime.now().strftime('%Y-%m-%dT%H:%M:%S.%fZ')),
initial=str(datetime.now().strftime('%Y-%m-%d')),
)
exclude_app_names = forms.CharField(

View File

@ -5,7 +5,7 @@ document.getElementsByClassName("include_system_calls")[0].innerHTML=`<div>
</div>`
function systemCalls(){
var checkbox = document.getElementById('include_system_calls_id');
let checkbox = document.getElementById('include_system_calls_id');
if (checkbox.checked == false) {
document.getElementById("obp_app_table").style.display = "none";
}else{

View File

@ -1,5 +1,5 @@
$(document).ready(function($) {
var barChart = new Chart($("#barchart"), {
let barChart = Chart($("#barchart"), {
type: 'horizontalBar',
data: {
labels: BarchartData['labels'],

View File

@ -85,10 +85,10 @@
<div class="row">
<div class="col-xs-2">
{% if form.verb.errors %}<div class="alert alert-danger">{{ form.verb.errors }}</div>{% endif %}
{% if form.verb_selection.errors %}<div class="alert alert-danger">{{ form.verb_selection.errors }}</div>{% endif %}
<div class="form-group">
{{ form.verb.label_tag }}
{{ form.verb }}
{{ form.verb_selection.label_tag }}
{{ form.verb_selection }}
</div>
</div>
@ -140,7 +140,7 @@
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">{% trans "Verb" %}</th>
<th scope="col">{% trans "Verb Select" %}</th>
<th scope="col">{% trans "URL" %}</th>
<th scope="col">{% trans "Date" %}</th>
<th scope="col">{% trans "Duration(ms)" %}</th>
@ -151,7 +151,7 @@
{% for metric in metrics %}
<tr>
<td>{{ forloop.counter }}</td>
<td>{{ metric.verb }}</td>
<td>{{ metric.verb_selection }}</td>
<td>
{{ metric.url }}
</td>

View File

@ -3,8 +3,8 @@
{% load i18n %}
{% block nav_tabs %}
<li><a href="{% url 'api-metrics' %}?{{ request.GET.urlencode }}">{% trans "List" %}</a></li>
<li class="active"><a href="{% url 'api-metrics-summary-partial-function' %}?{{ request.GET.urlencode }}">{% trans "Summary by Partial Function" %}</a></li>
<a href="{% url 'api-metrics' %}?{{ request.GET.urlencode }}">{% trans "List" %}</a>
<a href="{% url 'api-metrics-summary-partial-function' %}?{{ request.GET.urlencode }}" class="active">{% trans "Summary by Partial Function" %}</a>
{% endblock nav_tabs %}
{% block tab_content %}

View File

@ -14,15 +14,12 @@
<li><a href="{% url 'metrics-summary' %}?{{ request.GET.urlencode }}">{% trans "Month" %}</a></li>
<li><a href="{% url 'weekly-summary' %}?{{ request.GET.urlencode }}">{% trans "Week" %}</a></li>
<li><a href="{% url 'daily-summary' %}?{{ request.GET.urlencode }}">{% trans "Day" %}</a></li>
<!--<li><a href="{% url 'hourly-summary' %}?{{ request.GET.urlencode }}">Hour</a></li>-->
<li class="active"><a href="{% url 'custom-summary' %}?{{ request.GET.urlencode }}">{% trans "Custom" %}</a></li>
{% endblock nav_tabs %}
</ul>
<div id="metrics-filter">
<!--{% load bootstrap3 %} {# import bootstrap4/bootstrap3 #}-->
<!--{% bootstrap_css %} {# Embed Bootstrap CSS #}-->
{% bootstrap_javascript jquery='full' %} {# Embed Bootstrap JS+jQuery #}
{% block extrahead %} {# Extra Resources Start #}

View File

@ -19,7 +19,6 @@
<li><a href="{% url 'metrics-summary' %}?{{ request.GET.urlencode }}">{% trans "Month" %}</a></li>
<li><a href="{% url 'weekly-summary' %}?{{ request.GET.urlencode }}">{% trans "Week" %}</a></li>
<li class="active"><a href="{% url 'daily-summary' %}?{{ request.GET.urlencode }}">{% trans "Day" %}</a></li>
<!--<li><a href="{% url 'hourly-summary' %}?{{ request.GET.urlencode }}">Hour</a></li>-->
<li><a href="{% url 'custom-summary' %}?{{ request.GET.urlencode }}">{% trans "Custom" %}</a></li>
{% endblock nav_tabs %}
</ul>

View File

@ -74,7 +74,7 @@
<div class="tab-pane active">
<h2>{% trans "Period" %}: {% trans "From" %}{{ from_date }} {% trans "to" %} {{ to_date }}</h2>
<table border="1" id="obp_app_table">
<table border="1" id="obp_app_table" summary="Table about call APIs in every hours">
<tr>
<th></th>
<th></th>
@ -89,11 +89,11 @@
</tr>
<tr>
<td>{% trans "Calls per minute" %}:</td>
<td bgcolor="#FF0000">{%for item in calls_per_hour_list%}<li>{{item}}</li>{% endfor %}</td>
<td style="background-color:#FF0000">{%for item in calls_per_hour_list%}<li><ol>{{item}}</ol></li>{% endfor %}</td>
</tr>
<tr>
<td>{% trans "Calls per minute" %}:</td>
<td bgcolor="#FF0000"><img src="data:image/png;base64, {{ per_hour_chart }}" alt="somealt" /></td>
<td style="background-color:#FF0000"><img src="data:image/png;base64, {{ per_hour_chart }}" alt="somealt" /></td>
</tr>
<tr>
<td>{% trans "Average number of calls hour" %}: </td>

View File

@ -14,15 +14,12 @@
<li class="active"><a href="{% url 'metrics-summary' %}?{{ request.GET.urlencode }}">{% trans "Month" %}</a></li>
<li><a href="{% url 'weekly-summary' %}?{{ request.GET.urlencode }}">{% trans "Week" %}</a></li>
<li><a href="{% url 'daily-summary' %}?{{ request.GET.urlencode }}">{% trans "Day" %}</a></li>
<!--<li><a href="{% url 'hourly-summary' %}?{{ request.GET.urlencode }}">Hour</a></li>-->
<li><a href="{% url 'custom-summary' %}?{{ request.GET.urlencode }}">{% trans "Custom" %}</a></li>
{% endblock nav_tabs %}
</ul>
<div id="metrics-filter">
<!--{% load bootstrap3 %} {# import bootstrap4/bootstrap3 #}-->
<!--{% bootstrap_css %} {# Embed Bootstrap CSS #}-->
{% bootstrap_javascript jquery='full' %} {# Embed Bootstrap JS+jQuery #}
{% block extrahead %} {# Extra Resources Start #}

View File

@ -18,7 +18,6 @@
<li><a href="{% url 'metrics-summary' %}?{{ request.GET.urlencode }}">{% trans "Month" %}</a></li>
<li><a href="{% url 'weekly-summary' %}?{{ request.GET.urlencode }}">{% trans "Week" %}</a></li>
<li><a href="{% url 'daily-summary' %}?{{ request.GET.urlencode }}">{% trans "Day" %}</a></li>
<!--<li><a href="{% url 'hourly-summary' %}?{{ request.GET.urlencode }}">Hour</a></li>-->
<li><a href="{% url 'custom-summary' %}?{{ request.GET.urlencode }}">{% trans "Custom" %}</a></li>
{% endblock nav_tabs %}
</ul>

View File

@ -20,7 +20,6 @@
<li><a href="{% url 'metrics-summary' %}?{{ request.GET.urlencode }}">{% trans "Month" %}</a></li>
<li class="active"><a href="{% url 'weekly-summary' %}?{{ request.GET.urlencode }}">{% trans "Week" %}</a></li>
<li><a href="{% url 'daily-summary' %}?{{ request.GET.urlencode }}">{% trans "Day" %}</a></li>
<!--<li><a href="{% url 'hourly-summary' %}?{{ request.GET.urlencode }}">Hour</a></li>-->
<li><a href="{% url 'custom-summary' %}?{{ request.GET.urlencode }}">{% trans "Custom" %}</a></li>
{% endblock nav_tabs %}
</ul>

View File

@ -20,7 +20,6 @@
<li><a href="{% url 'metrics-summary' %}?{{ request.GET.urlencode }}">{% trans "Month" %}</a></li>
<li><a href="{% url 'weekly-summary' %}?{{ request.GET.urlencode }}">{% trans "Week" %}</a></li>
<li><a href="{% url 'daily-summary' %}?{{ request.GET.urlencode }}">{% trans "Day" %}</a></li>
<!--<li><a href="{% url 'hourly-summary' %}?{{ request.GET.urlencode }}">Hour</a></li>-->
<li><a href="{% url 'custom-summary' %}?{{ request.GET.urlencode }}">{% trans "Custom" %}</a></li>
{% endblock nav_tabs %}
</ul>

View File

@ -355,7 +355,7 @@ class MonthlyMetricsSummaryView(LoginRequiredMixin, TemplateView):
# If include OBP Apps is selected
if cleaned_data.get('include_obp_apps'):
app_names = app_names
pass
else:
for app in app_names:
if app in local_settings.EXCLUDE_APPS:
@ -721,8 +721,6 @@ class MonthlyMetricsSummaryView(LoginRequiredMixin, TemplateView):
if form.is_valid():
is_included_obp_apps = form.cleaned_data.get('include_obp_apps')
exclude_app_names = form.cleaned_data.get("exclude_app_names")
#if exclude_app_names not in local_settings.EXCLUDE_APPS:
# error_once_only(self.request, "Invalid Exclude App Name, Please select" + str(local_settings.EXCLUDE_APPS) + "Anyone of these")
form_to_date_string = form.data['to_date']
to_date = convert_form_date_to_obpapi_datetime_format(form_to_date_string)

View File

@ -16,6 +16,7 @@ from .api import API, APIError
from .authenticator import AuthenticatorError
from .forms import DirectLoginForm, GatewayLoginForm
from .oauth import OAuthAuthenticator
from django.conf import settings
class LoginToDjangoMixin(object):
@ -53,8 +54,11 @@ class OAuthInitiateView(RedirectView):
Gets the callback URI to where the user shall be returned after
initiation at OAuth server
"""
base_url = '{}://{}'.format(
request.scheme, request.environ['HTTP_HOST'])
if settings.CALLBACK_BASE_URL:
base_url = settings.CALLBACK_BASE_URL
else:
base_url = '{}://{}'.format(
request.scheme, request.environ['HTTP_HOST'])
uri = base_url + reverse('oauth-authorize')
if 'next' in request.GET:
uri = '{}?next={}'.format(uri, request.GET['next'])

View File

@ -1,7 +1,7 @@
{% extends 'base.html' %} {% load static %} {% load i18n %}
{% block page_title %} {{ block.super }} / {% trans "System View" %}{% endblock page_title %} {% block content %}
<div id="systemview">
<h1>{% trans "System View" %}</h1>
<h1>{% trans "System Views" %}</h1>
<div class="table-responsive">
<table class="table table-hover tablesorter" id="system_view" aria-describedby="system view">
<thead>

View File

@ -1,8 +1,8 @@
#Django==1.11.7
Django==2.0.7
oauthlib==2.0.0
requests==2.11.1
requests-oauthlib==0.6.2
Django==2.2.13
oauthlib==3.2.0
requests==2.27.1
requests-oauthlib==1.3.1
PyJWT==1.5.3
gunicorn==19.6.0
matplotlib