changeset 24:0bac5dfbcc7c

Merged Brian's changes with mine.
author Bob Mourlam <bob.mourlam@gmail.com>
date Mon, 31 Oct 2011 22:10:06 -0500
parents 1357c69e887d (diff) 7fce0720f89b (current diff)
children 72bfeac8f4f3 353ca3874f43
files
diffstat 3 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/bns_website/news/admin.py	Mon Oct 31 20:47:29 2011 -0500
+++ b/bns_website/news/admin.py	Mon Oct 31 22:10:06 2011 -0500
@@ -5,4 +5,8 @@
 from django.contrib import admin
 from news.models import News
 
-admin.site.register(News)
+class NewsAdmin(admin.ModelAdmin):
+    list_filter = ['date']
+    search_fields = ['title', 'content']
+
+admin.site.register(News, NewsAdmin)
--- a/bns_website/news/models.py	Mon Oct 31 20:47:29 2011 -0500
+++ b/bns_website/news/models.py	Mon Oct 31 22:10:06 2011 -0500
@@ -1,4 +1,5 @@
 from django.db import models
+from datetime import timedelta, datetime
 
 # Create your models here.
 class News(models.Model):
@@ -13,9 +14,16 @@
     # User field?
 
 
+    def is_new(self):
+        if datetime.now() - self.date <= timedelta(days=3):
+            return True
+
+        return False
+
 
     class Meta:
         verbose_name_plural="News"
+        ordering = ['-date']
 
     def __unicode__(self):
         return self.title
--- a/bns_website/templates/news/news_list.html	Mon Oct 31 20:47:29 2011 -0500
+++ b/bns_website/templates/news/news_list.html	Mon Oct 31 22:10:06 2011 -0500
@@ -20,12 +20,14 @@
 <h1>News</h1>
 <dl>
 {% for news in object_list %}
-<dt>{{ news.title }}</a></dt>
+<div class="alert-message block-message info">
+<dt><h2>{{ news.title }} {% if news.is_new %}<span class="label success">New</span>{% endif %}</h2>
+</dt>
 <dd>{{ news.content|linebreaksbr }}</dd>
+<p align="right">   <span class="label">{{news.date}}</span></p>
+</div>
 <p/>
 {% endfor %}
 </dl>
 
-</div>
-
 {% endblock %}