mirror of
https://github.com/OpenBankProject/API-Manager.git
synced 2026-02-06 15:06:48 +00:00
Merge pull request #267 from mark-tesobe/bugfix/sonarcloud
REFACTOR/sonarcloud
This commit is contained in:
commit
ae32f3a081
@ -56,8 +56,8 @@ class ApiCollectionListView(IndexView, LoginRequiredMixin, FormView ):
|
||||
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)))
|
||||
except Exception as err:
|
||||
messages.error(self.request, err)
|
||||
context.update({
|
||||
'apicollections_list': apicollections_list,
|
||||
})
|
||||
|
||||
@ -36,7 +36,7 @@ class IndexView(LoginRequiredMixin, FormView):
|
||||
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:
|
||||
except Exception as err:
|
||||
error_once_only(self.request, err)
|
||||
else:
|
||||
# set the default endpoint there, the first item will be the new endpoint.
|
||||
|
||||
@ -149,8 +149,8 @@ class IndexAtmsView(LoginRequiredMixin, FormView):
|
||||
"supported_currencies":[data["supported_currencies"]],
|
||||
"notes":[data["notes"]],
|
||||
"location_categories":[data["location_categories"]],
|
||||
**self._index_boolean_payload1(data),
|
||||
**self._index_boolean_payload2(data),
|
||||
**self._boolean_payload1(data),
|
||||
**self._boolean_payload2(data),
|
||||
|
||||
}
|
||||
result = self.api.post(urlpath, payload=payload)
|
||||
@ -181,7 +181,7 @@ class IndexAtmsView(LoginRequiredMixin, FormView):
|
||||
}
|
||||
}
|
||||
|
||||
def _index_boolean_payload1(self, data):
|
||||
def _boolean_payload1(self, data):
|
||||
return {
|
||||
"is_accessible": data["is_accessible"] if data["is_accessible"]!="" else "false",
|
||||
"located_at": data["located_at"] if data["located_at"]!="no-example-provided" else " ",
|
||||
@ -190,7 +190,7 @@ class IndexAtmsView(LoginRequiredMixin, FormView):
|
||||
"minimum_withdrawal": data["minimum_withdrawal"] if data["minimum_withdrawal"]!="" else "false"
|
||||
}
|
||||
|
||||
def _index_boolean_payload2(self, data):
|
||||
def _boolean_payload2(self, data):
|
||||
return {
|
||||
"branch_identification": data["branch_identification"] if data["branch_identification"]!="" else "false",
|
||||
"site_identification": data["site_identification"] if data["site_identification"]!="" else "false",
|
||||
|
||||
@ -55,6 +55,7 @@ def api_username(request):
|
||||
apicaches=cache.set(cache_key, {'API_USERNAME': nametodisplay})
|
||||
LOGGER.warning('The cache setting api_user_name is: {}'.format(nametodisplay))
|
||||
LOGGER.warning('The cache setting key is: {}'.format(cache_key))
|
||||
return {'API_USERNAME': nametodisplay}
|
||||
|
||||
def authenticated_name(request, get_current_user_api_url):
|
||||
try:
|
||||
@ -71,7 +72,7 @@ def authenticated_name(request, get_current_user_api_url):
|
||||
nametodisplay = email
|
||||
else:
|
||||
nametodisplay = username
|
||||
return {'API_USERNAME': nametodisplay}
|
||||
return nametodisplay
|
||||
except APIError as err:
|
||||
messages.error(request, err)
|
||||
except Exception as err:
|
||||
|
||||
@ -38,7 +38,7 @@ class IndexView(LoginRequiredMixin, FormView):
|
||||
except APIError as err:
|
||||
messages.error(self.request, err)
|
||||
except Exception as err:
|
||||
messages.error(self.request, err)
|
||||
error_once_only(self.request, err)
|
||||
else:
|
||||
# set the default endpoint there, the first item will be the new endpoint.
|
||||
default_dynamic_endpoint = {
|
||||
|
||||
@ -16,6 +16,7 @@ from apimanager.settings import API_MANAGER_DATE_FORMAT
|
||||
API_DATEFORMAT_PLACEHOLDER = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
|
||||
FORM_CONTROL = "FORM_CONTROL"
|
||||
FROM_DATE = "From Date"
|
||||
TO_DATE = "To Date"
|
||||
|
||||
class MetricsForm(forms.Form):
|
||||
from_date = forms.DateTimeField(
|
||||
@ -31,7 +32,7 @@ class MetricsForm(forms.Form):
|
||||
required=False,
|
||||
)
|
||||
to_date = forms.DateTimeField(
|
||||
label=_('To Date'),
|
||||
label=_(TO_DATE),
|
||||
input_formats=[settings.API_DATEFORMAT],
|
||||
widget=forms.DateTimeInput(
|
||||
attrs={
|
||||
@ -216,7 +217,7 @@ class ConnectorMetricsForm(MetricsForm):
|
||||
|
||||
class CustomSummaryForm(forms.Form):
|
||||
to_date = forms.DateField(
|
||||
label=_('To Date'),
|
||||
label=_(TO_DATE),
|
||||
widget=DatePickerInput(format='API_MANAGER_DATE_FORMAT'),
|
||||
required=True,
|
||||
initial=str(datetime.now().strftime('API_MANAGER_DATE_FORMAT')),
|
||||
@ -246,7 +247,7 @@ class CustomSummaryForm(forms.Form):
|
||||
|
||||
class MonthlyMetricsSummaryForm(forms.Form):
|
||||
to_date = forms.DateField(
|
||||
label=_('To Date'),
|
||||
label=_(TO_DATE),
|
||||
widget=DatePickerInput(format='API_MANAGER_DATE_FORMAT'),
|
||||
required=True,
|
||||
initial=str(datetime.now().strftime('API_MANAGER_DATE_FORMAT')),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user