Skip to content

Commit

Permalink
Merge pull request #2033 from rebeccacremona/disable-section-export
Browse files Browse the repository at this point in the history
Disable export of sections and resources
  • Loading branch information
rebeccacremona authored Oct 25, 2023
2 parents 95065cc + 33d1ba1 commit 5b46bcb
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 25 deletions.
4 changes: 2 additions & 2 deletions web/main/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@
path("casebooks/new", views.new_casebook, name="new_casebook"),
# export
path("casebooks/<casebook:node>/export.<file_type>", views.export, name="export_casebook"),
path("sections/<section:node>/export.<file_type>", views.export, name="export_section"),
path("resources/<resource:node>/export.<file_type>", views.export, name="export_resource"),
# path("sections/<section:node>/export.<file_type>", views.export, name="export_section"),
# path("resources/<resource:node>/export.<file_type>", views.export, name="export_resource"),
# Reading mode
path(
"casebooks/<idslug:casebook_param>/as-printable-html/",
Expand Down
77 changes: 54 additions & 23 deletions web/main/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,45 +267,76 @@ def actions(request, context):
# These pages allow the same actions regardless of node types
##
When a logged out user visits casebooks, sections, and resources:
>>> for o in [published, published_section, published_resource]:
When a logged out user visits casebooks:
>>> for o in [published]:
... check_response(
... client.get(o.get_absolute_url()),
... content_includes='actions="exportable"'
... content_includes='data-actions="exportable"'
... )
When a collaborator views a published casebook WITHOUT a draft, or
any of that casebook's sections or resources:
>>> for o in [published, published_section, published_resource]:
When a logged out user visits sections and resources:
>>> for o in [published_section, published_resource]:
... check_response(
... client.get(o.get_absolute_url()),
... content_includes='data-actions=""'
... )
When a collaborator views a published casebook WITHOUT a draft
>>> for o in [published]:
... check_response(
... client.get(o.get_absolute_url(), as_user=published.testing_editor),
... content_includes='data-actions="exportable,cloneable,can_create_draft"'
... )
When a collaborator views the sections or resources of a published casebook WITHOUT a draft:
>>> for o in [published_section, published_resource]:
... check_response(
... client.get(o.get_absolute_url(), as_user=published.testing_editor),
... content_includes='actions="exportable,cloneable,can_create_draft"'
... content_includes='data-actions="cloneable,can_create_draft"'
... )
When a collaborator views a published casebook WITH a draft, or
any of that casebook's sections or resources:
>>> for o in [with_draft, with_draft_section, with_draft_resource]:
When a collaborator views a published casebook WITH a draft:
>>> for o in [with_draft]:
... check_response(
... client.get(o.get_absolute_url(), as_user=with_draft.testing_editor),
... content_includes='actions="exportable,cloneable,publishable,can_view_existing_draft"'
... )
When a collaborator views the "preview" page of a private, never published casebook, or
the preview pages of any of that casebook's sections or resources:
>>> for o in [private, private_section, private_resource]:
When a collaborator views the sections or resources of a published casebook WITH a draft:
>>> for o in [with_draft_section, with_draft_resource]:
... check_response(
... client.get(o.get_absolute_url(), as_user=with_draft.testing_editor),
... content_includes='actions="cloneable,publishable,can_view_existing_draft"'
... )
When a collaborator views the "preview" page of a private, never published casebook:
>>> for o in [private]:
... check_response(
... client.get(o.get_absolute_url(), as_user=private.testing_editor),
... content_includes='actions="exportable,cloneable,publishable,can_be_directly_edited"'
... )
When a collaborator views the "preview" page of a draft of an already-published casebook, or
the preview pages of any of that casebook's sections or resources:
>>> for o in [draft, draft_section, draft_resource]:
When a collaborator views the "preview" page of the sections or resources of a private, never published casebook:
>>> for o in [private_section, private_resource]:
... check_response(
... client.get(o.get_absolute_url(), as_user=private.testing_editor),
... content_includes='actions="cloneable,publishable,can_be_directly_edited"'
... )
When a collaborator views the "preview" page of a draft of an already-published casebook:
>>> for o in [draft]:
... check_response(
... client.get(o.get_absolute_url(), as_user=draft.testing_editor),
... content_includes='actions="exportable,publishable,can_be_directly_edited"'
... )
When a collaborator views the "preview" page of the sections or resources of a draft of an already-published casebook:
>>> for o in [draft_section, draft_resource]:
... check_response(
... client.get(o.get_absolute_url(), as_user=draft.testing_editor),
... content_includes='actions="publishable,can_be_directly_edited"'
... )
##
# These pages allow different actions, depending on the node type
##
Expand All @@ -329,39 +360,39 @@ def actions(request, context):
When a collaborator views the "edit" page of a section in a private, never-published casebook
>>> check_response(
... client.get(private_section.get_edit_url(), as_user=private.testing_editor),
... content_includes='actions="exportable,previewable,can_save_nodes,can_add_nodes"'
... content_includes='actions="previewable,can_save_nodes,can_add_nodes"'
... )
When a collaborator views the "edit" page of a section in draft of an already-published casebook
>>> check_response(
... client.get(draft_section.get_edit_url(), as_user=draft.testing_editor),
... content_includes='actions="exportable,previewable,publishable,can_save_nodes,can_add_nodes"'
... content_includes='actions="previewable,publishable,can_save_nodes,can_add_nodes"'
... )
# Resource
When a collaborator views the "edit" page of a resource in a private, never-published casebook
>>> check_response(
... client.get(private_resource.get_edit_url(), as_user=private.testing_editor),
... content_includes='actions="exportable,previewable,can_save_nodes"'
... content_includes='actions="previewable,can_save_nodes"'
... )
When a collaborator views the "edit" page of a resource in draft of an already-published casebook
>>> check_response(
... client.get(draft_resource.get_edit_url(), as_user=draft.testing_editor),
... content_includes='actions="exportable,previewable,publishable,can_save_nodes"'
... content_includes='actions="previewable,publishable,can_save_nodes"'
... )
When a collaborator views the "annotate" page of a resource in a private, never-published casebook
>>> check_response(
... client.get(private_resource.get_annotate_url(), as_user=private.testing_editor),
... content_includes='actions="exportable,previewable"'
... content_includes='actions="previewable"'
... )
When a collaborator views the "annotate" page of a resource in draft of an already-published casebook
>>> check_response(
... client.get(draft_resource.get_annotate_url(), as_user=draft.testing_editor),
... content_includes='actions="exportable,previewable,publishable"'
... content_includes='actions="previewable,publishable"'
... )
"""
Expand Down Expand Up @@ -393,7 +424,7 @@ def actions(request, context):

actions = OrderedDict(
[
("exportable", True),
("exportable", view in ["edit_casebook", "casebook"]),
("cloneable", cloneable),
("previewable", context.get("editing", False)),
("publishable", publishable),
Expand Down

0 comments on commit 5b46bcb

Please sign in to comment.