utils.py 612 Bytes
Newer Older
1
"""
2
Common utility methods and decorators for Mobile APIs.
3
"""
4
from openedx.core.lib.api.view_utils import view_course_access, view_auth_classes
5

6

7
def mobile_course_access(depth=0):
8
    """
9
    Method decorator for a mobile API endpoint that verifies the user has access to the course in a mobile context.
10
    """
11
    return view_course_access(depth=depth, access_action='load_mobile', check_for_milestones=True)
12

13 14 15

def mobile_view(is_user=False):
    """
16
    Function and class decorator that abstracts the authentication and permission checks for mobile api views.
17
    """
18
    return view_auth_classes(is_user)