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)
|
||||
|
|
|
@ -7,7 +7,7 @@ from django.utils.timezone import datetime, timedelta
|
|||
|
||||
|
||||
from ..item import models
|
||||
from ..item.views import get_weeks, format_week, get_monday
|
||||
from ..item.views import get_weeks, format_week, get_monday, get_byline
|
||||
|
||||
|
||||
def week(year, month, day):
|
||||
|
@ -28,6 +28,7 @@ def week(year, month, day):
|
|||
monday = context['this_week'] = date.strftime('%Y-%m-%d')
|
||||
context['this_year'] = date.strftime('%Y')
|
||||
context['week_title'] = 'Phantas.ma weekly update %s' % format_week(monday)
|
||||
context['week_byline'] = get_byline(monday)
|
||||
context['week_link'] = settings.URL + '/_' + monday
|
||||
context['items'] = archive_week
|
||||
return render_to_string("weekly_email.html", context)
|
||||
|
|
|
@ -139,6 +139,30 @@ header {
|
|||
padding-bottom: 8px;
|
||||
margin-bottom: 8px;
|
||||
border-bottom: 1px solid blueviolet;
|
||||
|
||||
&.with-byline {
|
||||
display: flex;
|
||||
margin-left: 4px;
|
||||
margin-right: 4px;
|
||||
div {
|
||||
flex-grow: 1;
|
||||
text-align: left;
|
||||
}
|
||||
.byline {
|
||||
text-align: right;
|
||||
}
|
||||
@media(max-width:768px) {
|
||||
display: block;
|
||||
div {
|
||||
margin-left: 4px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
.byline {
|
||||
text-align: left;
|
||||
margin-left: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.item > a {
|
||||
display: flex;
|
||||
|
|
|
@ -5,7 +5,14 @@
|
|||
{% block content %}
|
||||
<div class="index archive">
|
||||
{% if week_title %}
|
||||
<h2 class="week">{{ week_title }}</h2>
|
||||
<h2 class="week{% if week_byline %} with-byline{% endif %}">
|
||||
{% if week_byline %}
|
||||
<div>{{ week_title }}</div>
|
||||
<div class="byline">{{ week_byline }}</div>
|
||||
{% else %}
|
||||
{{ week_title }}
|
||||
{% endif %}
|
||||
</h2>
|
||||
{% endif %}
|
||||
{% for item in items %}
|
||||
{% include "listitem.html" with item=item %}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
{% if week_title %}
|
||||
<a style="color: #F0F0F0;text-decoration: underline;font-size: 18px;font-weight: bold" href="{{ week_link }}">{{ week_title }}</a>
|
||||
{% if week_byline %}<br>
|
||||
{{ week_byline }}
|
||||
{% endif %}
|
||||
<br>
|
||||
<br>
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in a new issue