diff --git a/tildes/tildes/models/group/group.py b/tildes/tildes/models/group/group.py index 7a3ba04..eedbc4c 100644 --- a/tildes/tildes/models/group/group.py +++ b/tildes/tildes/models/group/group.py @@ -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"" diff --git a/tildes/tildes/templates/includes/new_topic_form.jinja2 b/tildes/tildes/templates/includes/new_topic_form.jinja2 index 7954a9d..0d6f7d6 100644 --- a/tildes/tildes/templates/includes/new_topic_form.jinja2 +++ b/tildes/tildes/templates/includes/new_topic_form.jinja2 @@ -48,11 +48,11 @@ {# Hide the tag-adding form in a
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 %}
Add tags (optional) - {{ topic_tagging(autocomplete_options=group.common_topic_tags, value=tags) }} + {{ topic_tagging(autocomplete_options=group.autocomplete_topic_tags, value=tags) }}
{% endif %} diff --git a/tildes/tildes/templates/intercooler/topic_tags_edit.jinja2 b/tildes/tildes/templates/intercooler/topic_tags_edit.jinja2 index bf38379..6c69911 100644 --- a/tildes/tildes/templates/intercooler/topic_tags_edit.jinja2 +++ b/tildes/tildes/templates/intercooler/topic_tags_edit.jinja2 @@ -14,7 +14,7 @@ data-js-remove-on-success > - {{ 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) }}