Mercurial > public > sg101
changeset 462:53fdaf0da539
Adding a priority field to news stories for front page display purposes. This fixes #223.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 05 Jul 2011 21:40:56 +0000 |
parents | 2d96d9bcf0de |
children | 452835f4429f |
files | gpp/news/admin.py gpp/news/models.py gpp/news/templatetags/news_tags.py |
diffstat | 3 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/gpp/news/admin.py Tue Jul 05 19:24:18 2011 +0000 +++ b/gpp/news/admin.py Tue Jul 05 21:40:56 2011 +0000 @@ -36,7 +36,8 @@ date_submitted=pending_story.date_submitted, allow_comments=pending_story.allow_comments, tags=pending_story.tags, - front_page_expiration=pending_story.front_page_expiration) + front_page_expiration=pending_story.front_page_expiration, + priority=pending_story.priority) story.save() pending_story.delete()
--- a/gpp/news/models.py Tue Jul 05 19:24:18 2011 +0000 +++ b/gpp/news/models.py Tue Jul 05 21:40:56 2011 +0000 @@ -37,6 +37,7 @@ tags = TagField() front_page_expiration = models.DateField(null=True, blank=True) update_date = models.DateTimeField(db_index=True, blank=True) + priority = models.IntegerField(db_index=True, default=0, blank=True) class Meta: abstract = True
--- a/gpp/news/templatetags/news_tags.py Tue Jul 05 19:24:18 2011 +0000 +++ b/gpp/news/templatetags/news_tags.py Tue Jul 05 21:40:56 2011 +0000 @@ -18,7 +18,8 @@ # Defer the tags field because we are going to get all the # tags out in 1 query later... stories = Story.objects.defer('tags').exclude( - front_page_expiration__lt=datetime.date.today())[:10] + front_page_expiration__lt=datetime.date.today()).order_by( + '-priority', '-date_submitted')[:10] attach_extra_attrs(stories)