diff options
author | Dan McGee <dan@archlinux.org> | 2011-02-16 18:09:46 -0600 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-03-23 15:44:41 -0500 |
commit | 97437d27b7b3d01bfd2e2ae628e6612c149324b4 (patch) | |
tree | 79171e35d639e3ad38b02171d704c389a1f978c8 /packages/models.py | |
parent | 5f7fbcb7133b1c04824d1aa4ded7af8feef13c2e (diff) |
Add new package parts models
This allows us to store conflicts, provisions (provides), and replacements
in the database, things we weren't capturing before. All can be multivalued,
just like License and PackageGroup.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'packages/models.py')
-rw-r--r-- | packages/models.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/packages/models.py b/packages/models.py index 5dbdea45..63a7255b 100644 --- a/packages/models.py +++ b/packages/models.py @@ -57,6 +57,50 @@ class License(models.Model): class Meta: ordering = ['name'] +class Conflict(models.Model): + pkg = models.ForeignKey('main.Package', related_name='conflicts') + name = models.CharField(max_length=255, db_index=True) + comparison = models.CharField(max_length=255, default='') + version = models.CharField(max_length=255, default='') + + def __unicode__(self): + if self.version: + return u'%s%s%s' % (self.name, self.comparison, self.version) + return self.name + + class Meta: + ordering = ['name'] + +class Provision(models.Model): + pkg = models.ForeignKey('main.Package', related_name='provides') + name = models.CharField(max_length=255, db_index=True) + # comparison must be '=' for provides + comparison = '=' + version = models.CharField(max_length=255, default='') + + def __unicode__(self): + if self.version: + return u'%s=%s' % (self.name, self.version) + return self.name + + class Meta: + ordering = ['name'] + +class Replacement(models.Model): + pkg = models.ForeignKey('main.Package', related_name='replaces') + name = models.CharField(max_length=255, db_index=True) + comparison = models.CharField(max_length=255, default='') + version = models.CharField(max_length=255, default='') + + def __unicode__(self): + if self.version: + return u'%s%s%s' % (self.name, self.comparison, self.version) + return self.name + + class Meta: + ordering = ['name'] + + def remove_inactive_maintainers(sender, instance, created, **kwargs): # instance is an auth.models.User; we want to remove any existing # maintainer relations if the user is no longer active |