use week title in email
This commit is contained in:
parent
778b6836de
commit
5b2670859f
3 changed files with 16 additions and 3 deletions
|
@ -43,6 +43,19 @@ def format_week(week):
|
|||
extra = ''
|
||||
return '%s - %s%s' % (a, b, extra)
|
||||
|
||||
def format_subject(monday):
|
||||
a = datetime.strptime(monday, '%Y-%m-%d')
|
||||
b = (a + timedelta(days=6))
|
||||
fmt = '%b %d'
|
||||
a = a.strftime(fmt)
|
||||
b = b.strftime(fmt)
|
||||
subject = '%s - %s | Phantas.ma' % (a, b)
|
||||
|
||||
extra = models.Week.objects.filter(monday=monday).first()
|
||||
if extra and extra.title:
|
||||
subject = '%s | %s' % (extra.title, subject)
|
||||
return subject
|
||||
|
||||
def get_byline(week):
|
||||
extra = models.Week.objects.filter(monday=week).first()
|
||||
if extra:
|
||||
|
|
|
@ -28,7 +28,7 @@ def send_week(monday):
|
|||
year, month, day = monday.split('-')
|
||||
body = views.week(year, month, day)
|
||||
name = 'weekly-digest-%s' % monday
|
||||
subject = 'Phantas.ma weekly update %s' % views.format_week(monday)
|
||||
subject = views.format_subject(monday)
|
||||
return send_email(name, subject, body)
|
||||
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ from django.core.validators import validate_email
|
|||
import django.contrib.auth
|
||||
|
||||
from ..item import models
|
||||
from ..item.views import get_weeks, format_week, get_monday, get_byline
|
||||
from ..item.views import get_weeks, format_week, get_monday, get_byline, format_subject
|
||||
from ..item.utils import render_to_json
|
||||
from ..utils import default_context
|
||||
|
||||
|
@ -40,7 +40,7 @@ def week(year, month, day):
|
|||
context['weeks'] = get_weeks(archive)
|
||||
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_title'] = format_subject(monday)
|
||||
context['week_byline'] = get_byline(monday)
|
||||
context['week_link'] = settings.URL + '/_' + monday
|
||||
context['items'] = archive_week
|
||||
|
|
Loading…
Add table
Reference in a new issue