changeset 16:71f2beb03789

First stab at the review app.
author Chris Ridgway <ckridgway@gmail.com>
date Sun, 30 Oct 2011 23:07:05 -0500
parents 6b664ec90f2f
children abe08d74dab3 ef4155f8c234
files bns_website/reviews/__init__.py bns_website/reviews/admin.py bns_website/reviews/models.py bns_website/reviews/tests.py bns_website/reviews/views.py bns_website/settings/base.py bns_website/templates/core/navbar_tag.html bns_website/templates/home.html bns_website/templates/reviews/review_list.html bns_website/urls.py
diffstat 9 files changed, 86 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bns_website/reviews/admin.py	Sun Oct 30 23:07:05 2011 -0500
@@ -0,0 +1,12 @@
+"""
+Automatic admin definitions for the models in the reviews application.
+"""
+from django.contrib import admin
+from reviews.models import Review
+
+
+class ReviewAdmin(admin.ModelAdmin):
+    list_display = ['date', 'reviewer', 'review_site', 'title']
+
+
+admin.site.register(Review, ReviewAdmin)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bns_website/reviews/models.py	Sun Oct 30 23:07:05 2011 -0500
@@ -0,0 +1,23 @@
+"""
+Models for the reviews application.
+
+"""
+from django.db import models
+
+
+class Review(models.Model):
+    """
+    This model represents all the info we store about each review.
+    """
+    date = models.DateField(auto_now_add=True)
+    title = models.CharField(max_length=200, blank=True)
+    reviewer = models.CharField(max_length=200)
+    review_site = models.CharField(max_length=200, blank=True)
+    review_url = models.URLField(verify_exists=False, max_length=256, blank=True)
+    review = models.TextField()
+
+    class Meta:
+        verbose_name_plural = "Reviews"
+
+    def __unicode__(self):
+        return self.reviewer
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bns_website/reviews/tests.py	Sun Oct 30 23:07:05 2011 -0500
@@ -0,0 +1,16 @@
+"""
+This file demonstrates writing tests using the unittest module. These will pass
+when you run "manage.py test".
+
+Replace this with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+
+class SimpleTest(TestCase):
+    def test_basic_addition(self):
+        """
+        Tests that 1 + 1 always equals 2.
+        """
+        self.assertEqual(1 + 1, 2)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bns_website/reviews/views.py	Sun Oct 30 23:07:05 2011 -0500
@@ -0,0 +1,1 @@
+# Create your views here.
--- a/bns_website/settings/base.py	Sun Oct 30 21:37:52 2011 -0500
+++ b/bns_website/settings/base.py	Sun Oct 30 23:07:05 2011 -0500
@@ -136,6 +136,7 @@
     'core',
     'bands',
     'news',
+    'reviews',
 ]
 
 # A sample logging configuration. The only tangible logging
--- a/bns_website/templates/core/navbar_tag.html	Sun Oct 30 21:37:52 2011 -0500
+++ b/bns_website/templates/core/navbar_tag.html	Sun Oct 30 23:07:05 2011 -0500
@@ -6,7 +6,7 @@
 <ul class="nav">
 <li{% if active_tab == "home" %} class="active"{% endif %}><a href="{% url 'home' %}">Home</a></li>
 <li{% if active_tab == "news" %} class="active"{% endif %}><a href="{% url 'news' %}">News</a></li>
-<li{% if active_tab == "reviews" %} class="active"{% endif %}><a href="#">Reviews</a></li>
+<li{% if active_tab == "reviews" %} class="active"{% endif %}><a href="{% url 'reviews' %}">Reviews</a></li>
 <li{% if active_tab == "bands" %} class="active"{% endif %}><a href="{% url 'bands' %}">Bands</a></li>
 <li{% if active_tab == "music" %} class="active"{% endif %}><a href="{% url 'music' %}">Listen</a></li>
 <li{% if active_tab == "videos" %} class="active"{% endif %}><a href="{% url 'videos' %}">Watch</a></li>
--- a/bns_website/templates/home.html	Sun Oct 30 21:37:52 2011 -0500
+++ b/bns_website/templates/home.html	Sun Oct 30 23:07:05 2011 -0500
@@ -91,7 +91,7 @@
             <li><a href="#">Headline number 2 goes here.</a> - <small>Oct. 12, 2011</small></li>
             <li><a href="#">Headline number 1 goes here.</a> - <small>Oct. 2, 2011</small></li>
          </ul>
-         <p><br /><a class="btn default" href="#">All News &raquo;</a></p>
+         <p><br /><a class="btn default" href="{% url 'news' %}">All News &raquo;</a></p>
       </div>
       <div class="alert-message block-message info">
          <h3>Reviews</h3>
@@ -102,7 +102,7 @@
             <li><a href="#">Review number 2 goes here.</a> - <small>Oct. 12, 2011</small></li>
             <li><a href="#">Review number 1 goes here.</a> - <small>Oct. 2, 2011</small></li>
          </ul>
-         <p><br /><a class="btn default" href="#">All Reviews &raquo;</a></p>
+         <p><br /><a class="btn default" href="{% url 'reviews' %}">All Reviews &raquo;</a></p>
       </div>
       <div class="alert-message block-message info">
       <h3>Looking for more surf music?</h3>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bns_website/templates/reviews/review_list.html	Sun Oct 30 23:07:05 2011 -0500
@@ -0,0 +1,26 @@
+{% extends 'base.html' %}
+{% load core_tags %}
+{% block title %}Reviews{% endblock %}
+
+{% block custom_css %}
+<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/redmond/jquery-ui.css">
+{% endblock %}
+{% block custom_js %}
+<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
+<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
+{% endblock %}
+
+{% block content %}
+{% navbar 'reviews' %}
+<h1>Reviews</h1>
+
+<ul>
+{% for review in object_list %}
+	<li>
+		<cite>{{ review.review }}</cite>
+		<br/><br/>- {{ review.reviewer }} - <a href="{{ review.review_url }}">{{ review.review_url }}</a>
+	</li>
+{% endfor %}
+</ul>
+
+{% endblock %}
--- a/bns_website/urls.py	Sun Oct 30 21:37:52 2011 -0500
+++ b/bns_website/urls.py	Sun Oct 30 23:07:05 2011 -0500
@@ -5,6 +5,7 @@
 
 from bands.models import Band
 from news.models import News
+from reviews.models import Review
 
 admin.autodiscover()
 
@@ -12,6 +13,9 @@
     url(r'^$',
         TemplateView.as_view(template_name="home.html"),
         name="home"),
+    url(r'^reviews/$',
+        ListView.as_view(model=Review),
+        name="reviews"),
     url(r'^bands/$',
         ListView.as_view(model=Band),
         name="bands"),