From da482212803b03146a6710ab1da1d30b83184d75 Mon Sep 17 00:00:00 2001 From: Julen Ruiz Aizpuru Date: Mon, 26 Mar 2018 11:54:42 +0200 Subject: [PATCH] Cleanup: move legalpage prefixes to constant There's not much use in having this as a setting and actually the approach should be revisited altogether. Refs. #318. --- CHANGES.md | 1 + docs/ref-settings.md | 10 --------- pootle/apps/staticpages/context_processors.py | 16 ++++++++++---- pootle/settings/40-apps.conf | 22 +------------------ 4 files changed, 14 insertions(+), 35 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 659e635284..b3d6ed4028 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ Zing Changelog v.next (not released yet) ------------------------- +* Moved `LEGALPAGE_NOCHECK_PREFIXES` into a constant. * Removed captcha middleware and associated setting. * Removed `ZING_INSTANCE_ID`. This can easily be implemented by anyone. * Cleaned up setting names and removed obsoletes: diff --git a/docs/ref-settings.md b/docs/ref-settings.md index 663df67a93..8244bb212a 100644 --- a/docs/ref-settings.md +++ b/docs/ref-settings.md @@ -48,16 +48,6 @@ Controls whether user sign ups are allowed or not. If set to `False`, administrators will still be able to create new user accounts. -### `ZING_LEGALPAGE_NOCHECK_PREFIXES` - -Default: `('/about', '/accounts', '/admin', '/contact', '/jsi18n', '/pages', )` - -List of path prefixes where the `LegalAgreementMiddleware` will check -if the current logged-in user has agreed all the legal documents defined -for the Zing instance. Don't change this unless you know what you're -doing. - - ### `ZING_REPORTS_MARK_FUNC` Default: _""_ (unset) diff --git a/pootle/apps/staticpages/context_processors.py b/pootle/apps/staticpages/context_processors.py index 037a13f2c0..e8a1636cd2 100644 --- a/pootle/apps/staticpages/context_processors.py +++ b/pootle/apps/staticpages/context_processors.py @@ -6,16 +6,24 @@ # or later license. See the LICENSE file for a copy of the license and the # AUTHORS file for copyright and authorship information. -from django.conf import settings - from .models import LegalPage +NOCHECK_PREFIXES = ( + '/about', + '/accounts', + '/admin', + '/contact', + '/jsi18n', + '/pages', + '/xhr', +) + + def agreement(request): """Returns whether the agreement box should be displayed or not.""" request_path = request.META['PATH_INFO'] - nocheck = filter(lambda x: request_path.startswith(x), - settings.ZING_LEGALPAGE_NOCHECK_PREFIXES) + nocheck = filter(lambda x: request_path.startswith(x), NOCHECK_PREFIXES) display_agreement = False if (request.user.is_authenticated and not nocheck and diff --git a/pootle/settings/40-apps.conf b/pootle/settings/40-apps.conf index 2cb3cfac4b..89297d3715 100644 --- a/pootle/settings/40-apps.conf +++ b/pootle/settings/40-apps.conf @@ -1,26 +1,6 @@ # -*- coding: utf-8 -*- -"""Configuration settings for applications used by Pootle.""" - -# -# Pootle -# - - -# Legal Page Agreements -# -# List of paths prefixes where no checks for legal document agreements -# will be enforced -ZING_LEGALPAGE_NOCHECK_PREFIXES = ( - '/about', - '/accounts', - '/admin', - '/contact', - '/jsi18n', - '/pages', - '/xhr', -) - +"""Configuration settings for applications.""" # # webassets