Skip to content

Commit 77ed75b

Browse files
committed
Move mail subject customization into notifications tab
1 parent f19f73d commit 77ed75b

File tree

4 files changed

+41
-11
lines changed

4 files changed

+41
-11
lines changed

src/sentry/templates/sentry/projects/notifications.html

+10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ <h3>{% trans "Events" %}</h3>
1919

2020
<p>{% trans "Sentry will automatically notify you whenever an event is first seen, or its state changes from resolved to unresolved." %}</p>
2121

22+
<div class="page-header">
23+
<h3>{% trans "General" %}</h3>
24+
</div>
25+
26+
{{ general_form|as_crispy_errors }}
27+
28+
{% for field in general_form %}
29+
{{ field|as_crispy_field }}
30+
{% endfor %}
31+
2232
<div class="page-header">
2333
<h3>{% trans "Alerts" %}</h3>
2434
</div>

src/sentry/web/forms/projects.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,10 @@ class EditProjectForm(BaseProjectForm):
111111
help_text=_('Separate multiple entries with a newline.'))
112112
resolve_age = RangeField(help_text=_('Treat an event as resolved if it hasn\'t been seen for this amount of time.'),
113113
required=False, min_value=0, max_value=168, step_value=1)
114-
mail_subject_prefix = forms.CharField(label=_('Mail Subject Prefix'), required=False)
115114
owner = UserField(required=False)
116115

117116
class Meta:
118-
fields = ('name', 'platform', 'public', 'team', 'owner', 'slug', 'mail_subject_prefix')
117+
fields = ('name', 'platform', 'public', 'team', 'owner', 'slug')
119118
model = Project
120119

121120
def __init__(self, request, team_list, data, instance, *args, **kwargs):
@@ -155,6 +154,12 @@ class AlertSettingsForm(forms.Form):
155154
help_text=_('Generate an alert only when an event is seen more than this many times during the interval.'),)
156155

157156

157+
class NotificationSettingsForm(forms.Form):
158+
subject_prefix = forms.CharField(
159+
label=_('Mail Subject Prefix'), required=False,
160+
help_text=_('Choose a custom prefix for emails from this project.'))
161+
162+
158163
class NotificationTagValuesForm(forms.Form):
159164
values = forms.CharField(required=False)
160165

src/sentry/web/frontend/projects/notifications.py

+24-6
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
:copyright: (c) 2012 by the Sentry Team, see AUTHORS for more details.
66
:license: BSD, see LICENSE for more details.
77
"""
8+
from django.conf import settings
89
from django.contrib import messages
910
from django.core.context_processors import csrf
1011
from django.core.urlresolvers import reverse
@@ -16,7 +17,7 @@
1617
from sentry.models import TagKey
1718
from sentry.web.decorators import has_access
1819
from sentry.web.forms.projects import (
19-
AlertSettingsForm, NotificationTagValuesForm
20+
AlertSettingsForm, NotificationTagValuesForm, NotificationSettingsForm
2021
)
2122
from sentry.web.helpers import render_to_response
2223

@@ -26,6 +27,15 @@
2627
def notification_settings(request, team, project):
2728
initial = project.get_option('notifcation:tags', {})
2829

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+
2939
tag_forms = []
3040
for tag in TagKey.objects.all_keys(project):
3141
tag_forms.append(NotificationTagValuesForm(
@@ -50,16 +60,23 @@ def notification_settings(request, team, project):
5060
}
5161
)
5262

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):
5469
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']
5772
if values:
58-
tags[form.tag] = values
59-
project.update_option('notifcation:tags', tags)
73+
tags[t_form.tag] = values
6074

75+
project.update_option('notifcation:tags', tags)
6176
project.update_option('alert:threshold', (
6277
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'])
6380

6481
messages.add_message(
6582
request, messages.SUCCESS,
@@ -71,6 +88,7 @@ def notification_settings(request, team, project):
7188
context.update({
7289
'team': team,
7390
'project': project,
91+
'general_form': general_form,
7492
'alert_form': alert_form,
7593
'tag_forms': tag_forms,
7694
'page': 'notifications',

src/sentry/web/frontend/projects/settings.py

-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
:copyright: (c) 2012 by the Sentry Team, see AUTHORS for more details.
66
:license: BSD, see LICENSE for more details.
77
"""
8-
from django.conf import settings
98
from django.contrib import messages
109
from django.core.context_processors import csrf
1110
from django.core.urlresolvers import reverse
@@ -35,14 +34,12 @@ def manage_project(request, team, project):
3534
'origins': '\n'.join(project.get_option('sentry:origins', None) or []),
3635
'owner': project.owner,
3736
'resolve_age': int(project.get_option('sentry:resolve_age', 0)),
38-
'mail_subject_prefix': project.get_option('mail:subject_prefix', settings.EMAIL_SUBJECT_PREFIX),
3937
})
4038

4139
if form.is_valid():
4240
project = form.save()
4341
project.update_option('sentry:origins', form.cleaned_data.get('origins') or [])
4442
project.update_option('sentry:resolve_age', form.cleaned_data.get('resolve_age'))
45-
project.update_option('mail:subject_prefix', form.cleaned_data.get('mail_subject_prefix'))
4643
messages.add_message(
4744
request, messages.SUCCESS,
4845
_('Changes to your project were saved.'))

0 commit comments

Comments
 (0)