Skip to content

Prevent creating draftsharing link snippets via admin - #13

Open
kevinhowbrook wants to merge 1 commit into
torchbox:mainfrom
kevinhowbrook:fix/issue-12-hide-add-link
Open

Prevent creating draftsharing link snippets via admin#13
kevinhowbrook wants to merge 1 commit into
torchbox:mainfrom
kevinhowbrook:fix/issue-12-hide-add-link

Conversation

@kevinhowbrook

@kevinhowbrook kevinhowbrook commented Feb 6, 2026

Copy link
Copy Markdown

Resolves #12

Introduce a custom permission policy to disable the add action on the draftsharing link snippet viewset and add admin view tests to ensure the add button is hidden. This is opposed to creating a form here to generate a link, which seems a bit counterintuitive to me.

Before:
image

After:
image

@kevinhowbrook
kevinhowbrook force-pushed the fix/issue-12-hide-add-link branch from 0497ace to 7722e3c Compare February 6, 2026 11:35
@kevinhowbrook
kevinhowbrook marked this pull request as draft February 6, 2026 11:36
@kevinhowbrook
kevinhowbrook force-pushed the fix/issue-12-hide-add-link branch 2 times, most recently from 0827e13 to 055afc6 Compare February 6, 2026 11:48
@kevinhowbrook
kevinhowbrook marked this pull request as ready for review February 6, 2026 11:51
@kevinhowbrook
kevinhowbrook force-pushed the fix/issue-12-hide-add-link branch from 055afc6 to b6ce810 Compare February 6, 2026 11:58
@tm-kn

tm-kn commented Feb 6, 2026

Copy link
Copy Markdown
Member

Suggestion: Could also consider removing add from WagtaildraftsharingLink.Meta.default_permissions and add a data migration to remove the existing permission in the system.

https://docs.djangoproject.com/en/6.0/ref/models/options/#default-permissions

return False
return super().user_has_permission(user, action)

class WagtaildraftsharingLinkSnippetViewSet(SnippetViewSet):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: Could also add_view_class = None to ensure that code path is not working, but redundant. There's no one way to disable the add view I guess.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that doesnt work on wagtail 5 though i dont think?

Introduce a custom permission policy to disable the add action on the draftsharing link snippet viewset and add admin view tests to ensure the add button is hidden.
@kevinhowbrook
kevinhowbrook force-pushed the fix/issue-12-hide-add-link branch from b6ce810 to d604024 Compare February 6, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

“Add new draftsharing link” does nothing on Draftsharing links page

2 participants