From de9c86bc1b4a2eb19c1871035077559c8871ca95 Mon Sep 17 00:00:00 2001 From: Deimos Date: Wed, 25 Jul 2018 16:53:44 -0600 Subject: [PATCH] Set default period to "all time" inside groups Currently, the default sort+period combination is "by activity, last 3 days". This works fairly well on the home page, but isn't working well inside individual groups because there usually aren't many posts made yet in a specific group in the last 3 days. Because of this, going into an individual group looks quite empty by default. This commit changes the default *only* when inside a group to be "by activity, all time". This will still be overridden if the user has set up custom defaults. --- tildes/tildes/views/topic.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tildes/tildes/views/topic.py b/tildes/tildes/views/topic.py index d728028..198534c 100644 --- a/tildes/tildes/views/topic.py +++ b/tildes/tildes/views/topic.py @@ -262,6 +262,7 @@ def post_comment_on_topic(request: Request, markdown: str) -> HTTPFound: def _get_default_settings(request: Request, order: Any) -> DefaultSettings: if isinstance(request.context, Group): + is_home_page = False user_settings = ( request.query(UserGroupSettings) .filter( @@ -271,6 +272,7 @@ def _get_default_settings(request: Request, order: Any) -> DefaultSettings: .one_or_none() ) else: + is_home_page = True user_settings = None if user_settings and user_settings.default_order: @@ -292,10 +294,16 @@ def _get_default_settings(request: Request, order: Any) -> DefaultSettings: user_default = request.user.home_default_period default_period = ShortTimePeriod().deserialize(user_default) else: - # default to "all time" if sorting by new, 3d if activity, otherwise - # last 24h + # Overall default periods, if the user doesn't have either a + # group-specific or a home default set up: + # * "all time" if sorting by new + # * "all time" if sorting by activity and inside a group + # * "3 days" if sorting by activity and on home page + # * "1 day" otherwise (sorting by most votes or most comments) if order == TopicSortOption.NEW: default_period = None + elif order == TopicSortOption.ACTIVITY and not is_home_page: + default_period = None elif order == TopicSortOption.ACTIVITY: default_period = SimpleHoursPeriod(72) else: