1
# Copyright 2009 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
4
"""Views, navigation and actions for CodeReviewVotes."""
9
from zope.interface import Interface
11
from canonical.launchpad import _
12
from canonical.launchpad.webapp import canonical_url
13
from lp.app.browser.launchpadform import (
17
from lp.code.errors import (
19
UserHasExistingReview,
21
from lp.services.fields import PublicPersonChoice
24
class ReassignSchema(Interface):
25
"""Schema to use when reassigning the reviewer for a requested review."""
27
reviewer = PublicPersonChoice(title=_('Reviewer'), required=True,
28
description=_('A person who you want to review this.'),
29
vocabulary='ValidPersonOrTeam')
32
class CodeReviewVoteReassign(LaunchpadFormView):
33
"""View for reassinging the reviewer for a requested review."""
35
schema = ReassignSchema
37
page_title = label = 'Reassign review request'
41
return canonical_url(self.context.branch_merge_proposal)
45
@action('Reassign', name='reassign')
46
def reassign_action(self, action, data):
47
"""Use the form data to change the review request reviewer."""
48
self.context.reassignReview(data['reviewer'])
50
def validate(self, data):
51
"""Make sure that the reassignment can happen."""
52
reviewer = data.get('reviewer')
53
if reviewer is not None:
55
self.context.validateReasignReview(reviewer)
56
except (ReviewNotPending, UserHasExistingReview), e: