mirror of
https://github.com/OpenBankProject/API-Manager.git
synced 2026-02-06 10:59:00 +00:00
FIX: sonarcloud
This commit is contained in:
parent
feca2f3118
commit
46d1d76075
@ -304,6 +304,9 @@ OVERRIDE_CSS_URL = None
|
||||
VERIFY = True
|
||||
CALLBACK_BASE_URL = ""
|
||||
|
||||
# Global
|
||||
UNDEFINED = "<undefined>"
|
||||
|
||||
# Local settings can replace any value ABOVE
|
||||
try:
|
||||
from apimanager.local_settings import * # noqa
|
||||
|
||||
@ -5,7 +5,7 @@ $(document).ready(function($) {
|
||||
}
|
||||
json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
||||
return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function (match) {
|
||||
var cls = 'number';
|
||||
let cls = 'number';
|
||||
if (/^"/.test(match)) {
|
||||
if (/:$/.test(match)) {
|
||||
cls = 'key';
|
||||
|
||||
@ -25,8 +25,8 @@ class IndexView(LoginRequiredMixin, TemplateView):
|
||||
except APIError as err:
|
||||
messages.error(self.request, err)
|
||||
config = {}
|
||||
except:
|
||||
messages.error(self.request, "Unknown Error")
|
||||
except Exception as err:
|
||||
messages.error(self.request, err)
|
||||
config = {}
|
||||
|
||||
context.update({
|
||||
|
||||
@ -34,8 +34,8 @@ class IndexView(LoginRequiredMixin, FormView):
|
||||
connectormethod=response['connector_methods']
|
||||
except APIError as err:
|
||||
messages.error(self.request, err)
|
||||
except BaseException as err:
|
||||
error_once_only(self.request, (Exception("Unknown Error. Details:" + str(err))))
|
||||
except Exception as err:
|
||||
error_once_only(self.request, err)
|
||||
else:
|
||||
default_connector_method_endpoint = {
|
||||
"connector_method_name": "Method Name",
|
||||
|
||||
@ -9,6 +9,7 @@ from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from obp.api import APIError
|
||||
|
||||
PLACEHOLDER = "2013-01-22T00:08:00Z"
|
||||
|
||||
class CreateCustomerForm(forms.Form):
|
||||
bank_id = forms.ChoiceField(
|
||||
@ -83,7 +84,7 @@ class CreateCustomerForm(forms.Form):
|
||||
input_formats=[settings.API_DATETIMEFORMAT],
|
||||
widget=forms.DateTimeInput(
|
||||
attrs={
|
||||
'placeholder': '2013-01-22T00:08:00Z',
|
||||
'placeholder': PLACEHOLDER,
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
@ -94,7 +95,7 @@ class CreateCustomerForm(forms.Form):
|
||||
input_formats=[settings.API_DATETIMEFORMAT],
|
||||
widget=forms.DateTimeInput(
|
||||
attrs={
|
||||
'placeholder': '2013-01-22T00:08:00Z',
|
||||
'placeholder': PLACEHOLDER,
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
@ -125,7 +126,7 @@ class CreateCustomerForm(forms.Form):
|
||||
label=_('Date of Birth of Dependants'),
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'placeholder': '2013-01-22T00:08:00Z, 2010-01-22T00:08:00Z',
|
||||
'placeholder': f'{PLACEHOLDER}, 2010-01-22T00:08:00Z',
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
@ -206,7 +207,7 @@ class CreateCustomerForm(forms.Form):
|
||||
input_formats=[settings.API_DATETIMEFORMAT],
|
||||
widget=forms.DateTimeInput(
|
||||
attrs={
|
||||
'placeholder': '2013-01-22T00:08:00Z',
|
||||
'placeholder': PLACEHOLDER,
|
||||
'class': 'form-control',
|
||||
}
|
||||
),
|
||||
|
||||
@ -35,8 +35,8 @@ class CreateView(LoginRequiredMixin, FormView):
|
||||
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")
|
||||
except Exception as err:
|
||||
messages.error(self.request, err)
|
||||
fields['last_ok_date'].initial =\
|
||||
datetime.datetime.now().strftime(settings.API_DATETIMEFORMAT)
|
||||
return form
|
||||
@ -78,8 +78,8 @@ class CreateView(LoginRequiredMixin, FormView):
|
||||
except APIError as err:
|
||||
messages.error(self.request, err)
|
||||
return super(CreateView, self).form_invalid(form)
|
||||
except:
|
||||
messages.error(self.request, "Unknown Error")
|
||||
except Exception as err:
|
||||
messages.error(self.request, err)
|
||||
return super(CreateView, self).form_invalid(form)
|
||||
msg = 'Customer number {} for user {} has been created successfully!'.format( # noqa
|
||||
result['customer_number'], data['username'])
|
||||
|
||||
@ -7,7 +7,7 @@ $(document).ready(function($) {
|
||||
|
||||
//each dynamic_endpoint 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() {
|
||||
let runner = $(this).parent().parent().parent();
|
||||
let json_editor_id= $(runner).find('.jsoneditor_div')[0].id;
|
||||
|
||||
@ -13,6 +13,10 @@ from .forms import DynamicEndpointsForm
|
||||
from django.urls import reverse_lazy
|
||||
from django.views.decorators.csrf import csrf_exempt
|
||||
|
||||
DEFINITIONS_USER = "#/definitions/user"
|
||||
UNEXPECTED_ERROR = "unexpected error"
|
||||
RESPONSES_UNEXPECTED_ERROR = "#/responses/unexpectedError"
|
||||
DEFINITIONS_API_ERROR = "#/definitions/APIError"
|
||||
|
||||
class IndexView(LoginRequiredMixin, FormView):
|
||||
"""Index view for config"""
|
||||
@ -33,8 +37,8 @@ class IndexView(LoginRequiredMixin, FormView):
|
||||
dynamic_endpoints=response['dynamic_endpoints']
|
||||
except APIError as err:
|
||||
messages.error(self.request, err)
|
||||
except BaseException as err:
|
||||
error_once_only(self.request, (Exception("Unknown Error. Details:" + str(err))))
|
||||
except Exception as err:
|
||||
messages.error(self.request, err)
|
||||
else:
|
||||
# set the default endpoint there, the first item will be the new endpoint.
|
||||
default_dynamic_endpoint = {
|
||||
@ -64,20 +68,20 @@ class IndexView(LoginRequiredMixin, FormView):
|
||||
"in":"body",
|
||||
"required":True,
|
||||
"schema":{
|
||||
"$ref":"#/definitions/user"
|
||||
"$ref":DEFINITIONS_USER
|
||||
}
|
||||
}],
|
||||
"responses":{
|
||||
"201":{
|
||||
"description":"create user successful and return created user object",
|
||||
"schema":{
|
||||
"$ref":"#/definitions/user"
|
||||
"$ref": DEFINITIONS_USER
|
||||
}
|
||||
},
|
||||
"500":{
|
||||
"description":"unexpected error",
|
||||
"description":UNEXPECTED_ERROR,
|
||||
"schema":{
|
||||
"$ref":"#/responses/unexpectedError"
|
||||
"$ref":RESPONSES_UNEXPECTED_ERROR
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -94,7 +98,7 @@ class IndexView(LoginRequiredMixin, FormView):
|
||||
"200":{
|
||||
"description":"the successful get requested user by user ID",
|
||||
"schema":{
|
||||
"$ref":"#/definitions/user"
|
||||
"$ref":DEFINITIONS_USER
|
||||
}
|
||||
},
|
||||
"400":{
|
||||
@ -106,13 +110,13 @@ class IndexView(LoginRequiredMixin, FormView):
|
||||
"404":{
|
||||
"description":"user not found",
|
||||
"schema":{
|
||||
"$ref":"#/definitions/APIError"
|
||||
"$ref":DEFINITIONS_API_ERROR
|
||||
}
|
||||
},
|
||||
"500":{
|
||||
"description":"unexpected error",
|
||||
"description":UNEXPECTED_ERROR,
|
||||
"schema":{
|
||||
"$ref":"#/responses/unexpectedError"
|
||||
"$ref":RESPONSES_UNEXPECTED_ERROR
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -126,13 +130,13 @@ class IndexView(LoginRequiredMixin, FormView):
|
||||
"200":{
|
||||
"description":"get all users",
|
||||
"schema":{
|
||||
"$ref":"#/definitions/users"
|
||||
"$ref":DEFINITIONS_USER
|
||||
}
|
||||
},
|
||||
"404":{
|
||||
"description":"user not found",
|
||||
"schema":{
|
||||
"$ref":"#/definitions/APIError"
|
||||
"$ref":DEFINITIONS_API_ERROR
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -145,20 +149,20 @@ class IndexView(LoginRequiredMixin, FormView):
|
||||
"in":"body",
|
||||
"required":True,
|
||||
"schema":{
|
||||
"$ref":"#/definitions/user"
|
||||
"$ref":DEFINITIONS_USER
|
||||
}
|
||||
}],
|
||||
"responses":{
|
||||
"200":{
|
||||
"description":"create user successful and return created user object",
|
||||
"schema":{
|
||||
"$ref":"#/definitions/user"
|
||||
"$ref":DEFINITIONS_USER
|
||||
}
|
||||
},
|
||||
"500":{
|
||||
"description":"unexpected error",
|
||||
"description":UNEXPECTED_ERROR,
|
||||
"schema":{
|
||||
"$ref":"#/responses/unexpectedError"
|
||||
"$ref":RESPONSES_UNEXPECTED_ERROR
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -182,9 +186,9 @@ class IndexView(LoginRequiredMixin, FormView):
|
||||
}
|
||||
},
|
||||
"500":{
|
||||
"description":"unexpected error",
|
||||
"description":UNEXPECTED_ERROR,
|
||||
"schema":{
|
||||
"$ref":"#/responses/unexpectedError"
|
||||
"$ref":RESPONSES_UNEXPECTED_ERROR
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -218,7 +222,7 @@ class IndexView(LoginRequiredMixin, FormView):
|
||||
"description":"array of users",
|
||||
"type":"array",
|
||||
"items":{
|
||||
"$ref":"#/definitions/user"
|
||||
"$ref":DEFINITIONS_USER
|
||||
}
|
||||
},
|
||||
"APIError":{
|
||||
@ -238,15 +242,15 @@ class IndexView(LoginRequiredMixin, FormView):
|
||||
},
|
||||
"responses":{
|
||||
"unexpectedError":{
|
||||
"description":"unexpected error",
|
||||
"description":UNEXPECTED_ERROR,
|
||||
"schema":{
|
||||
"$ref":"#/definitions/APIError"
|
||||
"$ref":DEFINITIONS_API_ERROR
|
||||
}
|
||||
},
|
||||
"invalidRequest":{
|
||||
"description":"invalid request",
|
||||
"schema":{
|
||||
"$ref":"#/definitions/APIError"
|
||||
"$ref":DEFINITIONS_API_ERROR
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@ -12,6 +12,7 @@ from datetime import datetime
|
||||
from django.conf import settings
|
||||
from django.urls import reverse
|
||||
from django.http import HttpResponseRedirect
|
||||
from apimanager.settings import UNDEFINED
|
||||
|
||||
|
||||
|
||||
@ -44,8 +45,8 @@ class IndexView(LoginRequiredMixin, TemplateView):
|
||||
entitlement_requests = sorted(entitlement_requests, key=lambda k: k['created'], reverse=True)
|
||||
except APIError as err:
|
||||
messages.error(self.request, err)
|
||||
except:
|
||||
messages.error(self.request, "Unknown Error")
|
||||
except Exception as err:
|
||||
messages.error(self.request, err)
|
||||
|
||||
context.update({
|
||||
'entitlementrequests': entitlement_requests,
|
||||
@ -66,12 +67,12 @@ class RejectEntitlementRequest(LoginRequiredMixin, View):
|
||||
messages.error(self.request, response['message'])
|
||||
else:
|
||||
msg = 'Entitlement Request with role {} has been deleted.'.format(
|
||||
request.POST.get('role_name', '<undefined>'))
|
||||
request.POST.get('role_name', UNDEFINED))
|
||||
messages.success(request, msg)
|
||||
except APIError as err:
|
||||
messages.error(request, err)
|
||||
except:
|
||||
messages.error(self.request, "Unknown Error")
|
||||
except Exception as err:
|
||||
messages.error(self.request, err)
|
||||
|
||||
return HttpResponseRedirect(reverse('entitlementrequests-index'))
|
||||
|
||||
@ -86,32 +87,32 @@ class AcceptEntitlementRequest(LoginRequiredMixin, View):
|
||||
try:
|
||||
urlpath = '/users/{}/entitlements'.format(kwargs['user_id'])
|
||||
payload = {
|
||||
'bank_id': request.POST.get('bank_id', '<undefined>'),
|
||||
'role_name': request.POST.get('role_name', '<undefined>'),
|
||||
'bank_id': request.POST.get('bank_id', UNDEFINED),
|
||||
'role_name': request.POST.get('role_name', UNDEFINED),
|
||||
}
|
||||
response = api.post(urlpath, payload=payload)
|
||||
if 'code' in response and response['code'] >= 400:
|
||||
messages.error(self.request, response['message'])
|
||||
else:
|
||||
msg = 'Entitlement with role {} has been added.'.format(request.POST.get('role_name', '<undefined>'))
|
||||
msg = 'Entitlement with role {} has been added.'.format(request.POST.get('role_name', UNDEFINED))
|
||||
messages.success(request, msg)
|
||||
except APIError as err:
|
||||
messages.error(request, err)
|
||||
except:
|
||||
messages.error(self.request, "Unknown Error")
|
||||
except Exception as err:
|
||||
messages.error(self.request, err)
|
||||
|
||||
try:
|
||||
urlpath = '/entitlement-requests/{}'.format(request.POST.get('entitlement_request_id', '<undefined>'))
|
||||
urlpath = '/entitlement-requests/{}'.format(request.POST.get('entitlement_request_id', UNDEFINED))
|
||||
response = api.delete(urlpath)
|
||||
if 'code' in response and response['code'] >= 400:
|
||||
messages.error(self.request, response['message'])
|
||||
else:
|
||||
msg = 'Entitlement Request with role {} has been deleted.'.format(
|
||||
request.POST.get('role_name', '<undefined>'))
|
||||
request.POST.get('role_name', UNDEFINED))
|
||||
messages.success(request, msg)
|
||||
except APIError as err:
|
||||
messages.error(request, err)
|
||||
except:
|
||||
messages.error(self.request, "Unknown Error")
|
||||
except Exception as err:
|
||||
messages.error(self.request, err)
|
||||
|
||||
return HttpResponseRedirect(reverse('entitlementrequests-index'))
|
||||
return HttpResponseRedirect(reverse('entitlementrequests-index'))
|
||||
|
||||
@ -38,7 +38,7 @@ class IndexView(LoginRequiredMixin, FormView):
|
||||
except APIError as err:
|
||||
messages.error(self.request, err)
|
||||
except BaseException as err:
|
||||
error_once_only(self.request, (Exception("Unknown Error. Details:" + str(err))))
|
||||
error_once_only(self.request, err)
|
||||
else:
|
||||
for i in range(len(method_routings)):
|
||||
#if the parameters are empty, we provide the example value.
|
||||
@ -100,4 +100,4 @@ def methodrouting_delete(request):
|
||||
|
||||
urlpath = '/management/method_routings/{}'.format(method_routing_id)
|
||||
result = api.delete(urlpath)
|
||||
return result
|
||||
return result
|
||||
|
||||
Loading…
Reference in New Issue
Block a user