diff --git a/app/item/migrations/0010_week_break_notice_week_is_break.py b/app/item/migrations/0010_week_break_notice_week_is_break.py new file mode 100644 index 0000000..0011238 --- /dev/null +++ b/app/item/migrations/0010_week_break_notice_week_is_break.py @@ -0,0 +1,23 @@ +# Generated by Django 5.1.5 on 2025-01-31 10:39 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("item", "0009_week_byline"), + ] + + operations = [ + migrations.AddField( + model_name="week", + name="break_notice", + field=models.TextField(blank=True, default="", editable=False), + ), + migrations.AddField( + model_name="week", + name="is_break", + field=models.BooleanField(default=False), + ), + ] diff --git a/app/item/models.py b/app/item/models.py index 7355a72..f086019 100644 --- a/app/item/models.py +++ b/app/item/models.py @@ -74,6 +74,9 @@ class Item(models.Model): cal = now.date().isocalendar() monday = now.date() - timedelta(days=now.date().isocalendar().weekday - 1) monday = timezone.datetime(monday.year, monday.month, monday.day, tzinfo=now.tzinfo) + current_week = Week.objects.filter(monday=monday).first() + if current_week and current_week.is_break: + return current_week, qs first_post = qs.filter(published__gt=monday).first() if first_post and first_post.published < now: week = qs.filter(published__gt=monday) @@ -192,6 +195,8 @@ class Week(models.Model): 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) + is_break = models.BooleanField(default=False) + break_notice = models.TextField(default="", blank=True) def __str__(self): return "%s (%s)" % (self.title, self.monday) diff --git a/app/item/views.py b/app/item/views.py index 5e59788..3ce69e1 100644 --- a/app/item/views.py +++ b/app/item/views.py @@ -69,13 +69,16 @@ def index(request): else: now = None week, archive = models.Item.public(now) - context['items'] = week - if archive.exists(): + if archive and archive.exists(): context['archive'] = '/_%s/' % get_monday(get_now() - timedelta(days=7)) - if now: - context['now'] = now - context['previous_week'] = (now - timedelta(days=7)).strftime(TS_FORMAT) - context['next_week'] = (now + timedelta(days=7)).strftime(TS_FORMAT) + if isinstance(week, models.Week) and week.is_break: + context["break"] = week + else: + context['items'] = week + if now: + context['now'] = now + context['previous_week'] = (now - timedelta(days=7)).strftime(TS_FORMAT) + context['next_week'] = (now + timedelta(days=7)).strftime(TS_FORMAT) return render(request, 'index.html', context) @@ -89,9 +92,7 @@ def archive(request, year=None, month=None, day=None, week=None): archive_week = archive.filter(year=year, week=week).order_by('published') years = {} context['weeks'] = get_weeks(archive) - years["2024"] = [] for week in get_weeks(archive): - print(week) if week["year"] not in years: years[week["year"]] = [] years[week["year"]].append(week) @@ -104,7 +105,7 @@ def archive(request, year=None, month=None, day=None, week=None): }) context['this_week'] = date.strftime('%Y-%m-%d') context['this_year'] = date.strftime('%Y') - extra = models.Week.objects.filter(monday=context['this_week']).first() + extra = models.Week.objects.filter(monday=context['this_week'], is_break=False).first() if extra: context['week_title'] = extra.title context['week_byline'] = extra.byline diff --git a/app/static/css/site.scss b/app/static/css/site.scss index c40fecc..ac57867 100644 --- a/app/static/css/site.scss +++ b/app/static/css/site.scss @@ -83,6 +83,14 @@ header { } .index { + .break { + display: flex; + min-height: 80vh; + div { + margin: auto; + text-align: center; + } + } .item { border-bottom: 1px solid blueviolet; padding-bottom: 4px; diff --git a/app/templates/index.html b/app/templates/index.html index 079a418..3491995 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -5,9 +5,17 @@ {% endblock %} {% block content %}