~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/bugs/browser/bugnomination.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-05-18 07:52:34 UTC
  • mfrom: (13060.1.1 nomination-page-oops)
  • Revision ID: launchpad@pqm.canonical.com-20110518075234-rbeu6ymqtevggzmg
[r=stevenk][bug=671002] If a use hacks lands on the bug nomination
        view and they are not authorised,
        redirect back to the bug target page with an error message.

Show diffs side-by-side

added added

removed removed

Lines of Context:
67
67
        submit_action = self.__class__.actions.byname['actions.submit']
68
68
        if self.userIsReleaseManager():
69
69
            submit_action.label = _("Target")
70
 
        else:
 
70
        elif self.userIsBugSupervisor():
71
71
            submit_action.label = _("Nominate")
 
72
        else:
 
73
            self.request.response.addErrorNotification(
 
74
                "You do not have permission to nominate this bug.")
 
75
            self.request.response.redirect(
 
76
                canonical_url(self.current_bugtask))
72
77
 
73
78
    @property
74
79
    def label(self):
89
94
        return check_permission(
90
95
            "launchpad.Driver", current_bugtask.target)
91
96
 
 
97
    def userIsBugSupervisor(self):
 
98
        """Is the current user the bug supervisor?"""
 
99
        current_bugtask = getUtility(ILaunchBag).bugtask
 
100
        return check_permission(
 
101
            "launchpad.BugSupervisor", current_bugtask.target)
 
102
 
92
103
    def userCanChangeDriver(self):
93
104
        """Can the current user set the release management team?"""
94
105
        return check_permission(