From 8bfe0a479844d06a5fddacf5ff17736e0a452834 Mon Sep 17 00:00:00 2001 From: Horilla Date: Tue, 13 Jan 2026 22:18:57 +0530 Subject: [PATCH] [UPDT] HORILLA_THEME: Updated the permissions for the theme --- base/templatetags/basefilters.py | 1 + base/views.py | 2 +- horilla_theme/apps.py | 2 ++ horilla_theme/templates/settings.html | 4 +--- horilla_theme/views.py | 8 +++----- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/base/templatetags/basefilters.py b/base/templatetags/basefilters.py index 314002dc2..ae6a92e91 100644 --- a/base/templatetags/basefilters.py +++ b/base/templatetags/basefilters.py @@ -308,5 +308,6 @@ def show_section(context): user.has_perm("horilla_ldap.update_ldapsettings"), user.has_perm("horilla_meet.view_googlecloudcredential"), user.has_perm("whatsapp.add_whatsappcredentials"), + user.has_perm("horilla_theme.view_horillacolortheme"), ] ) diff --git a/base/views.py b/base/views.py index b2d9f3862..984cdb02a 100644 --- a/base/views.py +++ b/base/views.py @@ -3520,7 +3520,7 @@ def get_models_in_app(app_name): try: app_config = apps.get_app_config(app_name) models = app_config.get_models() - return models + return [model for model in models if model.__name__ != "CompanyTheme"] except LookupError: return [] diff --git a/horilla_theme/apps.py b/horilla_theme/apps.py index 9ef3eaddc..33a4a7c71 100644 --- a/horilla_theme/apps.py +++ b/horilla_theme/apps.py @@ -3,6 +3,7 @@ AppConfig for the horilla_theme app """ from django.apps import AppConfig +from django.conf import settings from django.utils.translation import gettext_lazy as _ @@ -23,6 +24,7 @@ class HorillaThemeConfig(AppConfig): from horilla.urls import urlpatterns + settings.APPS.append(("horilla_theme")) # Add app URLs to main urlpatterns urlpatterns.append( path("theme/", include("horilla_theme.urls")), diff --git a/horilla_theme/templates/settings.html b/horilla_theme/templates/settings.html index 6606b3c03..97258678e 100644 --- a/horilla_theme/templates/settings.html +++ b/horilla_theme/templates/settings.html @@ -589,7 +589,7 @@ {% endif %} {% endif %} - {% if "horilla_theme"|app_installed %} + {% if "horilla_theme"|app_installed and perms.horilla_theme.view_horillacolortheme %}
diff --git a/horilla_theme/views.py b/horilla_theme/views.py index 836ae2aa0..f38d8e1ee 100644 --- a/horilla_theme/views.py +++ b/horilla_theme/views.py @@ -14,7 +14,7 @@ from horilla_views.cbv_methods import login_required, permission_required @method_decorator( - permission_required(["horilla_theme.view_horillacolortheme"]), + permission_required("horilla_theme.view_horillacolortheme"), name="dispatch", ) class ThemeView(LoginRequiredMixin, TemplateView): @@ -47,9 +47,7 @@ class ThemeView(LoginRequiredMixin, TemplateView): @method_decorator( - permission_required( - ["horilla_theme.change_companytheme", "horilla_theme.add_companytheme"] - ), + permission_required("horilla_theme.change_horillacolortheme"), name="dispatch", ) class ChangeThemeView(LoginRequiredMixin, View): @@ -147,7 +145,7 @@ class ChangeThemeView(LoginRequiredMixin, View): @method_decorator( - permission_required(["horilla_theme.add_horillacolortheme"]), + permission_required("horilla_theme.add_horillacolortheme"), name="dispatch", ) class SetDefaultThemeView(LoginRequiredMixin, View):