diff --git a/app/item/models.py b/app/item/models.py index 85939c8..ec9f6fd 100644 --- a/app/item/models.py +++ b/app/item/models.py @@ -312,11 +312,12 @@ class Week(models.Model): items, _ = Item.public(monday) return items.order_by('published') - @property - def background(self): + def background(self, now=None): if self.use_hue: colors = [] for item in self.items(): + if now and item.published > now: + continue color = item.get_hue(update=True) if color: if not colors: diff --git a/app/item/views.py b/app/item/views.py index f289c87..19743ab 100644 --- a/app/item/views.py +++ b/app/item/views.py @@ -68,6 +68,7 @@ def index(request): now = get_now() else: now = None + monday = get_monday(now) week, archive = models.Item.public(now) if archive and archive.exists(): context['archive'] = '/_%s/' % get_monday(get_now() - timedelta(days=7)) @@ -75,6 +76,9 @@ def index(request): context["break"] = week else: context['items'] = week + extra = models.Week.objects.filter(monday=monday, is_break=False).first() + if extra: + context['week_background'] = extra.background(now) if now: context['now'] = now context['previous_week'] = (now - timedelta(days=7)).strftime(TS_FORMAT) @@ -109,7 +113,7 @@ def archive(request, year=None, month=None, day=None, week=None): if extra: context['week_title'] = extra.title context['week_byline'] = extra.byline - context['week_background'] = extra.background + context['week_background'] = extra.background() elif week: week = int(week) year = int(year) diff --git a/app/templates/index.html b/app/templates/index.html index 3491995..e3939fd 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -2,6 +2,16 @@ {% block head %} {{ settings.SITENAME }} +{% if week_background %} + + +{% endif %} {% endblock %} {% block content %}