Add helper method to package to find self in testing repo

This will be useful in templates getting touched in an upcoming commit.

Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2010-07-06 18:53:03 -05:00
parent edfdc2e38b
commit b6fb5e02e5

View File

@ -321,6 +321,16 @@ def is_same_version(self, other):
and self.pkgver == other.pkgver \
and self.pkgrel == other.pkgrel
def in_testing(self):
'''attempt to locate this package in a testing repo; if we are in
a testing repo we will always return None.'''
if self.repo.testing:
return None
try:
return Package.objects.get(repo__testing=True,
pkgname=self.pkgname, arch=self.arch)
except Package.DoesNotExist:
return None
class Signoff(models.Model):
pkg = models.ForeignKey(Package)