Skip to content

Commit

Permalink
chore: add docstring, missing parameters
Browse files Browse the repository at this point in the history
Refs: HP-2490
  • Loading branch information
danipran committed Jul 18, 2024
1 parent 8853c97 commit 7dc1a82
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions open_city_profile/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,20 @@


def _use_context_tests(*test_funcs):
"""
Decorator for running context tests before the decorated function.
E.g. to create a decorator that checks that the user is authenticated::
def _require_authenticated(context):
# Check that the user is authenticated
...
@_use_context_tests(_require_authenticated)
def login_required():
pass
"""

def decorator(decorator_function):
@wraps(decorator_function)
def wrapper(function):
Expand Down Expand Up @@ -61,12 +75,12 @@ def permission_checker(context):


@_use_context_tests(_require_authenticated)
def login_required():
def login_required(*_, **__):
"""Decorator for checking that the user is logged in"""


@_use_context_tests(_require_authenticated, _require_service)
def login_and_service_required():
def login_and_service_required(*_, **__):
"""Decorator for checking that the user is logged in and service is known"""


Expand Down

0 comments on commit 7dc1a82

Please sign in to comment.