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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
# Copyright 2009 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Browser code for the malone application."""
__metaclass__ = type
__all__ = [
'MaloneApplicationNavigation',
'MaloneRelatedPages',
]
from zope.component import getUtility
from zope.security.interfaces import Unauthorized
from lp.bugs.browser.bug import MaloneView
from lp.bugs.interfaces.bug import IBugSet
from lp.bugs.interfaces.bugtracker import IBugTrackerSet
from lp.bugs.interfaces.cve import ICveSet
from lp.bugs.interfaces.malone import IMaloneApplication
from lp.bugs.publisher import BugsLayer
from lp.registry.interfaces.distribution import IDistributionSet
from lp.registry.interfaces.product import IProductSet
from lp.services.webapp import (
canonical_url,
Link,
Navigation,
stepto,
)
from lp.services.webapp.authorization import check_permission
from lp.services.webapp.menu import NavigationMenu
class MaloneApplicationNavigation(Navigation):
usedfor = IMaloneApplication
newlayer = BugsLayer
@stepto('bugs')
def bugs(self):
return getUtility(IBugSet)
@stepto('bugtrackers')
def bugtrackers(self):
return getUtility(IBugTrackerSet)
@stepto('cve')
def cve(self):
return getUtility(ICveSet)
@stepto('distros')
def distros(self):
return getUtility(IDistributionSet)
@stepto('projects')
def projects(self):
return getUtility(IProductSet)
@stepto('products')
def products(self):
return self.redirectSubTree(
canonical_url(getUtility(IProductSet)), status=301)
def traverse(self, name):
# Make /bugs/$bug.id, /bugs/$bug.name /malone/$bug.name and
# /malone/$bug.id Just Work
bug = getUtility(IBugSet).getByNameOrID(name)
if not check_permission("launchpad.View", bug):
return None
return bug
class MaloneRelatedPages(NavigationMenu):
facet = 'bugs'
title = 'Related pages'
usedfor = MaloneView
links = ['bugtrackers', 'cvetracker']
def bugtrackers(self):
url = canonical_url(getUtility(IBugTrackerSet))
text = "Bug trackers"
return Link(url, text, icon='bug')
def cvetracker(self):
text = 'CVE tracker'
return Link('cve/', text, icon='cve')
|