-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathviews.py
More file actions
63 lines (54 loc) · 2.27 KB
/
views.py
File metadata and controls
63 lines (54 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from django.contrib.admin.views.decorators import staff_member_required
from django.shortcuts import render
from plugins.notification_manager import forms
from security import decorators
from plugins.notification_manager.logic import get_plugin_settings, save_plugin_settings
@staff_member_required
@decorators.has_journal
def manager(request):
"""
The manager view for the Notification Manager plugin.
:param request: the request object
"""
(
notification_manager_enabled,
notification_manager_email,
notification_manager_password,
notification_manager_url,
notification_manager_authorization_url,
notification_manager_authenticate_send,
) = get_plugin_settings(request.journal)
if request.POST:
form = forms.NotificationManagerForm(request.POST)
if form.is_valid():
notification_manager_enabled = form.cleaned_data["enabled"]
notification_manager_email = form.cleaned_data["email"]
notification_manager_password = form.cleaned_data["password"]
notification_manager_url = form.cleaned_data["url"]
notification_manager_authorization_url = form.cleaned_data["authentication_url"]
notification_manager_authenticate_send = form.cleaned_data["authentication_enabled"]
save_plugin_settings(
notification_manager_enabled,
notification_manager_email,
notification_manager_password,
notification_manager_url,
notification_manager_authorization_url,
notification_manager_authenticate_send,
request,
)
else:
form = forms.NotificationManagerForm(
initial={
"enabled": notification_manager_enabled,
"email": notification_manager_email,
"password": notification_manager_password,
"url": notification_manager_url,
"authentication_url": notification_manager_authorization_url,
"authentication_enabled": notification_manager_authenticate_send,
}
)
template = "notification_manager/manager.html"
context = {
"form": form
}
return render(request, template, context)