-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5debbee
commit 25d170e
Showing
1 changed file
with
21 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |