10898.3.10
by Curtis Hovey
Moved BugRoleMixin to lp.bugs.browser.bugrole. |
1 |
# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
|
8687.15.17
by Karl Fogel
Add the copyright header block to the rest of the files under lib/lp/. |
2 |
# GNU Affero General Public License version 3 (see the file LICENSE).
|
3327.1.5
by Brad Bollenbach
checkpoint |
3 |
|
4 |
"""Browser view classes for security contacts."""
|
|
5 |
||
6 |
__metaclass__ = type |
|
10898.3.10
by Curtis Hovey
Moved BugRoleMixin to lp.bugs.browser.bugrole. |
7 |
|
8 |
__all__ = [ |
|
9 |
"SecurityContactEditView", |
|
10 |
]
|
|
11 |
||
11929.9.1
by Tim Penhey
Move launchpadform into lp.app.browser. |
12 |
from lp.app.browser.launchpadform import ( |
11403.1.4
by Henning Eggers
Reformatted imports using format-imports script r32. |
13 |
action, |
14 |
LaunchpadFormView, |
|
15 |
)
|
|
16 |
from lp.bugs.browser.bugrole import BugRoleMixin |
|
10876.5.1
by Curtis Hovey
Move security contact to bugs, the only app that *ever* used the data. |
17 |
from lp.bugs.interfaces.securitycontact import IHasSecurityContact |
14612.2.1
by William Grant
format-imports on lib/. So many imports. |
18 |
from lp.services.webapp.publisher import canonical_url |
3691.68.8
by James Henstridge
changes suggested by SteveA |
19 |
|
3327.1.5
by Brad Bollenbach
checkpoint |
20 |
|
10898.3.5
by Curtis Hovey
Validate security contact using the same rules are bug supervisor. |
21 |
class SecurityContactEditView(BugRoleMixin, LaunchpadFormView): |
3327.1.5
by Brad Bollenbach
checkpoint |
22 |
"""Browser view for editing the security contact.
|
23 |
||
24 |
self.context is assumed to implement IHasSecurityContact.
|
|
25 |
"""
|
|
26 |
||
3691.68.3
by James Henstridge
convert securitycontact edit form to LaunchpadFormView, and make LaunchpadFormView actually work |
27 |
schema = IHasSecurityContact |
28 |
field_names = ['security_contact'] |
|
29 |
||
3327.1.5
by Brad Bollenbach
checkpoint |
30 |
@property
|
9116.1.3
by Curtis Hovey
Updated product/distribution +securitycontact to UI 3.0. |
31 |
def label(self): |
32 |
"""See `LaunchpadFormView`."""
|
|
33 |
return 'Edit %s security contact' % self.context.displayname |
|
34 |
||
35 |
@property
|
|
36 |
def page_title(self): |
|
37 |
"""The page title."""
|
|
38 |
return self.label |
|
39 |
||
40 |
@property
|
|
3327.1.5
by Brad Bollenbach
checkpoint |
41 |
def initial_values(self): |
42 |
return { |
|
43 |
'security_contact': self.context.security_contact} |
|
44 |
||
10898.3.5
by Curtis Hovey
Validate security contact using the same rules are bug supervisor. |
45 |
def validate(self, data): |
46 |
"""See `LaunchpadFormView`."""
|
|
47 |
self.validateSecurityContact(data) |
|
48 |
||
3691.68.14
by James Henstridge
adjust tests to work with new LaunchpadFormView forms |
49 |
@action('Change', name='change') |
50 |
def change_action(self, action, data): |
|
3691.68.3
by James Henstridge
convert securitycontact edit form to LaunchpadFormView, and make LaunchpadFormView actually work |
51 |
security_contact = data['security_contact'] |
3644.1.1
by Brad Bollenbach
Fix OOPS bug 45780 (Assigning a team as security contact crashes if the team doesn't have a contact email) |
52 |
if self.context.security_contact == security_contact: |
53 |
return
|
|
54 |
||
3327.1.5
by Brad Bollenbach
checkpoint |
55 |
self.context.security_contact = security_contact |
56 |
if security_contact: |
|
57 |
self.request.response.addNotification( |
|
10898.3.5
by Curtis Hovey
Validate security contact using the same rules are bug supervisor. |
58 |
"Successfully changed the security contact to %s." % |
59 |
security_contact.displayname) |
|
3327.1.5
by Brad Bollenbach
checkpoint |
60 |
else: |
61 |
self.request.response.addNotification( |
|
10898.3.5
by Curtis Hovey
Validate security contact using the same rules are bug supervisor. |
62 |
"Successfully removed the security contact.") |
3327.1.5
by Brad Bollenbach
checkpoint |
63 |
|
3691.68.3
by James Henstridge
convert securitycontact edit form to LaunchpadFormView, and make LaunchpadFormView actually work |
64 |
@property
|
65 |
def next_url(self): |
|
3327.1.5
by Brad Bollenbach
checkpoint |
66 |
return canonical_url(self.context) |
9116.1.3
by Curtis Hovey
Updated product/distribution +securitycontact to UI 3.0. |
67 |
|
68 |
cancel_url = next_url |