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

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):
: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
if newsletter.date:
datetime = make_aware(timezone.datetime(
......@@ -33,6 +30,9 @@ def send_newsletter(newsletter):
html_template = get_template('newsletters/email.html')
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:
translation.activate(language[0])
......@@ -48,6 +48,7 @@ def send_newsletter(newsletter):
'newsletter': newsletter,
'agenda_events': events,
'main_partner': main_partner,
'local_partner': local_partner,
'lang_code': language[0]
}
......
This diff was suppressed by a .gitattributes entry.
......@@ -5,8 +5,8 @@ msgid ""
msgstr ""
"Project-Id-Version: Thaliawebsite: nieuwsbrieven\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-04-13 16:03+0200\n"
"PO-Revision-Date: 2019-04-13 16:00+0200\n"
"POT-Creation-Date: 2019-06-07 14:29+0200\n"
"PO-Revision-Date: 2019-06-07 15:03+0200\n"
"Last-Translator: Sébastiaan Versteeg <se_bastiaan@outlook.com>\n"
"Language-Team: Technicie <www@thalia.nu>\n"
"Language: nl\n"
......@@ -46,6 +46,10 @@ msgstr ""
"makkelijkste is dus om gewoon de maandag van de week in te vullen waar deze "
"nieuwsbrief voor is."
#: models.py
msgid "Send date"
msgstr "Verzenddatum"
#: models.py
msgid "Introduction"
msgstr "Introductie"
......@@ -62,6 +66,10 @@ msgstr ""
msgid "Please make sure all urls are absolute and contain http(s)://."
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
msgid "Description"
msgstr "Beschrijving"
......@@ -191,6 +199,10 @@ msgstr "Prijs"
msgid "Free"
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
msgid "our main partner"
msgstr "onze hoofdpartner"
......
......@@ -28,8 +28,8 @@ def save_to_disk(newsletter, request):
"""
Writes the newsletter as HTML to file (in all languages)
"""
partners = Partner.objects.filter(is_main_partner=True)
main_partner = partners[0] if len(partners) > 0 else None
main_partner = Partner.objects.filter(is_main_partner=True).first()
local_partner = Partner.objects.filter(is_local_partner=True).first()
html_template = get_template('newsletters/email.html')
......@@ -44,6 +44,7 @@ def save_to_disk(newsletter, request):
.order_by('newsletterevent__start_datetime')
),
'main_partner': main_partner,
'local_partner': local_partner,
'lang_code': language[0],
'request': request
}
......
This diff was suppressed by a .gitattributes entry.
This diff was suppressed by a .gitattributes entry.
......@@ -184,35 +184,56 @@
</tr>
<tr style="margin-top: 20px;">
<td style="background-color: {{ primary_color }}; overflow: hidden;">
<table style="padding-left:30px; padding-right: 40px;">
<col width="180">
<col width="260">
<tr>
<td>
<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>
</td>
<td style="text-align: right; valign: middle; ">
<p style="font-size: 18px; color: white; font-family: 'Calibri', 'Trebuchet MS', sans-serif;">
M1.0.08<br>
<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>
<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>
</p>
</td>
</tr>
</table>
<td style="background-color: {{ primary_color }}; overflow: hidden; padding-left:30px; padding-top: 10px; padding-bottom: 10px;">
<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>
</td>
<td align="center" style="background-color: black; color: white;font-size: 12px; padding: 10px;">
<p style="font-size: 18px; color: white; font-family: 'Calibri', 'Trebuchet MS', sans-serif;">
M1.0.08<br>
<a href="https://www.thalia.nu" style="text-decoration:none; color: white; font-family: Calibri, 'Trebuchet MS', sans-serif">WWW.THALIA.NU</a><br>
<a href="mailto:info@thalia.nu" style="text-decoration:none; color: white; font-family: Calibri, 'Trebuchet MS', sans-serif">INFO@THALIA.NU</a>
</p>
</td>
</tr>
</table>
</div>
{% if local_partner or main_partner %}
<div style="width: 700px ; margin-top: 30px; margin-left: auto ; margin-right: auto;">
<table cellspacing="0" cellpadding="0">
{% 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 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;">
{% if main_partner %}
<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/>
{% trans "our main partner"|upper %}
{% endif %}
<a href="{{ main_partner.link }}">
{# TODO: Only show Nedap logo after 2019-8-1, remove if #}
{% if main_partner.pk == 1 %}
<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>
</td>
{% endif %}
</tr>
</table>
</div>
{% endif %}
</body>
</html>
{% endwith %}
......@@ -25,7 +25,8 @@
{% trans "website"|capfirst %}: www.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.
......
......@@ -10,6 +10,4 @@ urlpatterns = [
url(r'^(?P<pk>\d+)/(?P<lang>[-\w]+)/$', views.preview,
name='preview-localised'),
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"""
import os
from datetime import datetime, timedelta, date
from django.conf import settings
from django.contrib.admin.views.decorators import staff_member_required
......@@ -44,38 +43,17 @@ def preview(request, pk, lang=None):
return sendfile(request, file_path)
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
return render(request, 'newsletters/email.html', {
'newsletter': newsletter,
'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
})
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
@permission_required('newsletters.send_newsletter')
def admin_send(request, pk):
......
......@@ -16,15 +16,18 @@ class PartnerAdmin(admin.ModelAdmin):
"""Class to show partners in the admin."""
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')
list_filter = ('is_active',)
inlines = (PartnerImageInline,)
fieldsets = (
(None, {
'fields': (
'is_active', 'is_main_partner', 'name', 'slug', 'link',
'company_profile', 'logo', 'site_header'
'name', 'slug', 'link',
'company_profile', 'logo', 'site_header',
'is_active', 'is_main_partner', 'is_local_partner',
)
}),
('Address', {
......
This diff was suppressed by a .gitattributes entry.
......@@ -7,8 +7,8 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-11-07 20:54+0100\n"
"PO-Revision-Date: 2018-11-07 20:56+0100\n"
"POT-Creation-Date: 2019-06-07 14:29+0200\n"
"PO-Revision-Date: 2019-06-07 15:04+0200\n"
"Last-Translator: Sébastiaan Versteeg <se_bastiaan@outlook.com>\n"
"Language-Team: \n"
"Language: nl\n"
......@@ -16,7 +16,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\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
msgid "Partners"
......@@ -49,10 +49,6 @@ msgstr ""
msgid "not shown on the page"
msgstr "wordt niet getoond op de vacaturepagina"
#: models.py templates/partners/partner.html templates/partners/vacancies.html
msgid "Vacancies"
msgstr "Vacatures"
#: models.py
msgid "If no partner is used then both a company name and logo are required."
msgstr ""
......@@ -62,6 +58,10 @@ msgstr ""
msgid "Either select a partner or provide a company name and 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
msgid "title"
msgstr "titel"
......@@ -113,8 +113,8 @@ msgid ""
"produce a magazine called the Thabloid. We are always looking to create new "
"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 "
"contact us at <a href=\"mailto:samenwerking@thalia.nu\" target=\"_blank"
"\">samenwerking@thalia.nu</a>."
"contact us at <a href=\"mailto:samenwerking@thalia.nu\" rel=\"noopener\" "
"target=\"_blank\">samenwerking@thalia.nu</a>."
msgstr ""
"Wij zijn studievereniging Thalia voor studenten informatica en "
"informatiekunde. Als studievereniging doen we ontzettend ons best om leuke "
......@@ -124,7 +124,8 @@ msgstr ""
"en brengen we elk kwartaal studieblad de Thabloid uit. Als u benieuwd bent "
"naar samenwerkingsmogelijkheden, kunt u een e-mail sturen naar de "
"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
msgid "Main Partner"
......@@ -148,13 +149,15 @@ msgid ""
"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 "
"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 ""
"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 "
"bedrijf een vacature plaatsen op onze website, dan kun je contact opnemen "
"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
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):
is_active = models.BooleanField(default=False)
is_main_partner = models.BooleanField(default=False)
is_local_partner = models.BooleanField(default=False)
name = models.CharField(max_length=255)
slug = models.SlugField()
link = models.CharField(
......@@ -44,9 +45,12 @@ class Partner(models.Model):
city = models.CharField(max_length=100)
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:
self.is_local_partner = False
self._reset_main_partner()
if self.is_local_partner:
self._reset_local_partner()
super(Partner, self).save(*args, **kwargs)
......@@ -65,6 +69,21 @@ class Partner(models.Model):
except Partner.DoesNotExist:
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):
"""Return the name of the partner."""
return self.name
......
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