summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-06-09 23:16:45 +0200
committerDan McGee <dan@archlinux.org>2010-06-09 23:16:45 +0200
commit408288719e7515ac01c6eb81a5a2d9a1c63a62bc (patch)
tree875d67a208b0948b070e56aa7827aa955285db03
parentd199ac33b2ae0235cd7717b93d0c49cbbeabc7f2 (diff)
downloadarchweb-408288719e7515ac01c6eb81a5a2d9a1c63a62bc.tar.gz
archweb-408288719e7515ac01c6eb81a5a2d9a1c63a62bc.tar.xz
Enhance base package listing in package details
Add two methods to the package class, base_package() and split_packages(), that allow us to grab other related packages to one we are interested in. This allows us to list the Base Package on the package details page as a link. With the split_packages() method, we can also now list and link all sub-packages on the package details page; e.g. for 'kernel26' we can now link through to 'kernel26-firmware' and 'kernel26-headers'. Signed-off-by: Dan McGee <dan@archlinux.org>
-rw-r--r--main/models.py30
-rw-r--r--templates/packages/details.html25
2 files changed, 52 insertions, 3 deletions
diff --git a/main/models.py b/main/models.py
index e106313..7eeec85 100644
--- a/main/models.py
+++ b/main/models.py
@@ -264,6 +264,36 @@ class Package(models.Model):
self.deps_cache = deps
return deps
+ def base_package(self):
+ """
+ Locate the base package for this package. It may be this very package,
+ or if it was built in a way that the base package isn't real, will
+ return None.
+ """
+ try:
+ # start by looking for something in this repo
+ return Package.objects.get(arch=self.arch,
+ repo=self.repo, pkgname=self.pkgbase)
+ except Package.DoesNotExist:
+ # this package might be split across repos? just find one
+ # that matches the correct [testing] repo flag
+ pkglist = Package.objects.filter(arch=self.arch,
+ repo__testing=self.repo.testing, pkgname=self.pkgbase)
+ if len(pkglist) > 0:
+ return pkglist[0]
+ return None
+
+ def split_packages(self):
+ """
+ Return all packages that were built with this one (e.g. share a pkgbase
+ value). The package this method is called on will never be in the list,
+ and we will never return a package that does not have the same
+ repo.testing flag. For any non-split packages, the return value will be
+ an empty list.
+ """
+ return Package.objects.filter(arch=self.arch,
+ repo__testing=self.repo.testing, pkgbase=self.pkgbase).exclude(id=self.id)
+
def get_svn_link(self, svnpath):
linkbase = "http://repos.archlinux.org/wsvn/%s/%s/%s/"
repo = self.repo.name.lower()
diff --git a/templates/packages/details.html b/templates/packages/details.html
index 247b634..e52a005 100644
--- a/templates/packages/details.html
+++ b/templates/packages/details.html
@@ -50,10 +50,29 @@
<th>Repository:</th>
<td><a href="/packages/?repo={{ pkg.repo.name|capfirst }}"
title="Browse the {{ pkg.repo.name|capfirst }} repository">{{ pkg.repo.name|capfirst }}</a></td>
- </tr>{% ifnotequal pkg.pkgname pkg.pkgbase %}<tr>
- <th>Base Package Name:</th>
+ </tr>
+ {% ifequal pkg.pkgname pkg.pkgbase %}
+ {% with pkg.split_packages as splits %}{% if splits %}
+ <tr>
+ <th>Split Packages:</th>
+ <td>
+ {% for s in splits %}
+ <a href="{{ s.get_absolute_url }}">{{ s.pkgname }}</a><br/>
+ {% endfor %}
+ </td>
+ </tr>
+ {% endif %}{% endwith %}
+ {% else %}
+ <tr>
+ <th>Base Package:</th>
+ {% if pkg.base_package %}
+ <td><a href="{{ pkg.base_package.get_absolute_url }}">{{ pkg.pkgbase }}</a></td>
+ {% else %}
<td>{{ pkg.pkgbase }}</td>
- </tr>{% endifnotequal %}<tr>
+ {% endif %}
+ </tr>
+ {% endifequal %}
+ <tr>
<th>Description:</th>
<td>{% if pkg.pkgdesc %}{{ pkg.pkgdesc }}{% endif %}</td>
</tr><tr>