From cde35515c72756f58189ce15783424c95fb8fc23 Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Tue, 27 Nov 2018 10:56:40 +0100 Subject: [PATCH] Fix prospector errors and move secret_key to yaml config --- manage.py | 1 + passbook/core/settings.py | 2 +- passbook/lib/default.yml | 1 + passbook/lib/templatetags/__init__.py | 0 passbook/lib/templatetags/reflection.py | 4 ---- passbook/lib/templatetags/utils.py | 11 ++++++----- passbook/oauth_client/views/core.py | 2 +- 7 files changed, 10 insertions(+), 11 deletions(-) create mode 100644 passbook/lib/templatetags/__init__.py diff --git a/manage.py b/manage.py index 554e96deb..aeadd85a4 100755 --- a/manage.py +++ b/manage.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +"""Django manage.py""" import os import sys diff --git a/passbook/core/settings.py b/passbook/core/settings.py index 76e14027a..c93ae9bab 100644 --- a/passbook/core/settings.py +++ b/passbook/core/settings.py @@ -27,7 +27,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__fil # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = '9$@r!d^1^jrn#fk#1#@ks#9&i$^s#1)_13%$rwjrhd=e8jfi_s' +SECRET_KEY = CONFIG.get('secret_key') # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True diff --git a/passbook/lib/default.yml b/passbook/lib/default.yml index 5a64501cf..0e2041c92 100644 --- a/passbook/lib/default.yml +++ b/passbook/lib/default.yml @@ -29,6 +29,7 @@ secure_proxy_header: redis: localhost # Error reporting, sends stacktrace to sentry.services.beryju.org error_report_enabled: true +secret_key: 9$@r!d^1^jrn#fk#1#@ks#9&i$^s#1)_13%$rwjrhd=e8jfi_s passbook: sign_up: diff --git a/passbook/lib/templatetags/__init__.py b/passbook/lib/templatetags/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/passbook/lib/templatetags/reflection.py b/passbook/lib/templatetags/reflection.py index 27f2415bf..cb59d2558 100644 --- a/passbook/lib/templatetags/reflection.py +++ b/passbook/lib/templatetags/reflection.py @@ -2,10 +2,6 @@ from logging import getLogger from django import template -from django.apps import AppConfig -from django.core.cache import cache -from django.urls import reverse -from django.urls.exceptions import NoReverseMatch register = template.Library() LOGGER = getLogger(__name__) diff --git a/passbook/lib/templatetags/utils.py b/passbook/lib/templatetags/utils.py index c4befd2fa..17b0962d3 100644 --- a/passbook/lib/templatetags/utils.py +++ b/passbook/lib/templatetags/utils.py @@ -145,10 +145,10 @@ def related_models(context, model_path): user = request.user model = path_to_class(model_path) - if not issubclass(model, UserAcquirable): - # model_path is not actually a module - # so we can't assume that it's usable - return [] + # if not issubclass(model, UserAcquirable): + # # model_path is not actually a module + # # so we can't assume that it's usable + # return [] return model.objects.filter(users__in=[user]) @@ -161,4 +161,5 @@ def unslug(_input): @register.filter(name='css_class') def css_class(field, css): - return field.as_widget(attrs={"class": css}) + """Add css class to form field""" + return field.as_widget(attrs={"class": css}) diff --git a/passbook/oauth_client/views/core.py b/passbook/oauth_client/views/core.py index 77ca72aa0..0de069cae 100644 --- a/passbook/oauth_client/views/core.py +++ b/passbook/oauth_client/views/core.py @@ -195,7 +195,7 @@ class OAuthCallback(OAuthClientMixin, View): def handle_new_user(self, source, access, info): "Create a shell auth.User and redirect." was_authenticated = False - if self.request.user.is_authenticated: # pylint: disable=no-else-return + if self.request.user.is_authenticated: # there's already a user logged in, just link them up user = self.request.user was_authenticated = True