Mercurial > public > bravenewsurf
changeset 18:abe08d74dab3
I merged Chris' Reviews branch with mine.
author | Bob Mourlam <bob.mourlam@gmail.com> |
---|---|
date | Mon, 31 Oct 2011 20:38:43 -0500 |
parents | 5348d2235497 (current diff) 71f2beb03789 (diff) |
children | 7fce0720f89b 687af3cb0525 |
files | |
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 Mon Oct 31 20:38:43 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 Mon Oct 31 20:38:43 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 Mon Oct 31 20:38:43 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 Mon Oct 31 20:38:43 2011 -0500 @@ -0,0 +1,1 @@ +# Create your views here.
--- a/bns_website/settings/base.py Mon Oct 31 20:30:37 2011 -0500 +++ b/bns_website/settings/base.py Mon Oct 31 20:38:43 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 Mon Oct 31 20:30:37 2011 -0500 +++ b/bns_website/templates/core/navbar_tag.html Mon Oct 31 20:38:43 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 Mon Oct 31 20:30:37 2011 -0500 +++ b/bns_website/templates/home.html Mon Oct 31 20:38:43 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 »</a></p> + <p><br /><a class="btn default" href="{% url 'news' %}">All News »</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 »</a></p> + <p><br /><a class="btn default" href="{% url 'reviews' %}">All Reviews »</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 Mon Oct 31 20:38:43 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 Mon Oct 31 20:30:37 2011 -0500 +++ b/bns_website/urls.py Mon Oct 31 20:38:43 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"),