# HG changeset patch # User Bob Mourlam # Date 1320117006 18000 # Node ID 0bac5dfbcc7c13819060e632656344db3f0d0e8a # Parent 1357c69e887d88498d0911330ee8404fc0012198# Parent 7fce0720f89bc01a75739baf9161196cf26eb844 Merged Brian's changes with mine. diff -r 7fce0720f89b -r 0bac5dfbcc7c bns_website/news/admin.py --- 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) diff -r 7fce0720f89b -r 0bac5dfbcc7c bns_website/news/models.py --- 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 diff -r 7fce0720f89b -r 0bac5dfbcc7c bns_website/templates/news/news_list.html --- 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 @@

News

{% for news in object_list %} -
{{ news.title }}
+
+

{{ news.title }} {% if news.is_new %}New{% endif %}

+
{{ news.content|linebreaksbr }}
+

{{news.date}}

+

{% endfor %}

- - {% endblock %}