UPDATE:
The feature is now fully implemented! It shows up as an extra option in the community sidebar and saves the result in the database (as was decided by the poll). It is not merged with main yet, but you can look at the pull request , if you are interested.

In a previous post , I talked about the new community themes feature.

From a lot of the commentors, I heard, that you wish, that you would like to have the ability to disable community themes from specific communities and not just in general.
I am currently planning on implementing that feature, but I am not quite shure, if you would like to be able to disable certain community themes on some of your devices, but not on others (which would mean storing that setting in a browser cookie) or if you want to disable community themes of certain communities for your entire user account, so that the setting is applied to all your devices at once (which would mean storing that setting in the database.

Feel free to share your opinion in more details in the comments!

50% Disable certain community themes only on one device at a time (store it as a cookie)
50% Disable certain community themes for your entire account (store it in the database)
2 votes - ended 7 months ago
you are viewing a single comment's thread
view the rest of the comments
[–] [S] 1 point 7 months ago (2 children)

Do you know, if there is a way to be able to get the result of my function community.utils.get_community_theme_allowed in the jinja base template when any relevant route is rendered?

Because including this as a parameter in every route seems really inefficient.

  • source
  • parent
  • hideshow 2 child comments
  • [–] 2 points 7 months ago (1 child)

    The user and community are generally accessible across pretty much every relevant view function and template, so that might work well to stick those kinds of getter functions.

    So, you could have a function for these models that returns whether the style is allowed for that user/community. See something like User.has_blocked_user() as an example. It could look something like this in the User class:

    def allow_community_theme(self, community_id: int):
        # Need to do the import here to avoid circular import error
        from app.utils import function_you_made
        
        # Do the call to your function and logic here and return True/False
        # Make sure that anything you do also works for anonymous users
    

    Similarly, you just swap some stuff around to add a function under the Community model where it would take the user_id as an argument.

  • source
  • parent
  • hideshow 1 child comment