-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Require Tag type on creation, update #9783
Conversation
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.
for more information, see https://pre-commit.ci
@@ -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: |
There was a problem hiding this comment.
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).
<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: |
There was a problem hiding this comment.
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.
Closes #9780
Changes to require
tag_type
andname
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:/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.POST
requests to the/tag/add
endpoint. Ensure that you receive a400
when either thename
ortag_type
is missing from the request.Screenshot
Stakeholders