diff --git a/tildes/tildes/views/topic.py b/tildes/tildes/views/topic.py index 376cd8e..0295cff 100644 --- a/tildes/tildes/views/topic.py +++ b/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 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.db_session.add(new_topic)