コード例 #1
0
    def test_add_unrequested(self):
        add_user_with_status_unrequested(self.user)
        self.assertEqual('unrequested', get_course_creator_status(self.user))

        # Calling add again will be a no-op (even if state is different).
        add_user_with_status_granted(self.admin, self.user)
        self.assertEqual('unrequested', get_course_creator_status(self.user))
コード例 #2
0
ファイル: test_views.py プロジェクト: 6thfdwp/edx-platform
    def test_add_unrequested(self):
        add_user_with_status_unrequested(self.user)
        self.assertEqual('unrequested', get_course_creator_status(self.user))

        # Calling add again will be a no-op (even if state is different).
        add_user_with_status_granted(self.admin, self.user)
        self.assertEqual('unrequested', get_course_creator_status(self.user))
コード例 #3
0
ファイル: test_views.py プロジェクト: 6thfdwp/edx-platform
 def test_user_requested_already_granted(self):
     add_user_with_status_granted(self.admin, self.user)
     self.assertEqual('granted', get_course_creator_status(self.user))
     # Will not "downgrade" to pending because that would require removing the
     # user from the authz course creator group (and that can only be done by an admin).
     user_requested_access(self.user)
     self.assertEqual('granted', get_course_creator_status(self.user))
コード例 #4
0
 def test_user_requested_already_granted(self):
     add_user_with_status_granted(self.admin, self.user)
     self.assertEqual('granted', get_course_creator_status(self.user))
     # Will not "downgrade" to pending because that would require removing the
     # user from the authz course creator group (and that can only be done by an admin).
     user_requested_access(self.user)
     self.assertEqual('granted', get_course_creator_status(self.user))
コード例 #5
0
    def test_user_requested_access(self):
        add_user_with_status_unrequested(self.user)
        self.assertEqual('unrequested', get_course_creator_status(self.user))

        request = RequestFactory().get('/')
        request.user = self.user

        mako_middleware_process_request(request)
        user_requested_access(self.user)
        self.assertEqual('pending', get_course_creator_status(self.user))
コード例 #6
0
    def test_user_requested_access(self):
        add_user_with_status_unrequested(self.user)
        self.assertEqual('unrequested', get_course_creator_status(self.user))

        request = RequestFactory().get('/')
        request.user = self.user

        mako_middleware_process_request(request)
        user_requested_access(self.user)
        self.assertEqual('pending', get_course_creator_status(self.user))
コード例 #7
0
ファイル: test_views.py プロジェクト: gopinath81/vmss
    def test_user_requested_access(self):
        add_user_with_status_unrequested(self.user)
        self.assertEqual('unrequested', get_course_creator_status(self.user))

        self.client.login(username=self.user.username, password='******')

        # The user_requested_access function renders a template that requires
        # request-specific information. Use the django TestClient to supply
        # the appropriate request context.
        self.client.post(reverse('request_course_creator'))
        self.assertEqual('pending', get_course_creator_status(self.user))
コード例 #8
0
    def test_user_requested_access(self):
        add_user_with_status_unrequested(self.user)
        self.assertEqual('unrequested', get_course_creator_status(self.user))

        self.client.login(username=self.user.username, password='******')

        # The user_requested_access function renders a template that requires
        # request-specific information. Use the django TestClient to supply
        # the appropriate request context.
        self.client.post(reverse('request_course_creator'))
        self.assertEqual('pending', get_course_creator_status(self.user))
コード例 #9
0
ファイル: test_views.py プロジェクト: 6thfdwp/edx-platform
    def test_add_granted(self):
        with mock.patch.dict('django.conf.settings.FEATURES', {"ENABLE_CREATOR_GROUP": True}):
            # Calling add_user_with_status_granted impacts is_user_in_course_group_role.
            self.assertFalse(is_user_in_creator_group(self.user))

            add_user_with_status_granted(self.admin, self.user)
            self.assertEqual('granted', get_course_creator_status(self.user))

            # Calling add again will be a no-op (even if state is different).
            add_user_with_status_unrequested(self.user)
            self.assertEqual('granted', get_course_creator_status(self.user))

            self.assertTrue(is_user_in_creator_group(self.user))
コード例 #10
0
ファイル: test_views.py プロジェクト: sam1610/ThemeEdx
    def test_add_granted(self):
        with mock.patch.dict('django.conf.settings.FEATURES', {"ENABLE_CREATOR_GROUP": True}):
            # Calling add_user_with_status_granted impacts is_user_in_course_group_role.
            self.assertFalse(auth.user_has_role(self.user, CourseCreatorRole()))

            add_user_with_status_granted(self.admin, self.user)
            self.assertEqual('granted', get_course_creator_status(self.user))

            # Calling add again will be a no-op (even if state is different).
            add_user_with_status_unrequested(self.user)
            self.assertEqual('granted', get_course_creator_status(self.user))

            self.assertTrue(auth.user_has_role(self.user, CourseCreatorRole()))
コード例 #11
0
    def _get_course_creator_status(self, user):
        """
        Helper method to get user's course creator status.
        """
        from course_creators.views import get_course_creator_status

        return get_course_creator_status(user)
コード例 #12
0
ファイル: library.py プロジェクト: shevious/edx-platform
def get_library_creator_status(user):
    """
    Helper method for returning the library creation status for a particular user,
    taking into account the value LIBRARIES_ENABLED.
    """

    if not LIBRARIES_ENABLED:
        return False
    elif user.is_staff:
        return True
    elif settings.FEATURES.get('ENABLE_CREATOR_GROUP', False):
        return get_course_creator_status(user) == 'granted'
    else:
        return True
コード例 #13
0
ファイル: course.py プロジェクト: robertlight/edx-platform
def _get_course_creator_status(user):
    """
    Helper method for returning the course creator status for a particular user,
    taking into account the values of DISABLE_COURSE_CREATION and ENABLE_CREATOR_GROUP.

    If the user passed in has not previously visited the index page, it will be
    added with status 'unrequested' if the course creator group is in use.
    """
    if user.is_staff:
        course_creator_status = 'granted'
    elif settings.FEATURES.get('DISABLE_COURSE_CREATION', False):
        course_creator_status = 'disallowed_for_this_site'
    elif settings.FEATURES.get('ENABLE_CREATOR_GROUP', False):
        course_creator_status = get_course_creator_status(user)
        if course_creator_status is None:
            # User not grandfathered in as an existing user, has not previously visited the dashboard page.
            # Add the user to the course creator admin table with status 'unrequested'.
            add_user_with_status_unrequested(user)
            course_creator_status = get_course_creator_status(user)
    else:
        course_creator_status = 'granted'

    return course_creator_status
コード例 #14
0
ファイル: library.py プロジェクト: harambee-sa/edx-platform
def get_library_creator_status(user):
    """
    Helper method for returning the library creation status for a particular user,
    taking into account the value LIBRARIES_ENABLED.
    """

    if not LIBRARIES_ENABLED:
        return False
    elif user.is_staff:
        return True
    elif settings.FEATURES.get('ENABLE_CREATOR_GROUP', False):
        return get_course_creator_status(user) == 'granted'
    else:
        return True
コード例 #15
0
ファイル: course.py プロジェクト: raeeschachar/edx-platform
def _get_course_creator_status(user):
    """
    Helper method for returning the course creator status for a particular user,
    taking into account the values of DISABLE_COURSE_CREATION and ENABLE_CREATOR_GROUP.

    If the user passed in has not previously visited the index page, it will be
    added with status 'unrequested' if the course creator group is in use.
    """
    if user.is_staff:
        course_creator_status = 'granted'
    elif settings.FEATURES.get('DISABLE_COURSE_CREATION', False):
        course_creator_status = 'disallowed_for_this_site'
    elif settings.FEATURES.get('ENABLE_CREATOR_GROUP', False):
        course_creator_status = get_course_creator_status(user)
        if course_creator_status is None:
            # User not grandfathered in as an existing user, has not previously visited the dashboard page.
            # Add the user to the course creator admin table with status 'unrequested'.
            add_user_with_status_unrequested(user)
            course_creator_status = get_course_creator_status(user)
    else:
        course_creator_status = 'granted'

    return course_creator_status
コード例 #16
0
ファイル: library.py プロジェクト: yellowsignz/edx-platform
def get_library_creator_status(user):
    """
    Helper method for returning the library creation status for a particular user,
    taking into account the value LIBRARIES_ENABLED.
    """

    if not LIBRARIES_ENABLED:
        return False
    elif user.is_staff:
        return True
    elif settings.FEATURES.get('ENABLE_CREATOR_GROUP', False):
        return get_course_creator_status(user) == 'granted'
    else:
        # EDUCATOR-1924: DISABLE_LIBRARY_CREATION overrides DISABLE_COURSE_CREATION, if present.
        disable_library_creation = settings.FEATURES.get('DISABLE_LIBRARY_CREATION', None)
        disable_course_creation = settings.FEATURES.get('DISABLE_COURSE_CREATION', False)
        if disable_library_creation is not None:
            return not disable_library_creation
        else:
            return not disable_course_creation
コード例 #17
0
ファイル: library.py プロジェクト: cpennington/edx-platform
def get_library_creator_status(user):
    """
    Helper method for returning the library creation status for a particular user,
    taking into account the value LIBRARIES_ENABLED.
    """

    if not LIBRARIES_ENABLED:
        return False
    elif user.is_staff:
        return True
    elif settings.FEATURES.get('ENABLE_CREATOR_GROUP', False):
        return get_course_creator_status(user) == 'granted'
    else:
        # EDUCATOR-1924: DISABLE_LIBRARY_CREATION overrides DISABLE_COURSE_CREATION, if present.
        disable_library_creation = settings.FEATURES.get('DISABLE_LIBRARY_CREATION', None)
        disable_course_creation = settings.FEATURES.get('DISABLE_COURSE_CREATION', False)
        if disable_library_creation is not None:
            return not disable_library_creation
        else:
            return not disable_course_creation
コード例 #18
0
ファイル: test_views.py プロジェクト: 6thfdwp/edx-platform
 def test_user_requested_access(self):
     add_user_with_status_unrequested(self.user)
     self.assertEqual('unrequested', get_course_creator_status(self.user))
     user_requested_access(self.user)
     self.assertEqual('pending', get_course_creator_status(self.user))
コード例 #19
0
 def test_add_user_granted_staff(self):
     # Users marked as is_staff will not be added to the course creator table.
     add_user_with_status_granted(self.admin, self.admin)
     self.assertIsNone(get_course_creator_status(self.admin))
コード例 #20
0
ファイル: test_views.py プロジェクト: 6thfdwp/edx-platform
 def test_table_initially_empty(self):
     self.assertIsNone(get_course_creator_status(self.user))
コード例 #21
0
 def test_user_requested_access(self):
     add_user_with_status_unrequested(self.user)
     self.assertEqual('unrequested', get_course_creator_status(self.user))
     user_requested_access(self.user)
     self.assertEqual('pending', get_course_creator_status(self.user))
コード例 #22
0
 def test_table_initially_empty(self):
     self.assertIsNone(get_course_creator_status(self.user))
コード例 #23
0
ファイル: test_views.py プロジェクト: 6thfdwp/edx-platform
 def test_add_user_granted_staff(self):
     # Users marked as is_staff will not be added to the course creator table.
     add_user_with_status_granted(self.admin, self.admin)
     self.assertIsNone(get_course_creator_status(self.admin))