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

Require Tag type on creation, update #9783

Merged
merged 4 commits into from
Aug 26, 2024

Conversation

jimchamp
Copy link
Collaborator

Closes #9780

Changes to require tag_type and name whenever a Tag is created or updated.

Technical

Testing

Important

Until #9776 is merged, validations will not occur when ?m=edit is used to navigate to the edit view.

While logged in as a librarian, test the following:

  1. Go to /tag/add page and attempt to submit the form without filling the Tag name input, or selecting a Tag type. Expect to see "Required field" messages by these inputs.
  2. Using your preferred tool, send some POST requests to the /tag/add endpoint. Ensure that you receive a 400 when either the name or tag_type is missing from the request.
  3. Repeat step 1 on an existing Tag's edit page.
  4. Repeat step 2 on an existing Tag's edit page.

Screenshot

Stakeholders

jimchamp and others added 4 commits August 20, 2024 16:22
Adds default "Select" option.  Ensures that option order is maintained,
regardless of what type of tag is being edited.  This change more
closely matches the type options in the "Add tag" view, making it easier
to combine these two very similar templates in the near future.
@@ -62,6 +66,10 @@ def POST(self):
raise web.unauthorized(message='Permission denied to add tags')

i = utils.unflatten(i)

if not i.tag_name or not i.tag_type:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Will DRY this to use validate_tag when work begins on #9784. Today, the "Tag Name" input is identified differently in both forms (name in one; tag_name in the other).

Comment on lines +38 to +44
<select name="tag_type" id="tag_type" required>
<option value="">$_("Select")</option>
$ tag_types = get_tag_types()
$for tag_type in tag_types:
$if tag_type != page.tag_type:
$if tag_type == page.tag_type:
<option value="$tag_type" selected>$tag_type</option>
$else:
Copy link
Collaborator Author

@jimchamp jimchamp Aug 21, 2024

Choose a reason for hiding this comment

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

These changes make this tag type selector roughly the same as the selector in the "add tag" view, and were largely made to support #9784.

@mekarpeles mekarpeles merged commit ea5ada0 into internetarchive:master Aug 26, 2024
4 checks passed
@jimchamp jimchamp deleted the 9780/bug/require-tag-type branch August 27, 2024 18:53
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.

Tags can be created/updated without a type
2 participants