fix index order
This commit is contained in:
parent
99882e78ae
commit
41c1b1cdec
2 changed files with 6 additions and 3 deletions
|
|
@ -312,10 +312,13 @@ class Week(models.Model):
|
||||||
items, _ = Item.public(monday)
|
items, _ = Item.public(monday)
|
||||||
return items.order_by('published')
|
return items.order_by('published')
|
||||||
|
|
||||||
def background(self, now=None):
|
def background(self, now=None, order_by=None):
|
||||||
if self.use_hue:
|
if self.use_hue:
|
||||||
colors = []
|
colors = []
|
||||||
for item in self.items():
|
items = self.items()
|
||||||
|
if order_by:
|
||||||
|
items = items.order_by(order_by)
|
||||||
|
for item in items:
|
||||||
if now and item.published >= now:
|
if now and item.published >= now:
|
||||||
continue
|
continue
|
||||||
color = item.get_hue(update=True)
|
color = item.get_hue(update=True)
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ def index(request):
|
||||||
context['items'] = week
|
context['items'] = week
|
||||||
extra = models.Week.objects.filter(monday=monday, is_break=False).first()
|
extra = models.Week.objects.filter(monday=monday, is_break=False).first()
|
||||||
if extra:
|
if extra:
|
||||||
context['week_background'] = extra.background(now)
|
context['week_background'] = extra.background(now, '-published')
|
||||||
if now:
|
if now:
|
||||||
context['now'] = now
|
context['now'] = now
|
||||||
context['previous_week'] = (now - timedelta(days=7)).strftime(TS_FORMAT)
|
context['previous_week'] = (now - timedelta(days=7)).strftime(TS_FORMAT)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue