# HG changeset patch # User Brian Neal # Date 1275369400 0 # Node ID 6dbb8faef085e8e30874a78400827233a4ad3093 # Parent 2377102061672ea3f75307efd8e6de22537e7e05 Implement #86, add a front page expiration date to news stories. diff -r 237710206167 -r 6dbb8faef085 gpp/news/admin.py --- a/gpp/news/admin.py Tue Jun 01 04:49:29 2010 +0000 +++ b/gpp/news/admin.py Tue Jun 01 05:16:40 2010 +0000 @@ -27,7 +27,8 @@ long_text=pending_story.long_text, date_submitted=datetime.datetime.now(), allow_comments=pending_story.allow_comments, - tags=pending_story.tags) + tags=pending_story.tags, + front_page_expiration=pending_story.front_page_expiration) story.save() pending_story.delete() diff -r 237710206167 -r 6dbb8faef085 gpp/news/forms.py --- a/gpp/news/forms.py Tue Jun 01 04:49:29 2010 +0000 +++ b/gpp/news/forms.py Tue Jun 01 05:16:40 2010 +0000 @@ -17,7 +17,7 @@ class Meta: model = PendingStory - exclude = ('submitter', 'date_submitted', 'allow_comments', 'approved', 'tags') + fields = ('title', 'category', 'short_text', 'long_text') class Media: js = settings.GPP_THIRD_PARTY_JS['tiny_mce'] diff -r 237710206167 -r 6dbb8faef085 gpp/news/models.py --- a/gpp/news/models.py Tue Jun 01 04:49:29 2010 +0000 +++ b/gpp/news/models.py Tue Jun 01 05:16:40 2010 +0000 @@ -34,6 +34,7 @@ date_submitted = models.DateTimeField(db_index=True) allow_comments = models.BooleanField(default=True) tags = TagField() + front_page_expiration = models.DateField(null=True, blank=True) class Meta: abstract = True diff -r 237710206167 -r 6dbb8faef085 gpp/news/templatetags/news_tags.py --- a/gpp/news/templatetags/news_tags.py Tue Jun 01 04:49:29 2010 +0000 +++ b/gpp/news/templatetags/news_tags.py Tue Jun 01 05:16:40 2010 +0000 @@ -1,6 +1,8 @@ """ Template tags for the news application. """ +import datetime + from django import template from news.models import Story @@ -11,7 +13,8 @@ @register.inclusion_tag('news/current_news.html', takes_context=True) def current_news(context): - stories = Story.objects.all()[:10] + stories = Story.objects.exclude( + front_page_expiration__lt=datetime.date.today())[:10] return { 'stories': stories, 'MEDIA_URL': context['MEDIA_URL'],