...
 
Commits (10)
......@@ -10,4 +10,4 @@ done
cd /usr/src/app/website/
>&2 echo "Running ./manage.py $@"
./manage.py $@
exec ./manage.py $@
......@@ -17,7 +17,7 @@ cd /usr/src/app/website/
./manage.py compress --force
>&2 echo "Running site with uwsgi"
uwsgi --chdir /usr/src/app/website \
exec uwsgi --chdir /usr/src/app/website \
--socket :8000 \
--socket-timeout 1800 \
--uid 33 \
......
import csv
from django.conf import settings
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 +89,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 +105,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')
......@@ -152,6 +152,8 @@ class EventMessage(FormView):
def form_valid(self, form):
values = form.cleaned_data
if not values['url']:
values['url'] = settings.BASE_URL + self.event.get_absolute_url()
message = Message(
title_nl=values['title_nl'],
title_en=values['title_en'],
......@@ -164,15 +166,11 @@ class EventMessage(FormView):
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 +326,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,12 @@ 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,
help_text=_('The notification opens to the event by default.')
)
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-28 13:31+0200\n"
"PO-Revision-Date: 2019-05-28 13: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,26 @@ 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)"
#: forms.py
msgid "The notification opens to the event by default."
msgstr "De notificatie opent standaard het evenement."
#: models.py
msgid "Drinks"
msgstr "Borrel"
......
......@@ -12,7 +12,7 @@ def render_event_cards(context, events=None):
if events is None:
events = Event.objects.filter(
published=True,
start__lte=timezone.now() + timezone.timedelta(hours=24),
start__gte=timezone.now() - timezone.timedelta(hours=24),
end__gte=timezone.now()
).order_by('start')[:6]
......
......@@ -31,7 +31,7 @@ class NewsletterAdmin(TranslatedModelAdmin):
fieldsets = (
(None, {
'fields': (
'title', 'date', 'description'
'title', 'date', 'send_date', 'description'
)
}),
)
......
......@@ -3,7 +3,8 @@
from django.conf import settings
from django.core.mail import EmailMultiAlternatives
from django.template.loader import get_template
from django.utils import translation
from django.utils import translation, timezone
from django.utils.timezone import make_aware
from members.models import Member
from newsletters import services
......@@ -18,7 +19,15 @@ def send_newsletter(newsletter):
"""
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 = None
if newsletter.date:
datetime = make_aware(timezone.datetime(
year=newsletter.date.year,
month=newsletter.date.month,
day=newsletter.date.day,
)) if newsletter.date else None
events = services.get_agenda(datetime)
from_email = settings.NEWSLETTER_FROM_ADDRESS
html_template = get_template('newsletters/email.html')
......
from django.core.management.base import BaseCommand
from django.utils import timezone
from newsletters import emails
from newsletters import services
from newsletters.models import Newsletter
class Command(BaseCommand):
def add_arguments(self, parser):
parser.add_argument('pk')
def handle(self, *args, **options):
newsletters = Newsletter.objects.filter(
send_date__lte=timezone.now(),
sent=False
)
for n in newsletters:
emails.send_newsletter(n)
services.send_newsletter(n)
......@@ -5,6 +5,7 @@ from django.template.loader import get_template
from django.utils import translation, timezone
from events.models import Event
from newsletters import emails
from partners.models import Partner
......@@ -60,3 +61,9 @@ def get_agenda(start_date):
more_events = Event.objects.filter(end__gte=end_date).order_by('start')
return [*base_events, *more_events][:10]
return base_events
def send_newsletter(newsletter):
emails.send_newsletter(newsletter)
newsletter.sent = True
newsletter.save()
......@@ -9,7 +9,7 @@ from django.shortcuts import get_object_or_404, redirect, render
from django.utils.translation import activate, get_language_info
from sendfile import sendfile
from newsletters import emails, services
from newsletters import services
from newsletters.models import Newsletter
from partners.models import Partner
......@@ -95,9 +95,7 @@ def admin_send(request, pk):
return redirect(newsletter)
if request.POST:
emails.send_newsletter(newsletter)
newsletter.sent = True
newsletter.save()
services.send_newsletter(newsletter)
return redirect('admin:newsletters_newsletter_changelist')
else:
......
......@@ -37,7 +37,8 @@ class OrderSerializer(serializers.ModelSerializer):
read_only_fields = ('pk', 'payment', 'name', 'member')
payment = PaymentTypeField(source='payment.type',
choices=Payment.PAYMENT_TYPE)
choices=Payment.PAYMENT_TYPE,
read_only=True)
class AdminOrderSerializer(serializers.ModelSerializer):
......@@ -64,5 +65,6 @@ class AdminOrderSerializer(serializers.ModelSerializer):
).get('type', instance.payment.type) != instance.payment.type:
instance.payment.type = validated_data['payment']['type']
instance.payment.save()
del validated_data['payment']
if 'payment' in validated_data:
del validated_data['payment']
return super().update(instance, validated_data)
......@@ -8,6 +8,7 @@ from rest_framework.mixins import ListModelMixin
from rest_framework.response import Response
from rest_framework.viewsets import GenericViewSet, ModelViewSet
from payments.models import Payment
from pizzas.api import serializers
from pizzas.models import Product, PizzaEvent, Order
from pizzas.services import can_change_order
......@@ -54,7 +55,7 @@ class OrderViewset(ModelViewSet):
return Order.objects.none()
return Order.objects.filter(member=self.request.member,
paid=False,
payment__type=Payment.NONE,
pizza_event=event)
return Order.objects.filter(member=self.request.member,
pizza_event=event)
......
......@@ -149,11 +149,13 @@ class Message(models.Model, metaclass=ModelTranslateMeta):
data = kwargs.get('data', {})
if self.url is not None:
data['url'] = self.url
data['title'] = self.title
data['body'] = str(self.body)
message = messaging.Message(
notification=messaging.Notification(
title=self.title,
body=str(self.body),
title=data['title'],
body=data['body'],
),
data=data,
android=messaging.AndroidConfig(
......
......@@ -4,6 +4,7 @@ from django.forms import TypedChoiceField
from django.urls import reverse_lazy
from django.utils import timezone
from django.utils.safestring import mark_safe
from django.utils.text import capfirst
from django.utils.translation import ugettext_lazy as _
from utils.snippets import datetime_to_lectureyear
......@@ -17,7 +18,7 @@ class BaseRegistrationForm(forms.ModelForm):
widget=forms.widgets.SelectDateWidget(years=[
year for year in range(timezone.now().year - 50,
timezone.now().year - 10)]),
label=_('birthday')
label=capfirst(_('birthday'))
)
privacy_policy = forms.BooleanField(
......
......@@ -430,7 +430,7 @@ def execute_data_minimisation(dry_run=False):
:param dry_run: does not really remove data if True
:return: number of removed registrations
"""
deletion_period = timezone.now().date() - timezone.timedelta(days=31)
deletion_period = timezone.now() - timezone.timedelta(days=31)
objects = (Entry.objects
.filter((Q(status=Entry.STATUS_COMPLETED)
| Q(status=Entry.STATUS_REJECTED))
......