diff options
author | Dan McGee <dan@archlinux.org> | 2011-06-14 18:16:00 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-06-14 18:17:22 -0500 |
commit | f465a6afb71573bac0876dd8cc56aaae4d67035c (patch) | |
tree | 682be8841f7d776c5d582fd52a98dac0c5eb46b4 /main/models.py | |
parent | 2fd78dfa0019d1b1d25f89a7729b5ebb0f341a93 (diff) |
Mark several package columns as non-NULL
These have been around for a long time now so they don't need to be
NULL-able anymore. We can also add a custom field type for our numbers
to at least get a check constraint at the Django level.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'main/models.py')
-rw-r--r-- | main/models.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/main/models.py b/main/models.py index 926e7377..57e9650e 100644 --- a/main/models.py +++ b/main/models.py @@ -11,6 +11,17 @@ from datetime import datetime from itertools import groupby import pytz +class PositiveBigIntegerField(models.BigIntegerField): + _south_introspects = True + + def get_internal_type(self): + return "PositiveBigIntegerField" + + def formfield(self, **kwargs): + defaults = {'min_value': 0} + defaults.update(kwargs) + return super(PositiveBigIntegerField, self).formfield(**defaults) + def validate_pgp_key_length(value): if len(value) not in (8, 16, 40): raise ValidationError( @@ -131,11 +142,10 @@ class Package(models.Model): pkgdesc = models.CharField(max_length=255, null=True) url = models.CharField(max_length=255, null=True) filename = models.CharField(max_length=255) - # TODO: it would be nice to have the >0 check constraint back here - compressed_size = models.BigIntegerField(null=True) - installed_size = models.BigIntegerField(null=True) + compressed_size = PositiveBigIntegerField() + installed_size = PositiveBigIntegerField() build_date = models.DateTimeField(null=True) - last_update = models.DateTimeField(null=True, blank=True) + last_update = models.DateTimeField() files_last_update = models.DateTimeField(null=True, blank=True) packager_str = models.CharField(max_length=255) packager = models.ForeignKey(User, null=True, |