Mercurial > public > madeira
changeset 9:dac690ab98b2
Display video sets on index page by date in descending order. Allow the video set date to be edited.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 13 Dec 2009 21:47:08 +0000 |
parents | 3e22a6fde2d2 |
children | 10a8afa02eb2 |
files | mysite/band/models.py mysite/band/views.py |
diffstat | 2 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mysite/band/models.py Tue Jun 02 00:47:37 2009 +0000 +++ b/mysite/band/models.py Sun Dec 13 21:47:08 2009 +0000 @@ -221,7 +221,7 @@ ####################################################################### class Video_Set(models.Model): - date = models.DateField(auto_now_add = True, editable = False) + date = models.DateField(blank=True) title = models.CharField(max_length = 64) text = models.TextField() @@ -232,6 +232,12 @@ ordering = ('date', ) verbose_name = "Video Set" + def save(self, *args, **kwargs): + if not self.id: + self.date = datetime.date.today() + + super(Video_Set, self).save(*args, **kwargs) + ####################################################################### class Video(models.Model):
--- a/mysite/band/views.py Tue Jun 02 00:47:37 2009 +0000 +++ b/mysite/band/views.py Sun Dec 13 21:47:08 2009 +0000 @@ -173,7 +173,7 @@ ####################################################################### def videos_index(request): - vidsets = Video_Set.objects.values('title', 'id').order_by('-id') + vidsets = Video_Set.objects.values('title', 'id').order_by('-date') return render_to_response('band/videos.html', { 'vidsets' : vidsets }, context_instance = RequestContext(request))