push notifications
[wolnelektury.git] / src / push / views.py
diff --git a/src/push/views.py b/src/push/views.py
new file mode 100644 (file)
index 0000000..bbcf89d
--- /dev/null
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
+# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
+#
+from django.contrib.auth.decorators import permission_required
+from django.core.urlresolvers import reverse
+from django.http.response import HttpResponseRedirect
+from django.shortcuts import render
+
+from push.forms import NotificationForm
+
+
+@permission_required('push.change_notification')
+def notification_form(request):
+    if request.method == 'POST':
+        form = NotificationForm(data=request.POST, files=request.FILES or None)
+        if form.is_valid():
+            form.save()
+            return HttpResponseRedirect(reverse('notification_sent'))
+    else:
+        form = NotificationForm()
+    return render(request, 'push/notification_form.html', {'form': form})
+
+
+def notification_sent(request):
+    return render(request, 'push/notification_sent.html')
\ No newline at end of file