From 58ea6abce48d3f385cb225577d2178261407635b Mon Sep 17 00:00:00 2001 From: Yohann D'ANELLO Date: Wed, 11 Mar 2020 15:13:34 +0100 Subject: [PATCH] Fix template tags to make tox happy --- apps/logs/signals.py | 3 +++ apps/note/templatetags/__init__.py | 11 +++-------- apps/note/templatetags/getenv.py | 6 ++++++ apps/note/templatetags/pretty_money.py | 6 ++++++ note_kfet/settings/__init__.py | 2 +- note_kfet/settings/development.py | 2 +- note_kfet/settings/production.py | 4 ++-- 7 files changed, 22 insertions(+), 12 deletions(-) diff --git a/apps/logs/signals.py b/apps/logs/signals.py index ab196291..a6b75b50 100644 --- a/apps/logs/signals.py +++ b/apps/logs/signals.py @@ -17,6 +17,9 @@ from .models import Changelog EXCLUDED = [ 'admin.logentry', 'authtoken.token', + 'cas_server.proxygrantingticket', + 'cas_server.proxyticket', + 'cas_server.serviceticket', 'cas_server.user', 'cas_server.userattributes', 'contenttypes.contenttype', diff --git a/apps/note/templatetags/__init__.py b/apps/note/templatetags/__init__.py index 19b8e45b..6f6700c5 100644 --- a/apps/note/templatetags/__init__.py +++ b/apps/note/templatetags/__init__.py @@ -1,12 +1,7 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later -from django import template +from . import getenv +from . import pretty_money -from .getenv import getenv -from .pretty_money import pretty_money - -register = template.Library() - -register.filter('getenv', getenv) -register.filter('pretty_money', pretty_money) +print(getenv, pretty_money, file=None) # Useless, but tox is happy diff --git a/apps/note/templatetags/getenv.py b/apps/note/templatetags/getenv.py index 7710a389..c133cb8f 100644 --- a/apps/note/templatetags/getenv.py +++ b/apps/note/templatetags/getenv.py @@ -1,8 +1,14 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later +from django import template + import os def getenv(value): return os.getenv(value) + + +register = template.Library() +register.filter('getenv', getenv) diff --git a/apps/note/templatetags/pretty_money.py b/apps/note/templatetags/pretty_money.py index 5db2a1c0..12530c6e 100644 --- a/apps/note/templatetags/pretty_money.py +++ b/apps/note/templatetags/pretty_money.py @@ -1,6 +1,8 @@ # Copyright (C) 2018-2020 by BDE ENS Paris-Saclay # SPDX-License-Identifier: GPL-3.0-or-later +from django import template + def pretty_money(value): if value % 100 == 0: @@ -14,3 +16,7 @@ def pretty_money(value): abs(value) // 100, abs(value) % 100, ) + + +register = template.Library() +register.filter('pretty_money', pretty_money) diff --git a/note_kfet/settings/__init__.py b/note_kfet/settings/__init__.py index 10b21970..4a5deff8 100644 --- a/note_kfet/settings/__init__.py +++ b/note_kfet/settings/__init__.py @@ -51,7 +51,7 @@ except ImportError: if "cas" in INSTALLED_APPS: MIDDLEWARE += ['cas.middleware.CASMiddleware'] # CAS Settings - CAS_SERVER_URL = "https://" + os.getenv("NOTE_URL") + "/cas/" + CAS_SERVER_URL = "https://" + os.getenv("NOTE_URL", "note.example.com") + "/cas/" CAS_AUTO_CREATE_USER = False CAS_LOGO_URL = "/static/img/Saperlistpopette.png" CAS_FAVICON_URL = "/static/favicon/favicon-32x32.png" diff --git a/note_kfet/settings/development.py b/note_kfet/settings/development.py index 61f6d530..a949013b 100644 --- a/note_kfet/settings/development.py +++ b/note_kfet/settings/development.py @@ -39,7 +39,7 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' # EMAIL_HOST_USER = 'change_me' # EMAIL_HOST_PASSWORD = 'change_me' -SERVER_EMAIL = 'no-reply@' + os.getenv("DOMAIN") +SERVER_EMAIL = 'no-reply@' + os.getenv("DOMAIN", "example.com") # Security settings SECURE_CONTENT_TYPE_NOSNIFF = False diff --git a/note_kfet/settings/production.py b/note_kfet/settings/production.py index ea1e9739..c23a29e3 100644 --- a/note_kfet/settings/production.py +++ b/note_kfet/settings/production.py @@ -39,7 +39,7 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' # EMAIL_HOST_USER = 'change_me' # EMAIL_HOST_PASSWORD = 'change_me' -SERVER_EMAIL = 'no-reply@' + os.getenv("DOMAIN") +SERVER_EMAIL = 'no-reply@' + os.getenv("DOMAIN", "example.com") # Security settings SECURE_CONTENT_TYPE_NOSNIFF = False @@ -51,4 +51,4 @@ X_FRAME_OPTIONS = 'DENY' SESSION_COOKIE_AGE = 60 * 60 * 3 # CAS Client settings -CAS_SERVER_URL = "https://" + os.getenv("NOTE_URL") + "/cas/" +CAS_SERVER_URL = "https://" + os.getenv("NOTE_URL", "note.example.com") + "/cas/"