Example #1
0
    def test_page_locked_in_workflow(self):
        workflow, task = self.create_workflow_and_task()
        editor = get_user_model().objects.get(email="*****@*****.**")
        moderator = get_user_model().objects.get(
            email="*****@*****.**")
        superuser = get_user_model().objects.get(email="*****@*****.**")
        christmas_page = EventPage.objects.get(
            url_path="/home/events/christmas/")
        christmas_page.save_revision()
        workflow.start(christmas_page, editor)

        moderator_perms = UserPagePermissionsProxy(moderator).for_page(
            christmas_page)

        # the moderator is in the group assigned to moderate the task, so the page should
        # not be locked for them
        self.assertFalse(moderator_perms.page_locked())

        superuser_perms = UserPagePermissionsProxy(superuser).for_page(
            christmas_page)

        # superusers can moderate any GroupApprovalTask, so the page should not be locked
        # for them
        self.assertFalse(superuser_perms.page_locked())

        editor_perms = UserPagePermissionsProxy(editor).for_page(
            christmas_page)

        # the editor is not in the group assigned to moderate the task, so the page should
        # be locked for them
        self.assertTrue(editor_perms.page_locked())
Example #2
0
    def test_page_locked_for_unlocked_page(self):
        user = get_user_model().objects.get(email="*****@*****.**")
        christmas_page = EventPage.objects.get(
            url_path="/home/events/christmas/")

        perms = UserPagePermissionsProxy(user).for_page(christmas_page)

        self.assertFalse(perms.page_locked())
Example #3
0
    def test_page_locked_for_locked_page_with_global_lock_enabled(self):
        user = get_user_model().objects.get(email="*****@*****.**")
        christmas_page = EventPage.objects.get(
            url_path="/home/events/christmas/")

        # Lock the page
        christmas_page.locked = True
        christmas_page.locked_by = user
        christmas_page.locked_at = timezone.now()
        christmas_page.save()

        perms = UserPagePermissionsProxy(user).for_page(christmas_page)

        # The user who locked the page should now also see the page as locked
        self.assertTrue(perms.page_locked())

        # Other users should see the page as locked, like before
        other_user = get_user_model().objects.get(
            email="*****@*****.**")
        other_perms = UserPagePermissionsProxy(other_user).for_page(
            christmas_page)
        self.assertTrue(other_perms.page_locked())