Commit 25522cb7 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Add localised newsletters previews to admin backend

parent a8e6658d
.submit-row a.default {
text-transform: uppercase;
}
.submit-row a.button {
float: right;
padding: 10px 15px;
line-height: 15px;
margin: 0 0 0 8px;
}
.newsletters-row a.button.default {
background-color: #e62272;
}
.newsletters-row a.button.default:hover, .newsletters-row a.button.default:active {
background-color: #cd2167;
}
.newsletters-row a.button {
background-color: #e65c95;
}
.newsletters-row a.button:hover, .newsletters-row a.button:active {
background-color: #d25389;
}
\ No newline at end of file
.submit-row a {
&.default {
text-transform: uppercase;
}
&.button {
float: right;
padding: 10px 15px;
line-height: 15px;
margin: 0 0 0 8px;
}
}
.newsletters-row a.button {
background-color: #e65c95;
font-size: 13px;
&.default {
background-color: #e62272;
&:hover, &:active {
background-color: #cd2167;
}
}
&:hover, &:active {
background-color: #d25389;
}
}
......@@ -3,7 +3,19 @@
{% block extrastyle %}
{{ block.super }}
<link rel="stylesheet" type="text/css" href="{% static 'admin/newsletters/css/forms.css' %}" />
{% compress css %}<link rel="stylesheet" type="text/x-scss" href="{% static 'admin/newsletters/css/forms.scss' %}" />{% endcompress %}
{% endblock %}
{% block object-tools %}
{{ block.super }}
{% if newsletter %}
<div class="submit-row newsletters-row">
<a href="{% url 'newsletters:admin-send' pk=newsletter.pk %}" class="default button">{% trans "Send newsletter to members" %}</a>
<a target="_blank" href="{% url 'newsletters:preview-localised' pk=newsletter.pk lang='en' %}" class="button">{% trans "Show preview" %} (EN)</a>
<a target="_blank" href="{% url 'newsletters:preview-localised' pk=newsletter.pk lang='nl' %}" class="button">{% trans "Show preview" %} (NL)</a>
</div>
{% endif %}
{% endblock %}
{% block submit_buttons_bottom %}
......@@ -12,7 +24,8 @@
{% if newsletter %}
<div class="submit-row newsletters-row">
<a href="{% url 'newsletters:admin-send' pk=newsletter.pk %}" class="default button">{% trans "Send newsletter to members" %}</a>
<a target="_blank" href="{{ newsletter.get_absolute_url }}" class="button">{% trans "Show preview" %}</a>
<a target="_blank" href="{% url 'newsletters:preview-localised' pk=newsletter.pk lang='en' %}" class="button">{% trans "Show preview" %} (EN)</a>
<a target="_blank" href="{% url 'newsletters:preview-localised' pk=newsletter.pk lang='nl' %}" class="button">{% trans "Show preview" %} (NL)</a>
</div>
{% endif %}
{% endblock %}
\ No newline at end of file
{% endblock %}
......@@ -6,6 +6,8 @@ app_name = "newsletters"
urlpatterns = [
url('^(?P<pk>\d+)/$', views.preview, name='preview'),
url('^(?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('^(?P<year>\d+)/(?P<week>\d+)/nieuwsbrief.html',
views.legacy_redirect, name='legacy-redirect')
......
......@@ -9,20 +9,34 @@ from django.utils import translation
from datetime import datetime, timedelta, date
from django.utils.translation import activate, get_language_info
from members.models import Member
from newsletters.models import Newsletter
from partners.models import Partner
def preview(request, pk):
def preview(request, pk, lang=None):
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
lang_code = request.LANGUAGE_CODE
if lang is not None:
try:
get_language_info(lang)
activate(lang)
lang_code = lang
except KeyError:
# Language code not recognised by get_language_info
pass
return render(request, 'newsletters/email.html', {
'newsletter': newsletter,
'agenda_events': newsletter.newsletterevent_set.all().order_by(
'start_datetime'),
'main_partner': main_partner,
'lang_code': request.LANGUAGE_CODE
'lang_code': lang_code
})
......
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