diff options
author | Dusty Phillips <buchuki@gmail.com> | 2008-10-13 03:28:51 +0200 |
---|---|---|
committer | Dusty Phillips <buchuki@gmail.com> | 2008-10-13 03:28:51 +0200 |
commit | e3d50a5f49234d7163a87603d12cef70027633e3 (patch) | |
tree | 5f64c293275678c6391304e2f3b5e56b8a6a5df4 /main | |
parent | a181df791a7401e9f739d6bb5806cea8b1c19da6 (diff) | |
download | archweb-e3d50a5f49234d7163a87603d12cef70027633e3.tar.gz archweb-e3d50a5f49234d7163a87603d12cef70027633e3.tar.xz |
backport some archweb_pub changes into archweb_dev
Diffstat (limited to 'main')
-rw-r--r-- | main/models.py | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/main/models.py b/main/models.py index c62ac20..8123d07 100644 --- a/main/models.py +++ b/main/models.py @@ -198,6 +198,10 @@ class Package(models.Model): - (None, dependname, None) if no matching package is found, eg it is a virtual dep. """ + # object level cache. Doesn't last long, but helps for items rendered + # twice in the same template. + if 'deps_cache' in dir(self): + return self.deps_cache deps = [] for dep in self.packagedepend_set.order_by('depname'): # we only need depend on same-arch-packages @@ -208,10 +212,16 @@ class Package(models.Model): # couldn't find a package in the DB # it should be a virtual depend (or a removed package) deps.append({'dep': dep, 'pkg': None}) - continue + elif len(pkgs) == 1: + deps.append({'dep': dep, 'pkg': pkgs[0]}) else: - for pkg in pkgs: - deps.append({'dep': dep, 'pkg': pkg}) + tpkgs = pkgs.filter(repo__name='Testing') + if len(tpkgs) == 1: + deps.append({'dep': dep, 'pkg': tpkgs[0]}) + else: + for pkg in pkgs: + deps.append({'dep': dep, 'pkg': pkg}) + self.deps_cache = deps return deps class Signoff(models.Model): |