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

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