Commit 1ce6b0fc authored by Jelle Besseling's avatar Jelle Besseling
Browse files

Merge branch 'tc/newsletter-logos' into 'master'

Update newsletter to include logos of main and local partners

Closes #893

See merge request !1294
parents 22c6046e 0e38b50a
...@@ -17,9 +17,6 @@ def send_newsletter(newsletter): ...@@ -17,9 +17,6 @@ def send_newsletter(newsletter):
:param newsletter: the newsletter to be send :param newsletter: the newsletter to be send
""" """
partners = Partner.objects.filter(is_main_partner=True)
main_partner = partners[0] if len(partners) > 0 else None
events = None events = None
if newsletter.date: if newsletter.date:
datetime = make_aware(timezone.datetime( datetime = make_aware(timezone.datetime(
...@@ -33,6 +30,9 @@ def send_newsletter(newsletter): ...@@ -33,6 +30,9 @@ def send_newsletter(newsletter):
html_template = get_template('newsletters/email.html') html_template = get_template('newsletters/email.html')
text_template = get_template('newsletters/email.txt') text_template = get_template('newsletters/email.txt')
main_partner = Partner.objects.filter(is_main_partner=True).first()
local_partner = Partner.objects.filter(is_local_partner=True).first()
for language in settings.LANGUAGES: for language in settings.LANGUAGES:
translation.activate(language[0]) translation.activate(language[0])
...@@ -48,6 +48,7 @@ def send_newsletter(newsletter): ...@@ -48,6 +48,7 @@ def send_newsletter(newsletter):
'newsletter': newsletter, 'newsletter': newsletter,
'agenda_events': events, 'agenda_events': events,
'main_partner': main_partner, 'main_partner': main_partner,
'local_partner': local_partner,
'lang_code': language[0] 'lang_code': language[0]
} }
......
...@@ -5,8 +5,8 @@ msgid "" ...@@ -5,8 +5,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: Thaliawebsite: nieuwsbrieven\n" "Project-Id-Version: Thaliawebsite: nieuwsbrieven\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-04-13 16:03+0200\n" "POT-Creation-Date: 2019-06-07 14:29+0200\n"
"PO-Revision-Date: 2019-04-13 16:00+0200\n" "PO-Revision-Date: 2019-06-07 15:03+0200\n"
"Last-Translator: Sébastiaan Versteeg <se_bastiaan@outlook.com>\n" "Last-Translator: Sébastiaan Versteeg <se_bastiaan@outlook.com>\n"
"Language-Team: Technicie <www@thalia.nu>\n" "Language-Team: Technicie <www@thalia.nu>\n"
"Language: nl\n" "Language: nl\n"
...@@ -46,6 +46,10 @@ msgstr "" ...@@ -46,6 +46,10 @@ msgstr ""
"makkelijkste is dus om gewoon de maandag van de week in te vullen waar deze " "makkelijkste is dus om gewoon de maandag van de week in te vullen waar deze "
"nieuwsbrief voor is." "nieuwsbrief voor is."
#: models.py
msgid "Send date"
msgstr "Verzenddatum"
#: models.py #: models.py
msgid "Introduction" msgid "Introduction"
msgstr "Introductie" msgstr "Introductie"
...@@ -62,6 +66,10 @@ msgstr "" ...@@ -62,6 +66,10 @@ msgstr ""
msgid "Please make sure all urls are absolute and contain http(s)://." msgid "Please make sure all urls are absolute and contain http(s)://."
msgstr "Controleer of alle links absoluut zijn en http(s):// bevatten." msgstr "Controleer of alle links absoluut zijn en http(s):// bevatten."
#: models.py
msgid "Please make sure the send date is not in the past."
msgstr "De verzenddatum mag niet in het verleden liggne."
#: models.py #: models.py
msgid "Description" msgid "Description"
msgstr "Beschrijving" msgstr "Beschrijving"
...@@ -191,6 +199,10 @@ msgstr "Prijs" ...@@ -191,6 +199,10 @@ msgstr "Prijs"
msgid "Free" msgid "Free"
msgstr "Gratis" msgstr "Gratis"
#: templates/newsletters/email.html templates/newsletters/email.txt
msgid "our local partner"
msgstr "onze localpartner"
#: templates/newsletters/email.html templates/newsletters/email.txt #: templates/newsletters/email.html templates/newsletters/email.txt
msgid "our main partner" msgid "our main partner"
msgstr "onze hoofdpartner" msgstr "onze hoofdpartner"
......
...@@ -28,8 +28,8 @@ def save_to_disk(newsletter, request): ...@@ -28,8 +28,8 @@ def save_to_disk(newsletter, request):
""" """
Writes the newsletter as HTML to file (in all languages) Writes the newsletter as HTML to file (in all languages)
""" """
partners = Partner.objects.filter(is_main_partner=True) main_partner = Partner.objects.filter(is_main_partner=True).first()
main_partner = partners[0] if len(partners) > 0 else None local_partner = Partner.objects.filter(is_local_partner=True).first()
html_template = get_template('newsletters/email.html') html_template = get_template('newsletters/email.html')
...@@ -44,6 +44,7 @@ def save_to_disk(newsletter, request): ...@@ -44,6 +44,7 @@ def save_to_disk(newsletter, request):
.order_by('newsletterevent__start_datetime') .order_by('newsletterevent__start_datetime')
), ),
'main_partner': main_partner, 'main_partner': main_partner,
'local_partner': local_partner,
'lang_code': language[0], 'lang_code': language[0],
'request': request 'request': request
} }
......
...@@ -184,35 +184,56 @@ ...@@ -184,35 +184,56 @@
</tr> </tr>
<tr style="margin-top: 20px;"> <tr style="margin-top: 20px;">
<td style="background-color: {{ primary_color }}; overflow: hidden;"> <td style="background-color: {{ primary_color }}; overflow: hidden; padding-left:30px; padding-top: 10px; padding-bottom: 10px;">
<table style="padding-left:30px; padding-right: 40px;"> <a href="{% baseurl %}{% url 'index' %}"><img src="{% baseurl %}{% static 'newsletters/logo-footer-'|add:lang_code|add:'.png' %}" alt="Thalia" width="180" height="75" style="float:left;width: 180px; height: 75px;"></a>
<col width="180"> </td>
<col width="260"> <td align="center" style="background-color: black; color: white;font-size: 12px; padding: 10px;">
<tr> <p style="font-size: 18px; color: white; font-family: 'Calibri', 'Trebuchet MS', sans-serif;">
<td> M1.0.08<br>
<a href="{% baseurl %}{% url 'index' %}"><img src="{% baseurl %}{% static 'newsletters/logo-footer-'|add:lang_code|add:'.png' %}" alt="Thalia" width="180" height="75" style="float:left;width: 180px; height: 75px;"></a> <a href="https://www.thalia.nu" style="text-decoration:none; color: white; font-family: Calibri, 'Trebuchet MS', sans-serif">WWW.THALIA.NU</a><br>
</td> <a href="mailto:info@thalia.nu" style="text-decoration:none; color: white; font-family: Calibri, 'Trebuchet MS', sans-serif">INFO@THALIA.NU</a>
<td style="text-align: right; valign: middle; "> </p>
<p style="font-size: 18px; color: white; font-family: 'Calibri', 'Trebuchet MS', sans-serif;"> </td>
M1.0.08<br> </tr>
<a href="https://www.thalia.nu" style="text-decoration:none;"><span style="color: white; font-family: Calibri, 'Trebuchet MS', sans-serif">WWW.<span style="color: black">THALIA</span>.NU</span></a><br> </table>
<a href="mailto:info@thalia.nu" style="text-decoration:none;"><span style="color: white; font-family: Calibri, 'Trebuchet MS', sans-serif">INFO@<span style="color: black">THALIA</span>.NU</span></a> </div>
</p> {% if local_partner or main_partner %}
</td> <div style="width: 700px ; margin-top: 30px; margin-left: auto ; margin-right: auto;">
</tr> <table cellspacing="0" cellpadding="0">
</table> {% if local_partner and main_partner and local_partner.is_active and main_partner.is_active %}
<col width="350px">
<col width="350px">
{% else %}
<col width="700px">
{% endif %}
<tr>
{% if local_partner and local_partner.is_active %}
<td align="center" style="color: black; font-size: 12px;">
<p style="margin: 10px; font-family: 'Gill Sans', 'Trebuchet MS', sans-serif;">
<a href="{{ local_partner.link }}"><img src="{% baseurl %}{% static 'newsletters/yoast-logo.png' %}" height="70" style="height: 70px; margin-bottom: 25px" alt="{{ local_partner.name }}"/></a><br/>
{% trans "our local partner"|upper %}
</p>
</td> </td>
<td align="center" style="background-color: black; color: white;font-size: 12px;"> {% endif %}
{% if main_partner and main_partner.is_active %}
<td align="center" style="color: black; font-size: 12px;">
<p style="margin: 10px; font-family: 'Gill Sans', 'Trebuchet MS', sans-serif;"> <p style="margin: 10px; font-family: 'Gill Sans', 'Trebuchet MS', sans-serif;">
{% if main_partner %} <a href="{{ main_partner.link }}">
<a href="{{ main_partner.link }}"><img src="{% baseurl %}{% static 'newsletters/topicus-logo.png' %}" height="70" style="max-width: 170px; height: 70px; margin-bottom: 5px" alt="{{ main_partner.name }}"/></a><br/> {# TODO: Only show Nedap logo after 2019-8-1, remove if #}
{% trans "our main partner"|upper %} {% if main_partner.pk == 1 %}
{% endif %} <img src="{% baseurl %}{% static 'newsletters/topicus-logo.png' %}" height="95" style="height: 95px;" alt="{{ main_partner.name }}"/>
{% else %}
<img src="{% baseurl %}{% static 'newsletters/nedap-logo.png' %}" height="95" style="height: 95px;" alt="{{ main_partner.name }}"/>
{% endif %}
</a><br/>
{% trans "our main partner"|upper %}
</p> </p>
</td> </td>
{% endif %}
</tr> </tr>
</table> </table>
</div> </div>
{% endif %}
</body> </body>
</html> </html>
{% endwith %} {% endwith %}
...@@ -25,7 +25,8 @@ ...@@ -25,7 +25,8 @@
{% trans "website"|capfirst %}: www.thalia.nu {% trans "website"|capfirst %}: www.thalia.nu
{% trans "email"|capfirst %}: info@thalia.nu {% trans "email"|capfirst %}: info@thalia.nu
{% trans "our main partner"|capfirst %}: {{ main_partner.name }} - {{ main_partner.link }} {% if main_partner and main_partner.is_active %}{% trans "our main partner"|capfirst %}: {{ main_partner.name }} - {{ main_partner.link }}{% endif %}
{% if local_partner and local_partner.is_active %}{% trans "our local partner"|capfirst %}: {{ local_partner.name }} - {{ local_partner.link }}{% endif %}
Is this email not in your preferred language? Then edit your profile on the website ({% baseurl %}{% url 'members:edit-profile' %}) and adjust the preferred language setting. The next newsletter you'll receive will be in the language you selected. Is this email not in your preferred language? Then edit your profile on the website ({% baseurl %}{% url 'members:edit-profile' %}) and adjust the preferred language setting. The next newsletter you'll receive will be in the language you selected.
......
...@@ -10,6 +10,4 @@ urlpatterns = [ ...@@ -10,6 +10,4 @@ urlpatterns = [
url(r'^(?P<pk>\d+)/(?P<lang>[-\w]+)/$', views.preview, url(r'^(?P<pk>\d+)/(?P<lang>[-\w]+)/$', views.preview,
name='preview-localised'), name='preview-localised'),
url(r'admin/send/(?P<pk>\d+)/$', views.admin_send, name='admin-send'), url(r'admin/send/(?P<pk>\d+)/$', views.admin_send, name='admin-send'),
url(r'^(?P<year>\d+)/(?P<week>\d+)/nieuwsbrief.html',
views.legacy_redirect, name='legacy-redirect')
] ]
"""Views provided by the newsletters package""" """Views provided by the newsletters package"""
import os import os
from datetime import datetime, timedelta, date
from django.conf import settings from django.conf import settings
from django.contrib.admin.views.decorators import staff_member_required from django.contrib.admin.views.decorators import staff_member_required
...@@ -44,38 +43,17 @@ def preview(request, pk, lang=None): ...@@ -44,38 +43,17 @@ def preview(request, pk, lang=None):
return sendfile(request, file_path) return sendfile(request, file_path)
newsletter = get_object_or_404(Newsletter, pk=pk) newsletter = get_object_or_404(Newsletter, pk=pk)
partners = Partner.objects.filter(is_main_partner=True)
main_partner = partners[0] if len(partners) > 0 else None
events = services.get_agenda(newsletter.date) if newsletter.date else None events = services.get_agenda(newsletter.date) if newsletter.date else None
return render(request, 'newsletters/email.html', { return render(request, 'newsletters/email.html', {
'newsletter': newsletter, 'newsletter': newsletter,
'agenda_events': events, 'agenda_events': events,
'main_partner': main_partner, 'main_partner': Partner.objects.filter(is_main_partner=True).first(),
'local_partner': Partner.objects.filter(is_local_partner=True).first(),
'lang_code': lang_code 'lang_code': lang_code
}) })
def legacy_redirect(request, year, week):
"""
View that redirect you to the right newsletter by
using the previously used URL format of /{year}/{week}
:param request: the request object
:param year: the year of the newsletter
:param week: the week of the newsletter
:return: 302 RedirectResponse
"""
newsletter_date = datetime.strptime(
'%s-%s-1' % (year, week), '%Y-%W-%w')
if date(int(year), 1, 4).isoweekday() > 4:
newsletter_date -= timedelta(days=7)
newsletter = get_object_or_404(Newsletter, date=newsletter_date)
return redirect(newsletter.get_absolute_url(), permanent=True)
@staff_member_required @staff_member_required
@permission_required('newsletters.send_newsletter') @permission_required('newsletters.send_newsletter')
def admin_send(request, pk): def admin_send(request, pk):
......
...@@ -16,15 +16,18 @@ class PartnerAdmin(admin.ModelAdmin): ...@@ -16,15 +16,18 @@ class PartnerAdmin(admin.ModelAdmin):
"""Class to show partners in the admin.""" """Class to show partners in the admin."""
prepopulated_fields = {"slug": ("name",)} prepopulated_fields = {"slug": ("name",)}
list_display = ('name', 'is_active', 'is_main_partner',) list_display = ('name', 'is_active', 'is_main_partner',
'is_local_partner')
search_fields = ('name', 'city') search_fields = ('name', 'city')
list_filter = ('is_active',)
inlines = (PartnerImageInline,) inlines = (PartnerImageInline,)
fieldsets = ( fieldsets = (
(None, { (None, {
'fields': ( 'fields': (
'is_active', 'is_main_partner', 'name', 'slug', 'link', 'name', 'slug', 'link',
'company_profile', 'logo', 'site_header' 'company_profile', 'logo', 'site_header',
'is_active', 'is_main_partner', 'is_local_partner',
) )
}), }),
('Address', { ('Address', {
......
...@@ -7,8 +7,8 @@ msgid "" ...@@ -7,8 +7,8 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-11-07 20:54+0100\n" "POT-Creation-Date: 2019-06-07 14:29+0200\n"
"PO-Revision-Date: 2018-11-07 20:56+0100\n" "PO-Revision-Date: 2019-06-07 15:04+0200\n"
"Last-Translator: Sébastiaan Versteeg <se_bastiaan@outlook.com>\n" "Last-Translator: Sébastiaan Versteeg <se_bastiaan@outlook.com>\n"
"Language-Team: \n" "Language-Team: \n"
"Language: nl\n" "Language: nl\n"
...@@ -16,7 +16,7 @@ msgstr "" ...@@ -16,7 +16,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 2.0.6\n" "X-Generator: Poedit 2.2.1\n"
#: apps.py templates/partners/index.html templates/partners/partner.html #: apps.py templates/partners/index.html templates/partners/partner.html
msgid "Partners" msgid "Partners"
...@@ -49,10 +49,6 @@ msgstr "" ...@@ -49,10 +49,6 @@ msgstr ""
msgid "not shown on the page" msgid "not shown on the page"
msgstr "wordt niet getoond op de vacaturepagina" msgstr "wordt niet getoond op de vacaturepagina"
#: models.py templates/partners/partner.html templates/partners/vacancies.html
msgid "Vacancies"
msgstr "Vacatures"
#: models.py #: models.py
msgid "If no partner is used then both a company name and logo are required." msgid "If no partner is used then both a company name and logo are required."
msgstr "" msgstr ""
...@@ -62,6 +58,10 @@ msgstr "" ...@@ -62,6 +58,10 @@ msgstr ""
msgid "Either select a partner or provide a company name and logo." msgid "Either select a partner or provide a company name and logo."
msgstr "Selecteer of een partner of geef een bedrijfsnaam en logo." msgstr "Selecteer of een partner of geef een bedrijfsnaam en logo."
#: models.py templates/partners/partner.html templates/partners/vacancies.html
msgid "Vacancies"
msgstr "Vacatures"
#: models.py #: models.py
msgid "title" msgid "title"
msgstr "titel" msgstr "titel"
...@@ -113,8 +113,8 @@ msgid "" ...@@ -113,8 +113,8 @@ msgid ""
"produce a magazine called the Thabloid. We are always looking to create new " "produce a magazine called the Thabloid. We are always looking to create new "
"partnerships. If your company is interessed in creating such a partnership " "partnerships. If your company is interessed in creating such a partnership "
"or are you interested in what such a partnership can do for you, please " "or are you interested in what such a partnership can do for you, please "
"contact us at <a href=\"mailto:samenwerking@thalia.nu\" target=\"_blank" "contact us at <a href=\"mailto:samenwerking@thalia.nu\" rel=\"noopener\" "
"\">samenwerking@thalia.nu</a>." "target=\"_blank\">samenwerking@thalia.nu</a>."
msgstr "" msgstr ""
"Wij zijn studievereniging Thalia voor studenten informatica en " "Wij zijn studievereniging Thalia voor studenten informatica en "
"informatiekunde. Als studievereniging doen we ontzettend ons best om leuke " "informatiekunde. Als studievereniging doen we ontzettend ons best om leuke "
...@@ -124,7 +124,8 @@ msgstr "" ...@@ -124,7 +124,8 @@ msgstr ""
"en brengen we elk kwartaal studieblad de Thabloid uit. Als u benieuwd bent " "en brengen we elk kwartaal studieblad de Thabloid uit. Als u benieuwd bent "
"naar samenwerkingsmogelijkheden, kunt u een e-mail sturen naar de " "naar samenwerkingsmogelijkheden, kunt u een e-mail sturen naar de "
"commissaris externe betrekkingen, die te bereiken is via <a href=\"mailto:" "commissaris externe betrekkingen, die te bereiken is via <a href=\"mailto:"
"samenwerking@thalia.nu\" target=\"_blank\">samenwerking@thalia.nu</a>." "samenwerking@thalia.nu\" rel=\"noopener\" target=\"_blank"
"\">samenwerking@thalia.nu</a>."
#: templates/partners/index.html #: templates/partners/index.html
msgid "Main Partner" msgid "Main Partner"
...@@ -148,13 +149,15 @@ msgid "" ...@@ -148,13 +149,15 @@ msgid ""
"If you want to work besides studying or when you are (almost) graduated you " "If you want to work besides studying or when you are (almost) graduated you "
"can look here for interesting vacancies. When you want to post a vacancy on " "can look here for interesting vacancies. When you want to post a vacancy on "
"this page as a company you can contact us at <a href=\"mailto:" "this page as a company you can contact us at <a href=\"mailto:"
"samenwerking@thalia.nu\" target=\"_blank\">samenwerking@thalia.nu</a>." "samenwerking@thalia.nu\" rel=\"noopener\" target=\"_blank"
"\">samenwerking@thalia.nu</a>."
msgstr "" msgstr ""
"Wil je wat bijverdienen of ben je (bijna) afgestudeerd en wil je eens wat " "Wil je wat bijverdienen of ben je (bijna) afgestudeerd en wil je eens wat "
"rondkijken, op deze pagina staan al onze openstaande vacatures. Wil je als " "rondkijken, op deze pagina staan al onze openstaande vacatures. Wil je als "
"bedrijf een vacature plaatsen op onze website, dan kun je contact opnemen " "bedrijf een vacature plaatsen op onze website, dan kun je contact opnemen "
"met de commissaris externe betrekkingen via <a href=\"mailto:" "met de commissaris externe betrekkingen via <a href=\"mailto:"
"samenwerking@thalia.nu\" target=\"_blank\">samenwerking@thalia.nu</a>." "samenwerking@thalia.nu\" rel=\"noopener\" target=\"_blank"
"\">samenwerking@thalia.nu</a>."
#: templates/partners/vacancies.html #: templates/partners/vacancies.html
msgid "Everything" msgid "Everything"
......
# Generated by Django 2.2.1 on 2019-06-07 12:12
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('partners', '0013_auto_20181107_2010'),
]
operations = [
migrations.AddField(
model_name='partner',
name='is_local_partner',
field=models.BooleanField(default=False),
),
]
...@@ -13,6 +13,7 @@ class Partner(models.Model): ...@@ -13,6 +13,7 @@ class Partner(models.Model):
is_active = models.BooleanField(default=False) is_active = models.BooleanField(default=False)
is_main_partner = models.BooleanField(default=False) is_main_partner = models.BooleanField(default=False)
is_local_partner = models.BooleanField(default=False)
name = models.CharField(max_length=255) name = models.CharField(max_length=255)
slug = models.SlugField() slug = models.SlugField()
link = models.CharField( link = models.CharField(
...@@ -44,9 +45,12 @@ class Partner(models.Model): ...@@ -44,9 +45,12 @@ class Partner(models.Model):
city = models.CharField(max_length=100) city = models.CharField(max_length=100)
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
"""Save a partner and set main partner.""" """Save a partner and set main/local partners."""
if self.is_main_partner: if self.is_main_partner:
self.is_local_partner = False
self._reset_main_partner() self._reset_main_partner()
if self.is_local_partner:
self._reset_local_partner()
super(Partner, self).save(*args, **kwargs) super(Partner, self).save(*args, **kwargs)
...@@ -65,6 +69,21 @@ class Partner(models.Model): ...@@ -65,6 +69,21 @@ class Partner(models.Model):
except Partner.DoesNotExist: except Partner.DoesNotExist:
pass pass
def _reset_local_partner(self):
"""
Reset the local partner status.
If this partner is not local partner,
remove the local partner status from the local partner.
"""
try:
current_local_partner = Partner.objects.get(is_local_partner=True)
if self != current_local_partner:
current_local_partner.is_local_partner = False
current_local_partner.save()
except Partner.DoesNotExist:
pass
def __str__(self): def __str__(self):
"""Return the name of the partner.""" """Return the name of the partner."""
return self.name return self.name
......
Supports Markdown
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