Daily stats view.
[wolnelektury.git] / src / push / views.py
1 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
2 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
3 #
4 from django.contrib.auth.decorators import permission_required
5 from django.http.response import HttpResponseRedirect
6 from django.shortcuts import render
7 from django.urls import reverse
8
9 from push.forms import NotificationForm
10
11
12 @permission_required('push.change_notification')
13 def notification_form(request):
14     if request.method == 'POST':
15         form = NotificationForm(data=request.POST, files=request.FILES or None)
16         if form.is_valid():
17             form.save()
18             return HttpResponseRedirect(reverse('notification_sent'))
19     else:
20         form = NotificationForm()
21     return render(request, 'push/notification_form.html', {'form': form})
22
23
24 def notification_sent(request):
25     return render(request, 'push/notification_sent.html')