Commit 3ee093de authored by Jelle Besseling's avatar Jelle Besseling

Merge branch 'fix/events-pushnotifications' into 'master'

Fix event push notifications form redirect and field labels

See merge request !1271
parents 6eee70b9 2a3a1455
......@@ -4,9 +4,8 @@ from django.contrib import messages
from django.contrib.admin import helpers
from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.http import HttpResponse, HttpResponseRedirect
from django.http import HttpResponse
from django.shortcuts import get_object_or_404, redirect
from django.urls import reverse
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.utils.text import slugify
......@@ -89,10 +88,10 @@ class RegistrationAdminFields(FormView):
messages.success(self.request,
_("Registration successfully saved."))
if '_save' in self.request.POST:
return HttpResponseRedirect(reverse(
return redirect(
'admin:events_registration_change',
args=[str(self.registration.pk)]
))
self.registration.pk
)
except RegistrationError as e:
messages.error(self.request, e)
return self.render_to_response(self.get_context_data(form=form))
......@@ -105,10 +104,10 @@ class RegistrationAdminFields(FormView):
return super().dispatch(request, *args, **kwargs)
except RegistrationError:
pass
return HttpResponseRedirect(reverse(
return redirect(
'admin:events_registration_change',
args=[str(self.registration.pk)]
))
self.registration.pk
)
@method_decorator(staff_member_required, name='dispatch')
......@@ -157,22 +156,18 @@ class EventMessage(FormView):
title_en=values['title_en'],
body_nl=values['title_nl'],
body_en=values['title_en'],
url=values['url'],
url=values['url'] if values['url'] else None,
category=Category.objects.get(key='event')
)
message.save()
message.users.set([r.member for r in self.event.participants
if r.member])
message.send()
print(message)
messages.success(self.request,
_("Message sent successfully."))
if '_save' in self.request.POST:
return redirect(
'admin:events_event_details',
args=[str(self.event.pk)]
)
return redirect('admin:events_event_details', self.event.pk)
def dispatch(self, request, *args, **kwargs):
self.event = get_object_or_404(Event, pk=self.kwargs['pk'])
......@@ -328,5 +323,4 @@ class EventRegistrationsMarkPresent(View, PermissionRequiredMixin):
event.registration_set.filter(pk__in=registrations_query).update(
present=True, payment=Registration.PAYMENT_CASH)
return HttpResponseRedirect(reverse('admin:events_event_details',
args=[str(event.pk)]))
return redirect('admin:events_event_details', event.pk)
......@@ -90,8 +90,8 @@ class FieldsForm(forms.Form):
class EventMessageForm(forms.Form):
"""Form that outputs a widget to get info to send a push notification"""
title_en = forms.CharField(required=True, max_length=150)
title_nl = forms.CharField(required=True, max_length=150)
body_en = forms.CharField(required=True)
body_nl = forms.CharField(required=True)
url = forms.CharField(max_length=256)
title_en = forms.CharField(label=_('Title (EN)'), max_length=150)
title_nl = forms.CharField(label=_('Title (NL)'), max_length=150)
body_en = forms.CharField(label=_('Body (EN)'), widget=forms.Textarea)
body_nl = forms.CharField(label=_('Body (NL)'), widget=forms.Textarea)
url = forms.CharField(max_length=256, required=False)
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: 2019-05-22 20:11+0200\n"
"PO-Revision-Date: 2019-05-22 20:13+0200\n"
"POT-Creation-Date: 2019-05-27 21:30+0200\n"
"PO-Revision-Date: 2019-05-27 21:31+0200\n"
"Last-Translator: Thom Wiggers <thom@thomwiggers.nl>\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 1.8.7.1\n"
"X-Generator: Poedit 2.2.1\n"
#: admin.py
msgid "lecture year"
......@@ -138,6 +138,22 @@ msgstr "Studievereniginig Thalia evenementenkalender"
msgid "order"
msgstr "volgorde"
#: forms.py
msgid "Title (EN)"
msgstr "Titel (EN)"
#: forms.py
msgid "Title (NL)"
msgstr "Titel (NL)"
#: forms.py
msgid "Body (EN)"
msgstr "Bericht (EN)"
#: forms.py
msgid "Body (NL)"
msgstr "Bericht (NL)"
#: models.py
msgid "Drinks"
msgstr "Borrel"
......
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