~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/code/browser/sourcepackagerecipe.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2012-01-04 12:04:29 UTC
  • mfrom: (14625.1.2 hide-forbidden-sprbs)
  • Revision ID: launchpad@pqm.canonical.com-20120104120429-9up4kvcasxykd355
[r=jtv][bug=882834] Do not show SourcePackageRecipeBuilds that the
        user can't see in the SourcePackageRecipe views.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2010-2011 Canonical Ltd.  This software is licensed under the
 
1
# Copyright 2010-2012 Canonical Ltd.  This software is licensed under the
2
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3
3
 
4
4
"""SourcePackageRecipe views."""
350
350
        other circumstance which resulted in the build not being completed).
351
351
        This allows started but unfinished builds to show up in the view but
352
352
        be discarded as more recent builds become available.
 
353
 
 
354
        Builds that the user does not have permission to see are excluded.
353
355
        """
354
 
        builds = list(recipe.pending_builds)
 
356
        builds = [build for build in recipe.pending_builds
 
357
            if check_permission('launchpad.View', build)]
355
358
        for build in recipe.completed_builds:
 
359
            if not check_permission('launchpad.View', build):
 
360
                continue
356
361
            builds.append(build)
357
362
            if len(builds) >= 5:
358
363
                break
383
388
        """
384
389
        initial_values = {'distroseries': self.context.distroseries}
385
390
        build = self.context.last_build
386
 
        if build is not None:
387
 
            initial_values['archive'] = build.archive
 
391
        if build:
 
392
            # If the build can't be viewed, the archive can't.
 
393
            if check_permission('launchpad.View', build):
 
394
                initial_values['archive'] = build.archive
388
395
        return initial_values
389
396
 
390
397
    class schema(Interface):