From 6e6a58830ce55d04ce13d1ed3cc6cd129b2943e3 Mon Sep 17 00:00:00 2001 From: the-boy-sebastian Date: Sat, 10 Jun 2023 20:17:57 +0100 Subject: [PATCH 1/2] remove group name from hierarchical tags --- tildes/tildes/views/topic.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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) From 80f45c0b9296db3d399831f40ae23684d4e33ad5 Mon Sep 17 00:00:00 2001 From: the-boy-sebastian Date: Sat, 10 Jun 2023 20:39:07 +0100 Subject: [PATCH 2/2] fix misplaced comment --- tildes/tildes/views/topic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tildes/tildes/views/topic.py b/tildes/tildes/views/topic.py index 0295cff..ef10df9 100644 --- a/tildes/tildes/views/topic.py +++ b/tildes/tildes/views/topic.py @@ -129,8 +129,8 @@ def post_group_topics( split_tag = tag.split(".") if split_tag[0] == str(group.path): tag = ".".join(split_tag[1::]) - # remove duplicates new_topic.tags[idx] = tag + # remove duplicates new_topic.tags = list(set(new_topic.tags)) request.apply_rate_limit("topic_post")