From 3e31808521e990b3b86d25de7d49cdd90a2de29f Mon Sep 17 00:00:00 2001 From: eliott Date: Sat, 8 Mar 2008 12:11:02 -0800 Subject: More changes to the multiarch model. --- main/models.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'main') diff --git a/main/models.py b/main/models.py index 1a6423c3..7b31f07b 100644 --- a/main/models.py +++ b/main/models.py @@ -137,6 +137,8 @@ class Arch(models.Model): class Meta: db_table = 'arch' ordering = ['name'] + def __str__(self): + return self.name class Repo(models.Model): id = models.AutoField(primary_key=True) @@ -154,8 +156,8 @@ def last_update(self): class Package(models.Model): id = models.AutoField(primary_key=True) - repo = models.ForeignKey(Repo) - arch = models.ForeignKey(Arch) + repo = models.ForeignKey('Repo') + arch = models.ForeignKey('Arch') maintainer = models.ForeignKey(User, related_name='package_maintainer') needupdate = models.BooleanField(default=False) pkgname = models.CharField(maxlength=255) @@ -163,7 +165,7 @@ class Package(models.Model): pkgrel = models.CharField(maxlength=255) pkgdesc = models.CharField(maxlength=255) url = models.URLField() - depends = models.ForeignKey(PackageDepends) + depends = models.ForeignKey('PackageDepends') last_update = models.DateTimeField(null=True, blank=True) objects = PackageManager() class Meta: @@ -173,6 +175,16 @@ class Meta: def get_absolute_url(self): return '/packages/%i/' % self.id + def required_by_urlize(self): + urls = [] + requiredby = PackageDepends.objects.filter(depname=self.pkgname) + for req in requiredby.package_set.all(): + urls.append( + '
  • %s
  • ' % \ + (req.id,req.pkgname)) + return ''.join(urls) + + def depends_urlize(self): urls = [] for dep in self.packagedepends_set.all(): @@ -181,7 +193,7 @@ def depends_urlize(self): except IndexError: # couldn't find a package in the DB # it might be a virtual depend - urls.append('
  • %s
  • ' % dep.depname) + urls.append('
  • %s (v)
  • ' % dep.depname) continue urls.append( '
  • %s
  • ' % (p.id,dep.depname)) @@ -189,14 +201,14 @@ def depends_urlize(self): class PackageFile(models.Model): id = models.AutoField(primary_key=True) - pkg = models.ForeignKey(Package) + pkg = models.ForeignKey('Package') path = models.CharField(maxlength=255) class Meta: db_table = 'packages_files' class PackageDepends(models.Model): id = models.AutoField(primary_key=True) - pkg = models.ForeignKey(Package) + pkg = models.ForeignKey('Package') depname = models.CharField(db_index=True, maxlength=255) depvcmp = models.CharField(maxlength=255) class Meta: @@ -214,8 +226,8 @@ class Meta: class TodolistPkg(models.Model): id = models.AutoField(primary_key=True) - list = models.ForeignKey(Todolist) - pkg = models.ForeignKey(Package) + list = models.ForeignKey('Todolist') + pkg = models.ForeignKey('Package') complete = models.BooleanField(default=False) class Meta: db_table = 'todolists_pkgs' -- cgit v1.2.3-54-g00ecf