mirror of
https://gitlab.com/tildes/tildes.git
synced 2026-04-16 06:18:34 +02:00
Add global autocomplete tags
This is kind of hacky again (and shouldn't contain the coronavirus tag over the long term), but makes sure that the "spoiler", "nsfw", and "coronaviruses.covid19" tags are always offered as autocomplete options, no matter how common they are in the topic's group.
This commit is contained in:
@@ -86,6 +86,15 @@ class Group(DatabaseModel):
|
||||
else:
|
||||
self.sidebar_rendered_html = None
|
||||
|
||||
@property
|
||||
def autocomplete_topic_tags(self) -> List[str]:
|
||||
"""Return the topic tags that should be offered as autocomplete options."""
|
||||
global_options = ["nsfw", "spoiler", "coronaviruses.covid19"]
|
||||
|
||||
return self.common_topic_tags + [
|
||||
tag for tag in global_options if tag not in self.common_topic_tags
|
||||
]
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""Display the group's path and ID as its repr format."""
|
||||
return f"<Group {self.path} ({self.group_id})>"
|
||||
|
||||
@@ -48,11 +48,11 @@
|
||||
|
||||
{# Hide the tag-adding form in a <details> unless it should be shown for this user #}
|
||||
{% if request.user.show_tags_on_new_topic %}
|
||||
{{ topic_tagging(autocomplete_options=group.common_topic_tags, value=tags) }}
|
||||
{{ topic_tagging(autocomplete_options=group.autocomplete_topic_tags, value=tags) }}
|
||||
{% else %}
|
||||
<details>
|
||||
<summary>Add tags (optional)</summary>
|
||||
{{ topic_tagging(autocomplete_options=group.common_topic_tags, value=tags) }}
|
||||
{{ topic_tagging(autocomplete_options=group.autocomplete_topic_tags, value=tags) }}
|
||||
</details>
|
||||
{% endif %}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
data-js-remove-on-success
|
||||
>
|
||||
<input type="hidden" name="conflict_check" id="conflict_check" value="{{ topic.tags|join(",") }}">
|
||||
{{ topic_tagging(value=topic.tags|join(', '), auto_focus=True, autocomplete_options=topic.group.common_topic_tags) }}
|
||||
{{ topic_tagging(value=topic.tags|join(', '), auto_focus=True, autocomplete_options=topic.group.autocomplete_topic_tags) }}
|
||||
<div class="form-buttons">
|
||||
<button class="btn btn-primary" type="submit">Save tags</button>
|
||||
<button type="button" class="btn btn-link" data-js-cancel-button>Cancel</button>
|
||||
|
||||
Reference in New Issue
Block a user