mirror of
https://github.com/OpenBankProject/API-Manager.git
synced 2026-02-06 13:06:45 +00:00
Applied some flake8 fixes
This commit is contained in:
parent
5cee638f65
commit
0e533ee4e2
@ -103,16 +103,16 @@ DATABASES = {
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', # noqa
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', # noqa
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', # noqa
|
||||
},
|
||||
{
|
||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', # noqa
|
||||
},
|
||||
]
|
||||
|
||||
@ -219,7 +219,7 @@ GATEWAYLOGIN_HAS_CBS = False
|
||||
|
||||
# Local settings can override anything in here
|
||||
try:
|
||||
from apimanager.local_settings import *
|
||||
from apimanager.local_settings import * # noqa
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
@ -14,7 +14,6 @@ from obp.views import (
|
||||
)
|
||||
|
||||
|
||||
|
||||
urlpatterns = [
|
||||
url(r'^$', HomeView.as_view(), name="home"),
|
||||
# Defining authentication URLs here and not including oauth.urls for
|
||||
|
||||
@ -9,7 +9,6 @@ from django.contrib import messages
|
||||
from obp.api import API, APIError
|
||||
|
||||
|
||||
|
||||
def api_root(request):
|
||||
"""Returns the configured API_ROOT"""
|
||||
return {'API_ROOT': settings.API_ROOT}
|
||||
|
||||
@ -8,7 +8,6 @@ from datetime import datetime, timedelta
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
|
||||
class BaseFilter(object):
|
||||
"""Base for custom filter classes"""
|
||||
filter_type = None
|
||||
@ -34,7 +33,7 @@ class BaseFilter(object):
|
||||
filter_active_value = 'active_{}'.format(self.filter_type)
|
||||
self.context[filter_active_value] = 'All'
|
||||
|
||||
if not self.filter_type in self.request_get:
|
||||
if self.filter_type not in self.request_get:
|
||||
return data
|
||||
|
||||
filter_value = self.request_get[self.filter_type]
|
||||
@ -48,7 +47,6 @@ class BaseFilter(object):
|
||||
return self._apply(data, filter_value)
|
||||
|
||||
|
||||
|
||||
class FilterTime(BaseFilter):
|
||||
"""Filter items by datetime"""
|
||||
filter_type = 'time'
|
||||
|
||||
@ -7,7 +7,6 @@ from datetime import datetime
|
||||
from django.contrib.humanize.templatetags.humanize import naturaltime
|
||||
|
||||
|
||||
|
||||
def json_serial(obj):
|
||||
"""JSON serializer for objects not serializable by default json code"""
|
||||
|
||||
|
||||
@ -6,7 +6,6 @@ App config for config app
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
|
||||
class ConfigConfig(AppConfig):
|
||||
"""Config for config"""
|
||||
name = 'config'
|
||||
|
||||
@ -7,7 +7,7 @@ import json
|
||||
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.views.generic import FormView, TemplateView, View
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
from obp.api import API, APIError
|
||||
|
||||
|
||||
@ -15,7 +15,6 @@ from obp.api import API, APIError
|
||||
from base.filters import BaseFilter, FilterTime
|
||||
|
||||
|
||||
|
||||
class FilterAppType(BaseFilter):
|
||||
"""Filter consumers by application type"""
|
||||
filter_type = 'app_type'
|
||||
@ -35,7 +34,6 @@ class FilterEnabled(BaseFilter):
|
||||
return filtered
|
||||
|
||||
|
||||
|
||||
class IndexView(LoginRequiredMixin, TemplateView):
|
||||
"""Index view for consumers"""
|
||||
template_name = "consumers/index.html"
|
||||
@ -47,7 +45,6 @@ class IndexView(LoginRequiredMixin, TemplateView):
|
||||
consumer['created'], settings.API_DATETIMEFORMAT)
|
||||
return consumers
|
||||
|
||||
|
||||
def compile_statistics(self, consumers):
|
||||
"""Compiles a set of statistical values for the given consumers"""
|
||||
unique_developer_email = {}
|
||||
@ -64,7 +61,6 @@ class IndexView(LoginRequiredMixin, TemplateView):
|
||||
}
|
||||
return statistics
|
||||
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(IndexView, self).get_context_data(**kwargs)
|
||||
consumers = []
|
||||
@ -91,7 +87,6 @@ class IndexView(LoginRequiredMixin, TemplateView):
|
||||
return context
|
||||
|
||||
|
||||
|
||||
class DetailView(LoginRequiredMixin, TemplateView):
|
||||
"""Detail view for a consumer"""
|
||||
template_name = "consumers/detail.html"
|
||||
@ -114,7 +109,6 @@ class DetailView(LoginRequiredMixin, TemplateView):
|
||||
return context
|
||||
|
||||
|
||||
|
||||
class EnableDisableView(LoginRequiredMixin, RedirectView):
|
||||
"""View to enable or disable a consumer"""
|
||||
enabled = False
|
||||
@ -136,7 +130,6 @@ class EnableDisableView(LoginRequiredMixin, RedirectView):
|
||||
return redirect_url
|
||||
|
||||
|
||||
|
||||
class EnableView(EnableDisableView):
|
||||
"""View to enable a consumer"""
|
||||
enabled = True
|
||||
|
||||
@ -8,7 +8,6 @@ import datetime
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.urls import reverse_lazy
|
||||
from django.views.generic import FormView
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ if __name__ == "__main__":
|
||||
# issue is really that Django is missing to avoid masking other
|
||||
# exceptions on Python 2.
|
||||
try:
|
||||
import django
|
||||
import django # noqa
|
||||
except ImportError:
|
||||
raise ImportError(
|
||||
"Couldn't import Django. Are you sure it's installed and "
|
||||
|
||||
@ -6,7 +6,6 @@ App config for metrics app
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
|
||||
class MetricsConfig(AppConfig):
|
||||
"""Config for metrics"""
|
||||
name = 'metrics'
|
||||
|
||||
@ -12,8 +12,7 @@ from datetime import datetime
|
||||
from django.conf import settings
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.views.generic import FormView, TemplateView
|
||||
from django.utils.http import urlquote
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
from obp.api import API, APIError
|
||||
|
||||
|
||||
@ -163,7 +163,7 @@ class API(object):
|
||||
# Poor man's caching ...
|
||||
if not self.session_data.get('swagger'):
|
||||
# API throws 500 if authenticated via GatewayLogin ...
|
||||
#response = self.call('GET', settings.API_URL_SWAGGER)
|
||||
# response = self.call('GET', settings.API_URL_SWAGGER)
|
||||
response = requests.get(settings.API_URL_SWAGGER)
|
||||
swagger = self.handle_response(response)
|
||||
self.session_data['swagger'] = swagger
|
||||
|
||||
@ -3,12 +3,6 @@
|
||||
Base authenticator for OBP app
|
||||
"""
|
||||
|
||||
import hashlib
|
||||
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth import login
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
class AuthenticatorError(Exception):
|
||||
"""Exception class for Authenticator errors"""
|
||||
|
||||
@ -50,4 +50,3 @@ class GatewayLoginForm(forms.Form):
|
||||
except AuthenticatorError as err:
|
||||
raise forms.ValidationError(err)
|
||||
return cleaned_data
|
||||
|
||||
|
||||
@ -4,7 +4,6 @@ OAuth authenticator for OBP app
|
||||
"""
|
||||
|
||||
import logging
|
||||
import time
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
|
||||
@ -6,7 +6,6 @@ App config for users app
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
|
||||
class UsersConfig(AppConfig):
|
||||
"""Config for users"""
|
||||
name = 'users'
|
||||
|
||||
@ -6,7 +6,7 @@ Views of users app
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.urls import reverse, reverse_lazy
|
||||
from django.urls import reverse
|
||||
from django.views.generic import FormView, TemplateView, View
|
||||
|
||||
from base.filters import BaseFilter
|
||||
@ -87,14 +87,14 @@ class DetailView(LoginRequiredMixin, FormView):
|
||||
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
self.api = API(request.session.get('obp'))
|
||||
return super(DetailView, self).dispatch(request, *args,**kwargs)
|
||||
return super(DetailView, self).dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_form(self, *args, **kwargs):
|
||||
form = super(DetailView, self).get_form(*args, **kwargs)
|
||||
try:
|
||||
form.fields['bank_id'].choices = self.api.get_bank_id_choices()
|
||||
except APIError as err:
|
||||
messags.error(self.request, err)
|
||||
messages.error(self.request, err)
|
||||
return form
|
||||
|
||||
def form_valid(self, form):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user