Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable export of sections and resources #2033

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading