evorepo/releng/models.py

159 lines
4.2 KiB
Python
Raw Normal View History

import markdown
from django.core.urlresolvers import reverse
from django.db import models
from django.db.models.signals import pre_save
from django.utils.safestring import mark_safe
from main.fields import PositiveBigIntegerField
from main.utils import set_created_field
class IsoOption(models.Model):
name = models.CharField(max_length=200)
def __unicode__(self):
return self.name
isotests: various changes and updates * isotests/fixtures/clockchoices.json: changed 'default' to 'unchanged' * isotests/fixtures/filesystems.json: removed 'check the installed system' line from one of the options * isotests/fixtures/modules.json: added 'ext2','ext3','ext4','swap','xfs','jfs','reiserFS' * isotests/models.py: * Added RollbackOption abstract class that adds the functions get_rollback_success_test and get_rollback_failed_test on top of the IsoOption abstract class for use with the Filesystem and Module classes since Test uses these both in 2 ways (regular and rollback). This keeps them seperated. * renamed the related names of these properties from rollback_test to rollback_test_set (seems more in-tune with the other relations) * isotests/views.py: * changed the order of the fields, the automatic order makes no sense. * Added help texts to the fields success, filesystem, rollback_filesystem and rollback_modules. * Removed help text from modules (made no sense) * Added a website field, should remain empty, a simplistic way to hopefully reduce spambot entries. * templates/isotests/results.html: * Removed the rollback yes/no section * The rollback labels should check get_rollback_success_test and get_rollback_failed_test. * Rollback checkbox removed. * Clearly tell users that success must only be selected if everything works right. * Clearly tell users to only fill in the rollback options if they did a rollback. * Added a thanks page that tells people thanks. * Added links between the pages. * Added links to lists with tests of either a specific iso or of any iso where a specific option was selected. Signed-off-by: Dan McGee <dan@archlinux.org> Conflicts: templates/isotests/results.html
2011-04-28 11:19:42 -07:00
class Meta:
abstract = True
class RollbackOption(IsoOption):
class Meta:
abstract = True
class Iso(models.Model):
name = models.CharField(max_length=255)
created = models.DateTimeField(editable=False)
removed = models.DateTimeField(null=True, blank=True, default=None)
active = models.BooleanField(default=True)
def get_absolute_url(self):
return reverse('releng-results-iso', args=[self.pk])
def __unicode__(self):
return self.name
class Meta:
verbose_name = 'ISO'
class Architecture(IsoOption):
pass
class IsoType(IsoOption):
class Meta:
verbose_name = 'ISO type'
class BootType(IsoOption):
pass
class HardwareType(IsoOption):
pass
class InstallType(IsoOption):
pass
class Source(IsoOption):
pass
class ClockChoice(IsoOption):
pass
isotests: various changes and updates * isotests/fixtures/clockchoices.json: changed 'default' to 'unchanged' * isotests/fixtures/filesystems.json: removed 'check the installed system' line from one of the options * isotests/fixtures/modules.json: added 'ext2','ext3','ext4','swap','xfs','jfs','reiserFS' * isotests/models.py: * Added RollbackOption abstract class that adds the functions get_rollback_success_test and get_rollback_failed_test on top of the IsoOption abstract class for use with the Filesystem and Module classes since Test uses these both in 2 ways (regular and rollback). This keeps them seperated. * renamed the related names of these properties from rollback_test to rollback_test_set (seems more in-tune with the other relations) * isotests/views.py: * changed the order of the fields, the automatic order makes no sense. * Added help texts to the fields success, filesystem, rollback_filesystem and rollback_modules. * Removed help text from modules (made no sense) * Added a website field, should remain empty, a simplistic way to hopefully reduce spambot entries. * templates/isotests/results.html: * Removed the rollback yes/no section * The rollback labels should check get_rollback_success_test and get_rollback_failed_test. * Rollback checkbox removed. * Clearly tell users that success must only be selected if everything works right. * Clearly tell users to only fill in the rollback options if they did a rollback. * Added a thanks page that tells people thanks. * Added links between the pages. * Added links to lists with tests of either a specific iso or of any iso where a specific option was selected. Signed-off-by: Dan McGee <dan@archlinux.org> Conflicts: templates/isotests/results.html
2011-04-28 11:19:42 -07:00
class Filesystem(RollbackOption):
pass
isotests: various changes and updates * isotests/fixtures/clockchoices.json: changed 'default' to 'unchanged' * isotests/fixtures/filesystems.json: removed 'check the installed system' line from one of the options * isotests/fixtures/modules.json: added 'ext2','ext3','ext4','swap','xfs','jfs','reiserFS' * isotests/models.py: * Added RollbackOption abstract class that adds the functions get_rollback_success_test and get_rollback_failed_test on top of the IsoOption abstract class for use with the Filesystem and Module classes since Test uses these both in 2 ways (regular and rollback). This keeps them seperated. * renamed the related names of these properties from rollback_test to rollback_test_set (seems more in-tune with the other relations) * isotests/views.py: * changed the order of the fields, the automatic order makes no sense. * Added help texts to the fields success, filesystem, rollback_filesystem and rollback_modules. * Removed help text from modules (made no sense) * Added a website field, should remain empty, a simplistic way to hopefully reduce spambot entries. * templates/isotests/results.html: * Removed the rollback yes/no section * The rollback labels should check get_rollback_success_test and get_rollback_failed_test. * Rollback checkbox removed. * Clearly tell users that success must only be selected if everything works right. * Clearly tell users to only fill in the rollback options if they did a rollback. * Added a thanks page that tells people thanks. * Added links between the pages. * Added links to lists with tests of either a specific iso or of any iso where a specific option was selected. Signed-off-by: Dan McGee <dan@archlinux.org> Conflicts: templates/isotests/results.html
2011-04-28 11:19:42 -07:00
class Module(RollbackOption):
pass
class Bootloader(IsoOption):
pass
class Test(models.Model):
user_name = models.CharField(max_length=500)
user_email = models.EmailField('email address')
# Great work, Django... https://code.djangoproject.com/ticket/18212
ip_address = models.GenericIPAddressField(verbose_name='IP address',
unpack_ipv4=True)
created = models.DateTimeField(editable=False)
iso = models.ForeignKey(Iso)
architecture = models.ForeignKey(Architecture)
iso_type = models.ForeignKey(IsoType)
boot_type = models.ForeignKey(BootType)
hardware_type = models.ForeignKey(HardwareType)
install_type = models.ForeignKey(InstallType)
source = models.ForeignKey(Source)
clock_choice = models.ForeignKey(ClockChoice)
filesystem = models.ForeignKey(Filesystem)
modules = models.ManyToManyField(Module, null=True, blank=True)
bootloader = models.ForeignKey(Bootloader)
rollback_filesystem = models.ForeignKey(Filesystem,
isotests: various changes and updates * isotests/fixtures/clockchoices.json: changed 'default' to 'unchanged' * isotests/fixtures/filesystems.json: removed 'check the installed system' line from one of the options * isotests/fixtures/modules.json: added 'ext2','ext3','ext4','swap','xfs','jfs','reiserFS' * isotests/models.py: * Added RollbackOption abstract class that adds the functions get_rollback_success_test and get_rollback_failed_test on top of the IsoOption abstract class for use with the Filesystem and Module classes since Test uses these both in 2 ways (regular and rollback). This keeps them seperated. * renamed the related names of these properties from rollback_test to rollback_test_set (seems more in-tune with the other relations) * isotests/views.py: * changed the order of the fields, the automatic order makes no sense. * Added help texts to the fields success, filesystem, rollback_filesystem and rollback_modules. * Removed help text from modules (made no sense) * Added a website field, should remain empty, a simplistic way to hopefully reduce spambot entries. * templates/isotests/results.html: * Removed the rollback yes/no section * The rollback labels should check get_rollback_success_test and get_rollback_failed_test. * Rollback checkbox removed. * Clearly tell users that success must only be selected if everything works right. * Clearly tell users to only fill in the rollback options if they did a rollback. * Added a thanks page that tells people thanks. * Added links between the pages. * Added links to lists with tests of either a specific iso or of any iso where a specific option was selected. Signed-off-by: Dan McGee <dan@archlinux.org> Conflicts: templates/isotests/results.html
2011-04-28 11:19:42 -07:00
related_name="rollback_test_set", null=True, blank=True)
rollback_modules = models.ManyToManyField(Module,
isotests: various changes and updates * isotests/fixtures/clockchoices.json: changed 'default' to 'unchanged' * isotests/fixtures/filesystems.json: removed 'check the installed system' line from one of the options * isotests/fixtures/modules.json: added 'ext2','ext3','ext4','swap','xfs','jfs','reiserFS' * isotests/models.py: * Added RollbackOption abstract class that adds the functions get_rollback_success_test and get_rollback_failed_test on top of the IsoOption abstract class for use with the Filesystem and Module classes since Test uses these both in 2 ways (regular and rollback). This keeps them seperated. * renamed the related names of these properties from rollback_test to rollback_test_set (seems more in-tune with the other relations) * isotests/views.py: * changed the order of the fields, the automatic order makes no sense. * Added help texts to the fields success, filesystem, rollback_filesystem and rollback_modules. * Removed help text from modules (made no sense) * Added a website field, should remain empty, a simplistic way to hopefully reduce spambot entries. * templates/isotests/results.html: * Removed the rollback yes/no section * The rollback labels should check get_rollback_success_test and get_rollback_failed_test. * Rollback checkbox removed. * Clearly tell users that success must only be selected if everything works right. * Clearly tell users to only fill in the rollback options if they did a rollback. * Added a thanks page that tells people thanks. * Added links between the pages. * Added links to lists with tests of either a specific iso or of any iso where a specific option was selected. Signed-off-by: Dan McGee <dan@archlinux.org> Conflicts: templates/isotests/results.html
2011-04-28 11:19:42 -07:00
related_name="rollback_test_set", null=True, blank=True)
success = models.BooleanField()
comments = models.TextField(null=True, blank=True)
class Release(models.Model):
release_date = models.DateField(db_index=True)
version = models.CharField(max_length=50)
kernel_version = models.CharField(max_length=50, blank=True)
torrent_infohash = models.CharField(max_length=64, blank=True)
file_size = PositiveBigIntegerField(null=True, blank=True)
created = models.DateTimeField(editable=False)
available = models.BooleanField(default=True)
info = models.TextField('Public information', blank=True)
torrent_data = models.TextField(blank=True)
class Meta:
get_latest_by = 'release_date'
ordering = ('-release_date', '-version')
def __unicode__(self):
return self.version
def get_absolute_url(self):
return reverse('releng-release-detail', args=[self.version])
def dir_path(self):
return "iso/%s/" % self.version
def iso_url(self):
return "iso/%s/archlinux-%s-dual.iso" % (self.version, self.version)
def magnet_uri(self):
query = [
('dn', "archlinux-%s-dual.iso" % self.version),
('tr', "udp://tracker.archlinux.org:6969"),
('tr', "http://tracker.archlinux.org:6969/announce"),
]
if self.torrent_infohash:
query.insert(0, ('xt', "urn:btih:%s" % self.torrent_infohash))
return "magnet:?%s" % '&'.join(['%s=%s' % (k, v) for k, v in query])
def info_html(self):
return mark_safe(markdown.markdown(
self.info, safe_mode=True, enable_attributes=False))
for model in (Iso, Test, Release):
pre_save.connect(set_created_field, sender=model,
dispatch_uid="releng.models")
# vim: set ts=4 sw=4 et: