changeset 218:6dbb8faef085

Implement #86, add a front page expiration date to news stories.
author Brian Neal <bgneal@gmail.com>
date Tue, 01 Jun 2010 05:16:40 +0000
parents 237710206167
children 26ee684c2033
files gpp/news/admin.py gpp/news/forms.py gpp/news/models.py gpp/news/templatetags/news_tags.py
diffstat 4 files changed, 8 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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()
 
--- 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']
--- 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
--- 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'],