byline for week
This commit is contained in:
parent
688e0d22d4
commit
82edae60fb
7 changed files with 60 additions and 2 deletions
17
app/item/migrations/0009_week_byline.py
Normal file
17
app/item/migrations/0009_week_byline.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Generated by Django 4.2.3 on 2024-02-06 16:24
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("item", "0008_alter_week_title"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="week",
|
||||
name="byline",
|
||||
field=models.CharField(blank=True, default="", max_length=2048),
|
||||
),
|
||||
]
|
||||
|
|
@ -190,6 +190,7 @@ class Week(models.Model):
|
|||
modified = models.DateTimeField(auto_now=True)
|
||||
monday = models.DateField(unique=True)
|
||||
title = models.CharField(max_length=2048, blank=True, default="")
|
||||
byline = models.CharField(max_length=2048, blank=True, default="")
|
||||
published = models.DateTimeField(null=True, default=None, blank=True, editable=False)
|
||||
|
||||
def __str__(self):
|
||||
|
|
|
|||
|
|
@ -42,6 +42,10 @@ def format_week(week):
|
|||
extra = ''
|
||||
return '%s - %s%s' % (a, b, extra)
|
||||
|
||||
def get_byline(week):
|
||||
extra = models.Week.objects.filter(monday=week).first()
|
||||
if extra:
|
||||
return extra.byline
|
||||
|
||||
def get_weeks(archive):
|
||||
weeks = sorted(set(archive.values_list('year', 'week')))
|
||||
|
|
@ -103,6 +107,7 @@ def archive(request, year=None, month=None, day=None, week=None):
|
|||
extra = models.Week.objects.filter(monday=context['this_week']).first()
|
||||
if extra:
|
||||
context['week_title'] = extra.title
|
||||
context['week_byline'] = extra.byline
|
||||
elif week:
|
||||
week = int(week)
|
||||
year = int(year)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue