Browse Source

remove group name from hierarchical tags

merge-requests/139/head
the-boy-sebastian 2 years ago
committed by Bauke
parent
commit
6e6a58830c
  1. 9
      tildes/tildes/views/topic.py

9
tildes/tildes/views/topic.py

@ -124,6 +124,15 @@ def post_group_topics(
# remove any tag that's the same as the group's name # remove any tag that's the same as the group's name
new_topic.tags = [tag for tag in new_topic.tags if tag != str(group.path)] new_topic.tags = [tag for tag in new_topic.tags if tag != str(group.path)]
# remove the group's name from any hierarchical tag
for idx, tag in enumerate(new_topic.tags):
split_tag = tag.split(".")
if split_tag[0] == str(group.path):
tag = ".".join(split_tag[1::])
# remove duplicates
new_topic.tags[idx] = tag
new_topic.tags = list(set(new_topic.tags))
request.apply_rate_limit("topic_post") request.apply_rate_limit("topic_post")
request.db_session.add(new_topic) request.db_session.add(new_topic)

Loading…
Cancel
Save