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