Skip to content

Commit

Permalink
fix theme default
Browse files Browse the repository at this point in the history
  • Loading branch information
Grace-Amondi committed Jun 12, 2023
1 parent 5debbee commit 25d170e
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions site_settings/context_processors.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
from django.core.exceptions import ObjectDoesNotExist

from site_settings.models import Theme

default_theme = {
'primary_color': '#363636',
'primary_hover_color': '#67a9ce',
'secondary_color': '#ffffff',
'border_radius': '1.5em',
'box_shadow': 'elevation-1'
}

def theme(request):

theme_ls = Theme.objects.all()

for theme_item in theme_ls:
if theme_item.is_default:
theme = {
'primary_color': theme_item.primary_color,
'primary_hover_color': theme_item.primary_hover_color,
'secondary_color': theme_item.secondary_color,
'border_radius': f"{theme_item.border_radius * 0.06}em",
'box_shadow': f"elevation-{theme_item.box_shadow}",
}

else:
theme = {
'primary_color': '#363636',
'primary_hover_color': '#67a9ce',
'secondary_color': '#ffffff',
'border_radius': '1.5em',
'box_shadow': 'elevation-1'
}


return theme
def theme(request):
try:
theme = Theme.objects.get(is_default=True)
return {
'primary_color': theme.primary_color,
'primary_hover_color': theme.primary_hover_color,
'secondary_color': theme.secondary_color,
'border_radius': f"{theme.border_radius * 0.06}em",
'box_shadow': f"elevation-{theme.box_shadow}",
}
except ObjectDoesNotExist:
return default_theme

0 comments on commit 25d170e

Please sign in to comment.