Skip to content

Add delete button to Tag edit view#12141

Merged
mekarpeles merged 2 commits intointernetarchive:masterfrom
jimchamp:delete-tag
Mar 20, 2026
Merged

Add delete button to Tag edit view#12141
mekarpeles merged 2 commits intointernetarchive:masterfrom
jimchamp:delete-tag

Conversation

@jimchamp
Copy link
Copy Markdown
Collaborator

Addresses #11878

Adds "Delete" button to Tag edit views. Delete button is only rendered for admins and super-librarians.

Clicking "Delete" will change the affected Tag's type to /type/delete.

Delete functionality was already present in the Tag edit POST handler, so no server-side code changes were needed.

Technical

Testing

Screenshot

Stakeholders

Copilot AI review requested due to automatic review settings March 19, 2026 23:42
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Tag edit template to surface an admin-only “Delete Record” action, wiring it to the existing _delete POST behavior that marks a Tag as /type/delete.

Changes:

  • Add a “Delete Record” submit button to the tag edit header, shown only when editing an existing tag.
  • Gate the delete button behind an admin/super-librarian check in the template.
  • Add an id to the tag edit <form> so the header button can submit it via the form= attribute.

Comment on lines +12 to +16
$if ctx.user and (ctx.user.is_admin() or ctx.user.is_super_librarian()):
<span class="adminOnly right">
<button type="submit" value="$_('Delete Record')" name="_delete" title="$_('Delete Record')" id="delete"
form="tag-form">$_("Delete Record")</button>
</span>
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

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

The delete button’s role gating doesn’t match the server-side authorization in plugins/upstream/addtag.py: tag_edit.has_permission() allows admins/curators (and certain deputies) to POST updates, and the delete path triggers on any POST containing _delete. As a result (1) curators/deputies can still delete a tag by crafting a POST even though the UI hides the button, and (2) is_super_librarian() is checked here but isn’t included in tag_edit.has_permission(), so super-librarians may not be able to reach this page unless they’re also admins/curators. Recommend enforcing the intended delete permission check in the POST handler (not just the template) and aligning the UI condition with the backend’s allowed groups (or vice versa).

Copilot uses AI. Check for mistakes.
@mekarpeles mekarpeles self-assigned this Mar 20, 2026
@mekarpeles mekarpeles merged commit e15d8c2 into internetarchive:master Mar 20, 2026
3 checks passed
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.

3 participants