From b37f365f7cea05522c7aa9daa2a5c29092e609c8 Mon Sep 17 00:00:00 2001 From: Deimos Date: Fri, 10 May 2019 13:52:08 -0600 Subject: [PATCH] Allow linking to topics without any title slug This is a bit risky because of potential conflicts with other routes (like "~group_name/new_topic" if "new_topic" was a valid ID36), but it was being used a little before so it's probably better to have available. --- tildes/tildes/routes.py | 1 + tildes/tildes/views/topic.py | 1 + 2 files changed, 2 insertions(+) diff --git a/tildes/tildes/routes.py b/tildes/tildes/routes.py index 0179dac..45e5609 100644 --- a/tildes/tildes/routes.py +++ b/tildes/tildes/routes.py @@ -37,6 +37,7 @@ def includeme(config: Configurator) -> None: config.add_route("group_topics", "/topics", factory=group_by_path) config.add_route("topic", "/{topic_id36}/{title}", factory=topic_by_id36) + config.add_route("topic_no_title", "/{topic_id36}", factory=topic_by_id36) config.add_route("user", "/user/{username}", factory=user_by_username) with config.route_prefix_context("/user/{username}"): diff --git a/tildes/tildes/views/topic.py b/tildes/tildes/views/topic.py index c67fcfa..856b2b3 100644 --- a/tildes/tildes/views/topic.py +++ b/tildes/tildes/views/topic.py @@ -255,6 +255,7 @@ def get_new_topic_form(request: Request) -> dict: @view_config(route_name="topic", renderer="topic.jinja2") +@view_config(route_name="topic_no_title", renderer="topic.jinja2") @use_kwargs({"comment_order": Enum(CommentTreeSortOption, missing="relevance")}) def get_topic(request: Request, comment_order: CommentTreeSortOption) -> dict: """View a single topic."""