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
|
# Copyright 2009 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Views, navigation and actions for CodeReviewVotes."""
__metaclass__ = type
from zope.interface import Interface
from canonical.launchpad import _
from canonical.launchpad.webapp import canonical_url
from lp.app.browser.launchpadform import (
action,
LaunchpadFormView,
)
from lp.code.errors import (
ReviewNotPending,
UserHasExistingReview,
)
from lp.services.fields import PublicPersonChoice
class ReassignSchema(Interface):
"""Schema to use when reassigning the reviewer for a requested review."""
reviewer = PublicPersonChoice(title=_('Reviewer'), required=True,
description=_('A person who you want to review this.'),
vocabulary='ValidPersonOrTeam')
class CodeReviewVoteReassign(LaunchpadFormView):
"""View for reassinging the reviewer for a requested review."""
schema = ReassignSchema
page_title = label = 'Reassign review request'
@property
def next_url(self):
return canonical_url(self.context.branch_merge_proposal)
cancel_url = next_url
@action('Reassign', name='reassign')
def reassign_action(self, action, data):
"""Use the form data to change the review request reviewer."""
self.context.reassignReview(data['reviewer'])
def validate(self, data):
"""Make sure that the reassignment can happen."""
reviewer = data.get('reviewer')
if reviewer is not None:
try:
self.context.validateReasignReview(reviewer)
except (ReviewNotPending, UserHasExistingReview), e:
self.addError(str(e))
|