diff --git a/apimanager/apicollectionlist/views.py b/apimanager/apicollectionlist/views.py index 89e065b..65d1509 100644 --- a/apimanager/apicollectionlist/views.py +++ b/apimanager/apicollectionlist/views.py @@ -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, }) diff --git a/apimanager/apicollections/views.py b/apimanager/apicollections/views.py index 023a1b1..35327ef 100644 --- a/apimanager/apicollections/views.py +++ b/apimanager/apicollections/views.py @@ -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. diff --git a/apimanager/atms/views.py b/apimanager/atms/views.py index 90049a9..b63f48d 100644 --- a/apimanager/atms/views.py +++ b/apimanager/atms/views.py @@ -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", diff --git a/apimanager/base/context_processors.py b/apimanager/base/context_processors.py index b1dfb27..1169fdc 100644 --- a/apimanager/base/context_processors.py +++ b/apimanager/base/context_processors.py @@ -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: diff --git a/apimanager/dynamicendpoints/views.py b/apimanager/dynamicendpoints/views.py index 8cb0e0b..27dfa00 100644 --- a/apimanager/dynamicendpoints/views.py +++ b/apimanager/dynamicendpoints/views.py @@ -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 = { diff --git a/apimanager/metrics/forms.py b/apimanager/metrics/forms.py index 4ffd114..58b0d15 100644 --- a/apimanager/metrics/forms.py +++ b/apimanager/metrics/forms.py @@ -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')),