email list fixes

This commit is contained in:
j 2023-09-23 14:58:41 +02:00
parent e82d5d5f15
commit 113dd622b2
4 changed files with 20 additions and 6 deletions

View file

@ -97,6 +97,9 @@ class Item(models.Model):
def get_absolute_url(self):
return reverse('item', kwargs={'id': self.id})
def full_url(self):
return settings.URL + self.get_absolute_url()
def update_data(self):
self.data.update(self.parse_url())

View file

@ -10,10 +10,12 @@ logger = logging.getLogger(__name__)
def send_week(year, month, day):
from . import views
date = '%s-%02d-%02d' % (year, month, day)
date = datetime.strptime(date, '%Y-%m-%d')
monday = views.get_monday(date)
body = views.week(year, month, day)
week = '%s-%02d-%02d' % (year, month, day)
name = 'weekly-digest-%s' % week
subject = 'Phantas.ma weekly update %s' % views.format_week(week)
name = 'weekly-digest-%s' % monday
subject = 'Phantas.ma weekly update %s' % views.format_week(monday)
return send_email(name, subject, body)

View file

@ -1,14 +1,24 @@
from django.shortcuts import render
from django.template.loader import render_to_string
from django.utils.timezone import datetime, timedelta
from django.utils import timezone
from django.db.models.functions import ExtractWeek, ExtractYear
from ..item import models
from ..item.views import get_weeks
def week(year, month, day):
now = timezone.make_aware(datetime.now(), timezone.get_default_timezone())
context = {}
_, archive = models.Item.public()
archive = models.Item.objects.filter(
published__lte=now
).annotate(
year=ExtractYear('published')
).annotate(
week=ExtractWeek('published')
)
date = datetime.strptime('%s-%s-%s' % (year, month, day), '%Y-%m-%d')
week = int(date.strftime('%W'))
year = int(year)

View file

@ -7,10 +7,9 @@
<div class="info">
<h1>{{ item.title }}</h1>
<h2>{{ item.data.title }}</h2>
<div class="url">{{ item.full_url }}</div>
</div>
<div class="image">
<img src={{ item.data.thumbnail }}>
<img src="{{ item.data.thumbnail }}">
</div>
</a>
</div>