~launchpad-pqm/launchpad/devel

« back to all changes in this revision

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

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-12-22 04:08:17 UTC
  • mfrom: (14564.2.1 megalint-8)
  • Revision ID: launchpad@pqm.canonical.com-20111222040817-zx0jfft9hedsc8he
[r=jtv][no-qa] Lint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2009 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2009-2011 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
 
"""Views to generate CVE reports (as in distro and distroseries/+cve pages)."""
 
4
"""Views to generate CVE reports (as in distro & distroseries/+cve pages)."""
5
5
 
6
6
__metaclass__ = type
7
7
 
48
48
 
49
49
    @cachedproperty
50
50
    def open_cve_bugtasks(self):
51
 
        """Return BugTaskCves for bugs with open bugtasks in the context."""
52
 
        search_params = BugTaskSearchParams(self.user,
53
 
            status=any(*UNRESOLVED_BUGTASK_STATUSES))
 
51
        """Find BugTaskCves for bugs with open bugtasks in the context."""
 
52
        search_params = BugTaskSearchParams(
 
53
            self.user, status=any(*UNRESOLVED_BUGTASK_STATUSES))
54
54
        return self._buildBugTaskCves(search_params)
55
55
 
56
56
    @cachedproperty
57
57
    def resolved_cve_bugtasks(self):
58
 
        """Return BugTaskCves for bugs with resolved bugtasks in the context."""
59
 
        search_params = BugTaskSearchParams(self.user,
60
 
            status=any(*RESOLVED_BUGTASK_STATUSES))
 
58
        """Find BugTaskCves for bugs with resolved bugtasks in the context."""
 
59
        search_params = BugTaskSearchParams(
 
60
            self.user, status=any(*RESOLVED_BUGTASK_STATUSES))
61
61
        return self._buildBugTaskCves(search_params)
62
62
 
63
63
    def setContextForParams(self, params):
87
87
                has_bug_branch=badges['has_branch'],
88
88
                has_specification=badges['has_specification'],
89
89
                has_patch=badges['has_patch'])
90
 
            if not bugtaskcves.has_key(bugtask.bug.id):
 
90
            if bugtask.bug.id not in bugtaskcves:
91
91
                bugtaskcves[bugtask.bug.id] = BugTaskCve()
92
92
            bugtaskcves[bugtask.bug.id].bugtasks.append(bugtask)
93
93
 
94
94
        bugcves = getUtility(ICveSet).getBugCvesForBugTasks(bugtasks)
95
95
        for bugcve in bugcves:
96
 
            assert bugtaskcves.has_key(bugcve.bug.id)
 
96
            assert bugcve.bug.id in bugtaskcves, "Bug missing in bugcves."
97
97
            bugtaskcves[bugcve.bug.id].cves.append(bugcve.cve)
98
98
 
99
99
        # Order the dictionary items by bug ID and then return only the
100
100
        # bugtaskcve objects.
101
101
        return [bugtaskcve for bug, bugtaskcve in sorted(bugtaskcves.items())]
102