Skip to content

Commit

Permalink
Cleanup: move legalpage prefixes to constant
Browse files Browse the repository at this point in the history
There's not much use in having this as a setting and actually the
approach should be revisited altogether.

Refs. #318.
  • Loading branch information
julen committed Mar 26, 2018
1 parent 1b0150a commit da48221
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 35 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
10 changes: 0 additions & 10 deletions docs/ref-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 12 additions & 4 deletions pootle/apps/staticpages/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 1 addition & 21 deletions pootle/settings/40-apps.conf
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit da48221

Please sign in to comment.