# HG changeset patch # User Chris Ridgway # Date 1320555190 18000 # Node ID 37d9b6b1a097fa081bf6e40c57e6f355e527201b # Parent b5329e6ad8288c99a161e1176fa3c418b74acf8b Added reviews template tag. Fix ordering of reviews. Tweaked the display of the reviews page. Addresses ticket 2. diff -r b5329e6ad828 -r 37d9b6b1a097 bns_website/reviews/admin.py --- a/bns_website/reviews/admin.py Sat Nov 05 13:00:47 2011 -0500 +++ b/bns_website/reviews/admin.py Sat Nov 05 23:53:10 2011 -0500 @@ -8,7 +8,10 @@ class ReviewAdmin(admin.ModelAdmin): + list_filter = ['date'] + search_fields = ['title', 'review', 'reviewer', 'review_site'] list_display = ['date', 'reviewer', 'review_site', 'title'] + ordering = ['-date'] class Media: js = settings.THIRD_PARTY_JS['tiny_mce'] diff -r b5329e6ad828 -r 37d9b6b1a097 bns_website/reviews/models.py --- a/bns_website/reviews/models.py Sat Nov 05 13:00:47 2011 -0500 +++ b/bns_website/reviews/models.py Sat Nov 05 23:53:10 2011 -0500 @@ -9,7 +9,7 @@ """ This model represents all the info we store about each review. """ - date = models.DateField(auto_now_add=True) + date = models.DateTimeField(auto_now_add=True) title = models.CharField(max_length=200) reviewer = models.CharField(max_length=200) review_site = models.CharField(max_length=200, blank=True) diff -r b5329e6ad828 -r 37d9b6b1a097 bns_website/reviews/templatetags/reviews_tags.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bns_website/reviews/templatetags/reviews_tags.py Sat Nov 05 23:53:10 2011 -0500 @@ -0,0 +1,11 @@ +from django import template +from reviews.models import Review + +register = template.Library() + +""" +Display a list of the last num_to_display reviews. +""" +@register.inclusion_tag('reviews/reviews_tag.html') +def list_reviews(num_to_display): + return {'object_list': Review.objects.all()[:num_to_display]} \ No newline at end of file diff -r b5329e6ad828 -r 37d9b6b1a097 bns_website/reviews/tests.py --- a/bns_website/reviews/tests.py Sat Nov 05 13:00:47 2011 -0500 +++ b/bns_website/reviews/tests.py Sat Nov 05 23:53:10 2011 -0500 @@ -1,16 +1,18 @@ """ -This file demonstrates writing tests using the unittest module. These will pass -when you run "manage.py test". +Reviews application view tests. -Replace this with more appropriate tests for your application. """ +from django.test import TestCase +from django.core.urlresolvers import reverse -from django.test import TestCase +class ViewTest(TestCase): -class SimpleTest(TestCase): - def test_basic_addition(self): + def test_home(self): """ - Tests that 1 + 1 always equals 2. + Tests the home page to ensure it displays without errors. + """ - self.assertEqual(1 + 1, 2) + response = self.client.get(reverse('reviews')) + self.assertEqual(response.status_code, 200) + self.assertTemplateUsed(response, 'reviews/review_list.html') diff -r b5329e6ad828 -r 37d9b6b1a097 bns_website/templates/home.html --- a/bns_website/templates/home.html Sat Nov 05 13:00:47 2011 -0500 +++ b/bns_website/templates/home.html Sat Nov 05 23:53:10 2011 -0500 @@ -1,6 +1,6 @@ {% extends 'base.html' %} {% load url from future %} -{% load core_tags %} +{% load core_tags reviews_tags %} {% block title %}Home{% endblock %} {% block custom_meta %} @@ -71,7 +71,7 @@

The songs on this CD testify to a love affair between the musicians and their music. Surf musicians are not in this for the money – almost all have to keep their day jobs – but, rather, because of a deep passion for the music. For them, life is much more satisfying if some part of it is spent playing in a surf band. This passion is shared by an increasingly international community, reaching almost every corner of the world. The bands on this compilation come not only from North America, but also South America and Europe, these two continents emerging in the past decade as real hotbeds of surf music activity.

- Surf bands universally start off by playing the 1960s classics. As a result, the surf genre is steeped in the tradition. But while some stay largely within the boundaries of that tradition, others more fully explore the possibilities 
only hinted at by the first wave bands, and still others move beyond the boundaries, in some cases obliterating them, pushing surf music into new directions. + Surf bands universally start off by playing the 1960s classics. As a result, the surf genre is steeped in the tradition. But while some stay largely within the boundaries of that tradition, others more fully explore the possibilities
only hinted at by the first wave bands, and still others move beyond the boundaries, in some cases obliterating them, pushing surf music into new directions.

No matter what their approach, for every one of the bands here the 1960s foundations provide a springboard to a fresh and individual approach to surf music. Remarkably, while relying on the same basic set of instruments and tonal recipes, each of the bands has its own signature sound, as unique to it as a fingerprint to a person. It’s clear that the full possibilities of surf music for musical creativity (not to mention FUN!) are really only starting to be explored.

@@ -95,13 +95,7 @@

Reviews

-

This box shows links to the 5 most recent reviews.

- + {% list_reviews 5 %}


All Reviews »

diff -r b5329e6ad828 -r 37d9b6b1a097 bns_website/templates/reviews/review_list.html --- a/bns_website/templates/reviews/review_list.html Sat Nov 05 13:00:47 2011 -0500 +++ b/bns_website/templates/reviews/review_list.html Sat Nov 05 23:53:10 2011 -0500 @@ -15,15 +15,25 @@

Reviews

- - +{% if object_list %} + +{% else %} + Coming soon... +{% endif %} {% endblock %} diff -r b5329e6ad828 -r 37d9b6b1a097 bns_website/templates/reviews/reviews_tag.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bns_website/templates/reviews/reviews_tag.html Sat Nov 05 23:53:10 2011 -0500 @@ -0,0 +1,10 @@ +{% load url from future %} +{% if object_list %} +
    + {% for review in object_list %} +
  • {{ review.title }}
  • + {% endfor %} +
+{% else %} + Coming soon... +{% endif %} \ No newline at end of file