Esempio n. 1
0
    def test_editable_pages_for_non_editing_user(self):
        user = get_user_model().objects.get(
            email="*****@*****.**")
        homepage = Page.objects.get(url_path="/home/")
        christmas_page = EventPage.objects.get(
            url_path="/home/events/christmas/")
        unpublished_event_page = EventPage.objects.get(
            url_path="/home/events/tentative-unpublished-event/")
        someone_elses_event_page = EventPage.objects.get(
            url_path="/home/events/someone-elses-event/")

        user_perms = UserPagePermissionsProxy(user)
        editable_pages = user_perms.editable_pages()
        can_edit_pages = user_perms.can_edit_pages()
        publishable_pages = user_perms.publishable_pages()
        can_publish_pages = user_perms.can_publish_pages()

        self.assertFalse(editable_pages.filter(id=homepage.id).exists())
        self.assertFalse(editable_pages.filter(id=christmas_page.id).exists())
        self.assertFalse(
            editable_pages.filter(id=unpublished_event_page.id).exists())
        self.assertFalse(
            editable_pages.filter(id=someone_elses_event_page.id).exists())

        self.assertFalse(can_edit_pages)

        self.assertFalse(publishable_pages.filter(id=homepage.id).exists())
        self.assertFalse(
            publishable_pages.filter(id=christmas_page.id).exists())
        self.assertFalse(
            publishable_pages.filter(id=unpublished_event_page.id).exists())
        self.assertFalse(
            publishable_pages.filter(id=someone_elses_event_page.id).exists())

        self.assertFalse(can_publish_pages)
Esempio n. 2
0
def usage(request, pk):
    workflow = get_object_or_404(Workflow, id=pk)

    perms = UserPagePermissionsProxy(request.user)

    pages = workflow.all_pages() & perms.editable_pages()
    paginator = Paginator(pages, per_page=10)
    pages = paginator.get_page(request.GET.get("p"))

    return render(
        request,
        "wagtailadmin/workflows/usage.html",
        {
            "workflow": workflow,
            "used_by": pages,
        },
    )