Commit 5dd63f8c authored by fred's avatar fred

various improvements to newsletter handling

parent c128019d
......@@ -14,7 +14,9 @@ def online_url(object):
return settings.WEBSITE_BASE_URL + 'emissions/' + object.slug + '/'
if isinstance(object, Episode):
return settings.WEBSITE_BASE_URL + 'emissions/' + object.emission.slug + '/' + object.slug
return 'XXX'
if isinstance(object, SoundFile):
return settings.WEBSITE_BASE_URL + 'emissions/' + object.episode.emission.slug + '/' + object.episode.slug
return '#'
@register.filter
......
......@@ -193,6 +193,19 @@ AUTH_USER_MODEL = 'aa.User'
LOGIN_REDIRECT_URL = '/'
WEBSITE_BASE_URL = 'http://test-web.radiopanik.org/'
NEWSLETTER_SENDER = 'info@radiopanik.org'
NEWSLETTER_DOMAIN = 'radiopanik.org'
NEWSLETTER_STYLE = """
body { color: #222; text-align: justify; }
h2, h3 { font-family: "Reglo"; }
h3 { margin-bottom: 0; }
h3 + p { margin-top: 0; }
p strong { color: black; }
h3 strong { text-transform: uppercase; color: blue; }
p a { color: black; text-decoration: none; border-bottom: 1px dotted black; }
p a:hover { border-bottom: 1px solid black; }
"""
try:
from local_settings import *
except ImportError:
......
<h1>Cette semaine du côté du 105.4</h1>
{% load panikdbtags %}
<p>
Cette semaine du côté du 105.4…
</p>
{% if soundfiles.exists %}
<h2>Nouveaux podcasts</h2>
<p>
(N'hésitez pas à forwarder cette lettre d'info aux oreilles curieuses qui vous
entourent. Abonnement sur la page d'accueil de www.radiopanik.org)
</p>
{% if soundfiles.exists %} <h2>Nouveaux podcasts</h2>
<ul>
{% for soundfile in soundfiles %}
<li><a href="{{ soundfile.episode.get_absolute_url }}">{{ soundfile.episode.emission.title }} - {{ soundfile.episode.title }}</a></li>
<li><a href="{{ soundfile|online_url }}">{{ soundfile.episode.emission.title }} - {{ soundfile.episode.title }}</a></li>
</ul>
{% endfor %}
......@@ -19,14 +26,12 @@ Cette semaine sur le 105.4, en modulation de fréquence analogique, il y a
</p>
{% for diffusion in diffusions %}
<h2>{{ diffusion.datetime|date:"D d M Y H:i"|lower }} {{ diffusion.episode.emission.title }}</h2>
<p><strong>{{ diffusion.episode.title }}</strong></p>
<h3><strong>{{ diffusion.datetime|date:"l j F Y H:i"|lower }}</strong> : {{ diffusion.episode.emission.title }}</h3>
<p><strong><a href="{{ diffusion.episode|online_url }}">{{ diffusion.episode.title }}</a></strong></p>
<p>{{ diffusion.episode.text|safe|striptags|truncatewords:50 }}</p>
{% endfor %}
<hr/>
À bientôt !
<p>++++++++++++++++++</p>
(newsletter du {{ date }})
<p>À bientôt !</p>
Cette semaine sur Panik (du {% if date.month == date_end.month %}{{ date|date:"j" }}{% else %}{{ date|date:"j F"|lower }}{% endif %} au {{ date_end|date:"j F"|lower }})
......@@ -54,6 +54,7 @@ class NewsletterCreateView(newsletter.views.NewsletterCreateView):
initial = super(NewsletterCreateView, self).get_initial()
newsletter_body = loader.get_template('newsletter/body.html')
newsletter_subject = loader.get_template('newsletter/subject.txt')
context = Context()
date = datetime.datetime.today()
......@@ -61,8 +62,10 @@ class NewsletterCreateView(newsletter.views.NewsletterCreateView):
date = date + datetime.timedelta(days=7-date.weekday())
date = datetime.datetime(*date.timetuple()[:3])
date_end = date + datetime.timedelta(days=7)
context['date'] = date
context['date_end'] = date_end
context['soundfiles'] = SoundFile.objects.filter(
podcastable=True, fragment=False).select_related().filter(
......@@ -79,6 +82,7 @@ class NewsletterCreateView(newsletter.views.NewsletterCreateView):
context['diffusions'].remove(diff)
seen_episodes[diff.episode.id] = True
initial['subject'] = newsletter_subject.render(context)
initial['text'] = newsletter_body.render(context)
return initial
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment