diff options
Diffstat (limited to 'releng')
-rw-r--r-- | releng/admin.py | 1 | ||||
-rw-r--r-- | releng/migrations/0002_release_last_modified.py | 22 | ||||
-rw-r--r-- | releng/migrations/0003_release_populate_last_modified.py | 21 | ||||
-rw-r--r-- | releng/models.py | 1 | ||||
-rw-r--r-- | releng/views.py | 5 |
5 files changed, 46 insertions, 4 deletions
diff --git a/releng/admin.py b/releng/admin.py index c7e6396e..9c93c4be 100644 --- a/releng/admin.py +++ b/releng/admin.py @@ -18,6 +18,7 @@ class ReleaseAdmin(admin.ModelAdmin): list_display = ('version', 'release_date', 'kernel_version', 'available', 'created') list_filter = ('available', 'release_date') + readonly_fields = ('created', 'last_modified') SIMPLE_MODELS = (Architecture, BootType, Bootloader, ClockChoice, Filesystem, diff --git a/releng/migrations/0002_release_last_modified.py b/releng/migrations/0002_release_last_modified.py new file mode 100644 index 00000000..58502452 --- /dev/null +++ b/releng/migrations/0002_release_last_modified.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import datetime +from django.utils.timezone import utc + + +class Migration(migrations.Migration): + + dependencies = [ + ('releng', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='release', + name='last_modified', + field=models.DateTimeField(default=datetime.datetime(2001, 1, 1, tzinfo=utc), editable=False), + preserve_default=False, + ), + ] diff --git a/releng/migrations/0003_release_populate_last_modified.py b/releng/migrations/0003_release_populate_last_modified.py new file mode 100644 index 00000000..ec7b6fda --- /dev/null +++ b/releng/migrations/0003_release_populate_last_modified.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + +def forwards(apps, schema_editor): + Release = apps.get_model('releng', 'Release') + Release.objects.update(last_modified=models.F('created')) + +def backwards(apps, schema_editor): + pass + +class Migration(migrations.Migration): + + dependencies = [ + ('releng', '0002_release_last_modified'), + ] + + operations = [ + migrations.RunPython(forwards, backwards) + ] diff --git a/releng/models.py b/releng/models.py index 66690e81..2f9216bd 100644 --- a/releng/models.py +++ b/releng/models.py @@ -120,6 +120,7 @@ class Release(models.Model): md5_sum = models.CharField('MD5 digest', max_length=32, blank=True) sha1_sum = models.CharField('SHA1 digest', max_length=40, blank=True) created = models.DateTimeField(editable=False) + last_modified = models.DateTimeField(editable=False) available = models.BooleanField(default=True) info = models.TextField('Public information', blank=True) torrent_data = models.TextField(blank=True, diff --git a/releng/views.py b/releng/views.py index af25b966..0fb55b29 100644 --- a/releng/views.py +++ b/releng/views.py @@ -247,9 +247,6 @@ class ReleaseJSONEncoder(DjangoJSONEncoder): 'created', 'md5_sum', 'sha1_sum') def default(self, obj): - if hasattr(obj, '__iter__'): - # mainly for queryset serialization - return list(obj) if isinstance(obj, Release): data = {attr: getattr(obj, attr) or None for attr in self.release_attributes} @@ -276,7 +273,7 @@ def releases_json(request): data = { 'version': 1, - 'releases': releases, + 'releases': list(releases), 'latest_version': latest_version, } to_json = json.dumps(data, ensure_ascii=False, cls=ReleaseJSONEncoder) |