2011-04-13 08:50:24 +02:00
|
|
|
from django.db import models
|
|
|
|
|
2012-04-28 18:16:05 +02:00
|
|
|
|
2011-04-13 08:50:24 +02:00
|
|
|
class Herd(models.Model):
|
2011-04-13 19:00:31 +02:00
|
|
|
herd = models.CharField(max_length=128, unique=True)
|
|
|
|
email = models.CharField(max_length=128, blank=True, null=True)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
if self.email:
|
|
|
|
return '%s <%s>' % (self.herd, self.email)
|
|
|
|
return self.herd
|
2011-04-13 08:50:24 +02:00
|
|
|
|
2012-04-28 18:16:05 +02:00
|
|
|
|
2011-04-13 08:50:24 +02:00
|
|
|
class Maintainer(models.Model):
|
2011-04-13 19:00:31 +02:00
|
|
|
name = models.CharField(max_length=128)
|
2011-04-15 19:28:37 +02:00
|
|
|
email = models.CharField(max_length=128, unique=True)
|
2011-04-13 19:00:31 +02:00
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
return '%s <%s>' % (self.name, self.email)
|
|
|
|
|
2012-04-28 18:16:05 +02:00
|
|
|
|
2011-04-13 19:00:31 +02:00
|
|
|
class Package(models.Model):
|
|
|
|
category = models.CharField(max_length=128)
|
|
|
|
name = models.CharField(max_length=128)
|
|
|
|
description = models.TextField(blank=True)
|
2012-04-04 17:31:54 +02:00
|
|
|
homepage = models.TextField(blank=True)
|
2011-04-13 19:00:31 +02:00
|
|
|
herds = models.ManyToManyField(Herd, blank=True)
|
|
|
|
maintainers = models.ManyToManyField(Maintainer, blank=True)
|
|
|
|
|
2011-08-25 15:39:54 +02:00
|
|
|
' For performance, we keep pre-computed counters '
|
2011-04-14 08:52:26 +02:00
|
|
|
n_versions = models.IntegerField(default=0)
|
|
|
|
n_packaged = models.IntegerField(default=0)
|
2011-04-25 22:27:32 +02:00
|
|
|
n_overlay = models.IntegerField(default=0)
|
2011-04-14 08:52:26 +02:00
|
|
|
|
2012-03-02 18:01:46 +01:00
|
|
|
' And we also pre-compute last versions '
|
2012-04-28 18:16:05 +02:00
|
|
|
last_version_gentoo = models.ForeignKey(
|
|
|
|
'Version', blank=True, null=True, related_name="last_version_gentoo",
|
|
|
|
on_delete=models.SET_NULL
|
|
|
|
)
|
|
|
|
last_version_overlay = models.ForeignKey(
|
|
|
|
'Version', blank=True, null=True, related_name="last_version_overlay",
|
|
|
|
on_delete=models.SET_NULL
|
|
|
|
)
|
|
|
|
last_version_upstream = models.ForeignKey(
|
|
|
|
'Version', blank=True, null=True, related_name="last_version_upstream",
|
|
|
|
on_delete=models.SET_NULL
|
|
|
|
)
|
2012-03-02 18:01:46 +01:00
|
|
|
|
2011-04-13 19:00:31 +02:00
|
|
|
def __unicode__(self):
|
|
|
|
return '%s/%s' % (self.category, self.name)
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
unique_together = ['category', 'name']
|
2011-04-13 08:50:24 +02:00
|
|
|
|
2012-04-28 18:16:05 +02:00
|
|
|
|
2011-04-13 08:50:24 +02:00
|
|
|
class Version(models.Model):
|
2011-04-13 19:00:31 +02:00
|
|
|
package = models.ForeignKey(Package)
|
|
|
|
slot = models.CharField(max_length=128)
|
|
|
|
revision = models.CharField(max_length=128)
|
|
|
|
version = models.CharField(max_length=128)
|
|
|
|
packaged = models.BooleanField()
|
2011-11-23 18:03:07 +01:00
|
|
|
overlay = models.CharField(max_length=128, default='gentoo', db_index=True)
|
2011-04-13 19:00:31 +02:00
|
|
|
urls = models.TextField(blank=True)
|
2011-08-25 15:39:54 +02:00
|
|
|
alive = models.BooleanField(default=True, db_index=True)
|
2011-04-13 19:00:31 +02:00
|
|
|
|
|
|
|
def __unicode__(self):
|
2012-04-28 18:16:05 +02:00
|
|
|
return '%s/%s-%s-%s:%s [%s]' % (
|
|
|
|
self.package.category, self.package.name, self.version,
|
|
|
|
self.revision, self.slot, self.overlay
|
|
|
|
)
|
2011-04-13 19:00:31 +02:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
unique_together = ['package', 'slot', 'revision', 'version', 'overlay']
|
2011-04-13 08:50:24 +02:00
|
|
|
|
2012-04-28 18:16:05 +02:00
|
|
|
|
2011-08-25 15:39:54 +02:00
|
|
|
class VersionLog(models.Model):
|
|
|
|
VERSION_ADDED = 1
|
|
|
|
VERSION_REMOVED = 2
|
|
|
|
VERSION_ACTIONS = (
|
|
|
|
(VERSION_ADDED, 'Added'),
|
|
|
|
(VERSION_REMOVED, 'Removed')
|
|
|
|
)
|
|
|
|
|
|
|
|
package = models.ForeignKey(Package)
|
2012-04-04 14:33:40 +02:00
|
|
|
datetime = models.DateTimeField(auto_now_add=True)
|
2011-08-25 15:39:54 +02:00
|
|
|
slot = models.CharField(max_length=128)
|
|
|
|
revision = models.CharField(max_length=128)
|
|
|
|
version = models.CharField(max_length=128)
|
|
|
|
packaged = models.BooleanField()
|
|
|
|
overlay = models.CharField(max_length=128, default='gentoo')
|
|
|
|
action = models.IntegerField(choices=VERSION_ACTIONS)
|
|
|
|
|
|
|
|
def tag(self):
|
|
|
|
return '%s-%s:%s-[%s]' % (self.version, self.revision, self.slot,
|
|
|
|
self.overlay)
|
|
|
|
|
|
|
|
def __unicode__(self):
|
|
|
|
txt = '+ ' if self.action == self.VERSION_ADDED else '- '
|
2012-04-28 18:16:05 +02:00
|
|
|
txt += '%s/%s-%s-%s:%s [%s]' % (
|
|
|
|
self.package.category, self.package.name, self.version,
|
|
|
|
self.revision, self.slot,
|
|
|
|
self.overlay if self.overlay else '<upstream>'
|
|
|
|
)
|
2011-08-25 15:39:54 +02:00
|
|
|
return txt
|
|
|
|
|
2012-04-28 18:16:05 +02:00
|
|
|
|
2011-04-13 08:50:24 +02:00
|
|
|
class EuscanResult(models.Model):
|
2011-04-13 19:00:31 +02:00
|
|
|
package = models.ForeignKey(Package)
|
2011-04-14 08:52:26 +02:00
|
|
|
datetime = models.DateTimeField()
|
2011-04-13 19:00:31 +02:00
|
|
|
result = models.TextField(blank=True)
|
2011-04-14 08:52:26 +02:00
|
|
|
|
2012-04-28 18:16:05 +02:00
|
|
|
|
2011-04-14 08:52:26 +02:00
|
|
|
# Keep data for charts
|
2011-05-05 18:10:47 +02:00
|
|
|
class Log(models.Model):
|
2011-04-14 08:52:26 +02:00
|
|
|
datetime = models.DateTimeField()
|
|
|
|
|
2011-08-25 15:39:54 +02:00
|
|
|
' Packages up to date in the main portage tree '
|
2012-04-28 18:16:05 +02:00
|
|
|
n_packages_gentoo = models.IntegerField(default=0)
|
2011-08-25 15:39:54 +02:00
|
|
|
' Packages up to date in an overlay '
|
2012-04-28 18:16:05 +02:00
|
|
|
n_packages_overlay = models.IntegerField(default=0)
|
2011-08-25 15:39:54 +02:00
|
|
|
' Packages outdated '
|
|
|
|
n_packages_outdated = models.IntegerField(default=0)
|
|
|
|
|
|
|
|
' Versions in the main portage tree '
|
2012-04-28 18:16:05 +02:00
|
|
|
n_versions_gentoo = models.IntegerField(default=0)
|
2011-08-25 15:39:54 +02:00
|
|
|
' Versions in overlays '
|
2012-04-28 18:16:05 +02:00
|
|
|
n_versions_overlay = models.IntegerField(default=0)
|
2011-08-25 15:39:54 +02:00
|
|
|
' Upstream versions, not in the main tree or overlays '
|
|
|
|
n_versions_upstream = models.IntegerField(default=0)
|
2011-05-03 08:19:01 +02:00
|
|
|
|
|
|
|
def __unicode__(self):
|
2012-04-28 18:16:05 +02:00
|
|
|
return u'[%d:%d:%d] [%d:%d:%d]' % (
|
|
|
|
self.n_packages_gentoo, self.n_packages_overlay,
|
|
|
|
self.n_packages_outdated, self.n_versions_gentoo,
|
|
|
|
self.n_versions_overlay, self.n_versions_upstream
|
|
|
|
)
|
|
|
|
|
2011-05-03 08:19:01 +02:00
|
|
|
|
2011-05-05 18:10:47 +02:00
|
|
|
class WorldLog(Log):
|
|
|
|
def __unicode__(self):
|
|
|
|
return u'world ' + Log.__unicode__(self)
|
2011-04-14 08:52:26 +02:00
|
|
|
|
2012-04-28 18:16:05 +02:00
|
|
|
|
2011-05-05 18:10:47 +02:00
|
|
|
class CategoryLog(Log):
|
|
|
|
category = models.CharField(max_length=128)
|
2011-04-14 08:52:26 +02:00
|
|
|
|
2011-05-05 18:10:47 +02:00
|
|
|
def __unicode__(self):
|
|
|
|
return u'%s %s' % (self.category, Log.__unicode__(self))
|
2011-05-03 08:19:01 +02:00
|
|
|
|
2012-04-28 18:16:05 +02:00
|
|
|
|
2011-05-05 18:10:47 +02:00
|
|
|
class HerdLog(Log):
|
|
|
|
herd = models.ForeignKey(Herd)
|
2011-05-03 08:19:01 +02:00
|
|
|
|
|
|
|
def __unicode__(self):
|
2011-05-05 18:10:47 +02:00
|
|
|
return u'%s %s' % (self.herd, Log.__unicode__(self))
|
2011-04-14 08:52:26 +02:00
|
|
|
|
2012-04-28 18:16:05 +02:00
|
|
|
|
2011-05-05 18:10:47 +02:00
|
|
|
class MaintainerLog(Log):
|
2011-04-14 08:52:26 +02:00
|
|
|
maintainer = models.ForeignKey(Maintainer)
|
2011-05-03 08:19:01 +02:00
|
|
|
|
|
|
|
def __unicode__(self):
|
2011-05-05 18:10:47 +02:00
|
|
|
return u'%s %s' % (self.maintainer, Log.__unicode__(self))
|