Skip to content
Snippets Groups Projects
Commit e0681f8f authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Merge branch '247-add-predicate-that-checks-for-a-preference' into 'master'

Resolve "Add predicate that checks for a preference"

Closes #247

See merge request AlekSIS!246
parents 9752dfb1 28199a3d
No related branches found
No related tags found
1 merge request!246Resolve "Add predicate that checks for a preference"
Pipeline #1934 failed
......@@ -8,6 +8,7 @@ from guardian.shortcuts import get_objects_for_user
from rules import predicate
from ..models import Group
from .core_helpers import get_site_preferences
from .core_helpers import has_person as has_person_helper
......@@ -66,6 +67,17 @@ def has_any_object(perm: str, klass):
return fn
def is_site_preference_set(section: str, pref: str):
"""Check the boolean value of a given site preference."""
name = f"check_site_preference:{section}__{pref}"
@predicate(name)
def fn() -> bool:
return bool(get_site_preferences()[f"{section}__{pref}"])
return fn
@predicate
def has_person(user: User) -> bool:
"""Predicate which checks whether a user has a linked person."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment