From bb15b0dd84bbc1f88e2755f342d4fb586c4634b7 Mon Sep 17 00:00:00 2001 From: gsvr Date: Mon, 22 Aug 2022 20:29:19 +0200 Subject: [PATCH] pep8 --- backend/credits/admin.py | 2 -- backend/credits/models.py | 2 -- backend/credits/tests.py | 2 -- backend/credits/views.py | 2 -- backend/debits/views.py | 2 -- backend/events/models.py | 2 +- backend/events/tasks.py | 2 +- backend/maguire/schema.py | 12 ++++++------ backend/maguire/testsettings.py | 11 ++++++++--- backend/maguire/urls.py | 3 ++- backend/manage.py | 18 +++--------------- 11 files changed, 21 insertions(+), 37 deletions(-) diff --git a/backend/credits/admin.py b/backend/credits/admin.py index 8c38f3f..846f6b4 100644 --- a/backend/credits/admin.py +++ b/backend/credits/admin.py @@ -1,3 +1 @@ -from django.contrib import admin - # Register your models here. diff --git a/backend/credits/models.py b/backend/credits/models.py index 71a8362..6b20219 100644 --- a/backend/credits/models.py +++ b/backend/credits/models.py @@ -1,3 +1 @@ -from django.db import models - # Create your models here. diff --git a/backend/credits/tests.py b/backend/credits/tests.py index 7ce503c..a39b155 100644 --- a/backend/credits/tests.py +++ b/backend/credits/tests.py @@ -1,3 +1 @@ -from django.test import TestCase - # Create your tests here. diff --git a/backend/credits/views.py b/backend/credits/views.py index 91ea44a..60f00ef 100644 --- a/backend/credits/views.py +++ b/backend/credits/views.py @@ -1,3 +1 @@ -from django.shortcuts import render - # Create your views here. diff --git a/backend/debits/views.py b/backend/debits/views.py index 91ea44a..60f00ef 100644 --- a/backend/debits/views.py +++ b/backend/debits/views.py @@ -1,3 +1 @@ -from django.shortcuts import render - # Create your views here. diff --git a/backend/events/models.py b/backend/events/models.py index 202bd8f..e20cc5b 100644 --- a/backend/events/models.py +++ b/backend/events/models.py @@ -79,6 +79,6 @@ def run_task_event_type(): try: getattr(tasks, instance.event_type.replace(".", "_") ).apply_async(kwargs={"event_id": instance.id}) - except: + except Exception: pass transaction.on_commit(run_task_event_type) diff --git a/backend/events/tasks.py b/backend/events/tasks.py index 65db1fa..66f4ab0 100644 --- a/backend/events/tasks.py +++ b/backend/events/tasks.py @@ -8,7 +8,7 @@ class DebitBatchCompleted(Task): """ """ name = "maguire.events.tasks.debit_batch_completed" - l = get_task_logger(__name__) + tl = get_task_logger(__name__) def run(self, event_id, **kwargs): # trigger hook diff --git a/backend/maguire/schema.py b/backend/maguire/schema.py index 2d59f6e..589744f 100644 --- a/backend/maguire/schema.py +++ b/backend/maguire/schema.py @@ -3,15 +3,15 @@ class Query( - debits.schema.Query, - graphene.ObjectType): - pass + debits.schema.Query, + graphene.ObjectType): + pass class Mutation( - debits.schema.Mutation, - graphene.ObjectType): - pass + debits.schema.Mutation, + graphene.ObjectType): + pass schema = graphene.Schema(query=Query, mutation=Mutation) diff --git a/backend/maguire/testsettings.py b/backend/maguire/testsettings.py index 231a9b0..d3e3a0f 100644 --- a/backend/maguire/testsettings.py +++ b/backend/maguire/testsettings.py @@ -1,4 +1,6 @@ -from maguire.settings import * # flake8: noqa +from maguire.settings import * # noqa +import json +import os # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'TESTSEKRET' @@ -27,5 +29,8 @@ BASE_URL = os.environ.get('BASE_URL', 'http://localhost:8000') -DEBIT_CONFIG = json.loads(os.environ.get('DEBIT_CONFIG', '{"base_url": "https://www.slowdebit.co.za:8888/Services/PaymentService.svc/PartnerServices/","authentication": {"service_reference": "37H2-F00Z-735Q-1B11","username": "uname"},"bank_ref": "PICSA","group_code": "PICSA"}')) - +DEBIT_CONFIG = json.loads(os.environ.get( + 'DEBIT_CONFIG', + '{"base_url": "https://www.slowdebit.co.za:8888/Services/PaymentService.svc/' + 'PartnerServices/","authentication": {"service_reference": "37H2-F00Z-735Q-1B11",' + '"username": "uname"},"bank_ref": "PICSA","group_code": "PICSA"}')) diff --git a/backend/maguire/urls.py b/backend/maguire/urls.py index d4c61cf..a6e5d1d 100644 --- a/backend/maguire/urls.py +++ b/backend/maguire/urls.py @@ -26,6 +26,7 @@ def graphql_token_view(): url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^admin/', admin.site.urls), url(r'^graphql', graphql_token_view()), - url(r'^graphiql', staff_member_required(csrf_exempt(GraphQLView.as_view(schema=schema, graphiql=True)))), + url(r'^graphiql', staff_member_required(csrf_exempt( + GraphQLView.as_view(schema=schema, graphiql=True)))), url(r'^api/rest-auth/', include('rest_auth.urls')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/backend/manage.py b/backend/manage.py index 7df0c23..1fa48fb 100755 --- a/backend/manage.py +++ b/backend/manage.py @@ -4,19 +4,7 @@ if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "maguire.settings") - try: - from django.core.management import execute_from_command_line - except ImportError: - # The above import may fail for some other reason. Ensure that the - # issue is really that Django is missing to avoid masking other - # exceptions on Python 2. - try: - import django - except ImportError: - raise ImportError( - "Couldn't import Django. Are you sure it's installed and " - "available on your PYTHONPATH environment variable? Did you " - "forget to activate a virtual environment?" - ) - raise + + from django.core.management import execute_from_command_line + execute_from_command_line(sys.argv)