# HG changeset patch # User Brian Neal # Date 1309902056 0 # Node ID 53fdaf0da53903ef2571358de2edf84f4eea0828 # Parent 2d96d9bcf0defb2bdc4f907b96996d9fff89542d Adding a priority field to news stories for front page display purposes. This fixes #223. diff -r 2d96d9bcf0de -r 53fdaf0da539 gpp/news/admin.py --- 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() diff -r 2d96d9bcf0de -r 53fdaf0da539 gpp/news/models.py --- 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 diff -r 2d96d9bcf0de -r 53fdaf0da539 gpp/news/templatetags/news_tags.py --- 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)