diff --git a/tildes/tildes/views/topic.py b/tildes/tildes/views/topic.py index c3a8c0f..cca528b 100644 --- a/tildes/tildes/views/topic.py +++ b/tildes/tildes/views/topic.py @@ -48,9 +48,11 @@ def post_group_topics( request: Request, title: str, markdown: str, link: str, tags: str ) -> HTTPFound: """Post a new topic to a group.""" + group = request.context + if link: new_topic = Topic.create_link_topic( - group=request.context, author=request.user, title=title, link=link + group=group, author=request.user, title=title, link=link ) # if they specified both a link and markdown, use the markdown to post an @@ -66,7 +68,7 @@ def post_group_topics( ) else: new_topic = Topic.create_text_topic( - group=request.context, author=request.user, title=title, markdown=markdown + group=group, author=request.user, title=title, markdown=markdown ) try: @@ -74,6 +76,9 @@ def post_group_topics( except ValidationError: raise ValidationError({"tags": ["Invalid tags"]}) + # 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)] + request.apply_rate_limit("topic_post") request.db_session.add(new_topic)