5
5
:copyright: (c) 2012 by the Sentry Team, see AUTHORS for more details.
6
6
:license: BSD, see LICENSE for more details.
7
7
"""
8
+ from django .conf import settings
8
9
from django .contrib import messages
9
10
from django .core .context_processors import csrf
10
11
from django .core .urlresolvers import reverse
16
17
from sentry .models import TagKey
17
18
from sentry .web .decorators import has_access
18
19
from sentry .web .forms .projects import (
19
- AlertSettingsForm , NotificationTagValuesForm
20
+ AlertSettingsForm , NotificationTagValuesForm , NotificationSettingsForm
20
21
)
21
22
from sentry .web .helpers import render_to_response
22
23
26
27
def notification_settings (request , team , project ):
27
28
initial = project .get_option ('notifcation:tags' , {})
28
29
30
+ general_form = NotificationSettingsForm (
31
+ data = request .POST or None ,
32
+ prefix = 'general' ,
33
+ initial = {
34
+ 'subject_prefix' : project .get_option (
35
+ 'mail:subject_prefix' , settings .EMAIL_SUBJECT_PREFIX ),
36
+ },
37
+ )
38
+
29
39
tag_forms = []
30
40
for tag in TagKey .objects .all_keys (project ):
31
41
tag_forms .append (NotificationTagValuesForm (
@@ -50,16 +60,23 @@ def notification_settings(request, team, project):
50
60
}
51
61
)
52
62
53
- if request .method == 'POST' and all (f .is_valid () for f in tag_forms ) and alert_form .is_valid ():
63
+ all_forms = [
64
+ alert_form ,
65
+ general_form ,
66
+ ] + tag_forms
67
+
68
+ if request .method == 'POST' and all (f .is_valid () for f in all_forms ):
54
69
tags = {}
55
- for form in tag_forms :
56
- values = form .cleaned_data ['values' ]
70
+ for t_form in tag_forms :
71
+ values = t_form .cleaned_data ['values' ]
57
72
if values :
58
- tags [form .tag ] = values
59
- project .update_option ('notifcation:tags' , tags )
73
+ tags [t_form .tag ] = values
60
74
75
+ project .update_option ('notifcation:tags' , tags )
61
76
project .update_option ('alert:threshold' , (
62
77
alert_form .cleaned_data ['pct_threshold' ], alert_form .cleaned_data ['min_events' ]))
78
+ project .update_option (
79
+ 'mail:subject_prefix' , general_form .cleaned_data ['subject_prefix' ])
63
80
64
81
messages .add_message (
65
82
request , messages .SUCCESS ,
@@ -71,6 +88,7 @@ def notification_settings(request, team, project):
71
88
context .update ({
72
89
'team' : team ,
73
90
'project' : project ,
91
+ 'general_form' : general_form ,
74
92
'alert_form' : alert_form ,
75
93
'tag_forms' : tag_forms ,
76
94
'page' : 'notifications' ,
0 commit comments