DEV: Sidebar default tags and categories are determined at user creation (#18620)

The previous sidebar default tags and categories implementation did not
allow for a user to configure their sidebar to have no categories or
tags. This commit changes how the defaults are applied. When a user is being created,
we create the SidebarSectionLink records based on the `default_sidebar_categories` and
`default_sidebar_tags` site settings. SidebarSectionLink records are
only created for categories and tags which the user has visibility on at
the point of user creation.

With this change, we're also adding the ability for admins to apply
changes to the `default_sidebar_categories` and `default_sidebar_tags`
site settings historically when changing their site setting. When a new
category/tag has been added to the default, the new category/tag will be
added to the sidebar for all users if the admin elects to apply the changes historically.
Like wise when a tag/category is removed, the tag/category will be
removed from the sidebar for all users if the admin elects to apply the
changes historically.

Internal Ref: /t/73500
This commit is contained in:
Alan Guo Xiang Tan
2022-10-27 06:38:50 +08:00
committed by GitHub
parent a473e352de
commit 1b56a55f50
14 changed files with 637 additions and 107 deletions

View File

@ -339,7 +339,7 @@ class CurrentUserSerializer < BasicUserSerializer
end
def sidebar_category_ids
object.sidebar_categories_ids
object.category_sidebar_section_links.pluck(:linkable_id) & scope.allowed_category_ids
end
def include_sidebar_category_ids?