allow themes to not define any colors, and use them from the base theme instead

This commit is contained in:
Gwendolyn 2024-03-29 13:50:29 +01:00
parent 7aecc1a05f
commit dc3137eee0
2 changed files with 15 additions and 15 deletions

View file

@ -45,13 +45,13 @@ class Theme(TitledMixin, models.Model):
verbose_name=_('CSS route dots shadow color'))
extra_css = models.TextField(default='', blank=True, verbose_name=_('Extra CSS'))
color_background = models.CharField(max_length=32, verbose_name=_('background color'))
color_wall_fill = models.CharField(max_length=32, verbose_name=_('wall fill color'))
color_wall_border = models.CharField(max_length=32, verbose_name=_('wall border color'))
color_door_fill = models.CharField(max_length=32, verbose_name=_('door fill color'))
color_ground_fill = models.CharField(max_length=32, verbose_name=_('ground fill color'))
color_obstacles_default_fill = models.CharField(max_length=32, verbose_name=_('default fill color for obstacles'))
color_obstacles_default_border = models.CharField(max_length=32,
color_background = models.CharField(max_length=32, blank=True, verbose_name=_('background color'))
color_wall_fill = models.CharField(max_length=32, blank=True, verbose_name=_('wall fill color'))
color_wall_border = models.CharField(max_length=32, blank=True, verbose_name=_('wall border color'))
color_door_fill = models.CharField(max_length=32, blank=True, verbose_name=_('door fill color'))
color_ground_fill = models.CharField(max_length=32, blank=True, verbose_name=_('ground fill color'))
color_obstacles_default_fill = models.CharField(max_length=32, blank=True, verbose_name=_('default fill color for obstacles'))
color_obstacles_default_border = models.CharField(max_length=32, blank=True,
verbose_name=_('default border color for obstacles'))
last_updated = models.DateTimeField(auto_now=True)

View file

@ -35,14 +35,14 @@ class ThemeColorManager:
for obstacle_group in ObstacleGroup.objects.filter(color__isnull=False).all()
}
else:
self.background = theme.color_background
self.wall_fill = theme.color_wall_fill
self.wall_border = theme.color_wall_border
self.door_fill = theme.color_door_fill
self.ground_fill = theme.color_ground_fill
self.obstacles_default_fill = theme.color_obstacles_default_fill
self.obstacles_default_border = theme.color_obstacles_default_border
self.highlight = theme.color_css_primary
self.background = theme.color_background or settings.BASE_THEME['map']['background']
self.wall_fill = theme.color_wall_fill or settings.BASE_THEME['map']['wall_fill']
self.wall_border = theme.color_wall_border or settings.BASE_THEME['map']['wall_border']
self.door_fill = theme.color_door_fill or settings.BASE_THEME['map']['door_fill']
self.ground_fill = theme.color_ground_fill or settings.BASE_THEME['map']['ground_fill']
self.obstacles_default_fill = theme.color_obstacles_default_fill or settings.BASE_THEME['map']['obstacles_default_fill']
self.obstacles_default_border = theme.color_obstacles_default_border or settings.BASE_THEME['map']['obstacles_default_border']
self.highlight = theme.color_css_primary or settings.BASE_THEME['map']['highlight']
self.location_group_border_colors = {
theme_location_group.location_group_id: theme_location_group.border_color
for theme_location_group in theme.location_groups.all()