Mercurial > public > bravenewsurf
changeset 3:71f2941161e9
Created a generic view (for now) to display a home page.
Wrote a test for the home page. Created a test settings file that uses sqlite.
Created simple 404, 500, base, and home page templates.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Fri, 28 Oct 2011 20:32:29 -0500 |
parents | 920ba6593732 |
children | 2698ff124e87 |
files | bns_website/core/__init__.py bns_website/core/models.py bns_website/core/tests/__init__.py bns_website/core/tests/view_tests.py bns_website/core/views.py bns_website/settings/base.py bns_website/settings/test.py bns_website/templates/404.html bns_website/templates/500.html bns_website/templates/base.html bns_website/templates/home.html bns_website/urls.py |
diffstat | 11 files changed, 108 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bns_website/core/models.py Fri Oct 28 20:32:29 2011 -0500 @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bns_website/core/tests/__init__.py Fri Oct 28 20:32:29 2011 -0500 @@ -0,0 +1,1 @@ +from view_tests import *
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bns_website/core/tests/view_tests.py Fri Oct 28 20:32:29 2011 -0500 @@ -0,0 +1,18 @@ +""" +Core (non-application specific) view tests. + +""" +from django.test import TestCase +from django.core.urlresolvers import reverse + + +class ViewTest(TestCase): + + def test_home(self): + """ + Tests the home page to ensure it displays without errors. + + """ + response = self.client.get(reverse('home')) + self.assertEqual(response.status_code, 200) + self.assertTemplateUsed(response, 'home.html')
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bns_website/core/views.py Fri Oct 28 20:32:29 2011 -0500 @@ -0,0 +1,1 @@ +# Create your views here.
--- a/bns_website/settings/base.py Thu Oct 27 20:57:52 2011 -0500 +++ b/bns_website/settings/base.py Fri Oct 28 20:32:29 2011 -0500 @@ -133,6 +133,7 @@ 'django.contrib.staticfiles', 'django.contrib.admin', 'django.contrib.admindocs', + 'core', ] # A sample logging configuration. The only tangible logging
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bns_website/settings/test.py Fri Oct 28 20:32:29 2011 -0500 @@ -0,0 +1,15 @@ +""" +Settings to use when running tests. Uses sqlite for speed. +This idea was taken from +http://blog.davidziegler.net/post/370368042/test-database-settings-in-django + +""" +from settings.base import * +from settings.local import * + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': 'test.db', + }, +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bns_website/templates/404.html Fri Oct 28 20:32:29 2011 -0500 @@ -0,0 +1,13 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <title>Page Not Found</title> +</head> +<body> + + <h1>Not Found</h1> + + <p>The requested URL {{ request.path|escape }} was not found on this server.</p> + +</body> +</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bns_website/templates/500.html Fri Oct 28 20:32:29 2011 -0500 @@ -0,0 +1,14 @@ +<!DOCTYPE html> +<html lang="en"> +<head> + <title>Internal Server Error</title> +</head> +<body> + + <h1>Whoops! Internal Server Error</h1> + + <p>We're sorry, the page you requested is currently unavailable due to a server misconfiguration.</p> + <p>The server administrator has been notified, and we apologize for any inconvenience.</p> + +</body> +</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bns_website/templates/base.html Fri Oct 28 20:32:29 2011 -0500 @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<html lang="en"> +<head> +<title>Brave New Surf | {% block title %}{% endblock %}</title> +<meta charset="utf-8" /> +{% block custom_meta %}{% endblock %} +<link rel="shortcut icon" href="{{ STATIC_URL }}images/favicon.ico"> +<link rel="stylesheet" href="http://twitter.github.com/bootstrap/1.3.0/bootstrap.min.css"> +<link rel="stylesheet" href="{{ STATIC_URL }}css/base.css"> +{% block custom_css %}{% endblock %} +{% block custom_js %}{% endblock %} +</head> +<body>{% block begin_body %}{% endblock %} + +<div class="container"> + {% block content %}{% endblock %} +</div> + +<footer class="footer"> +<div class="container"> + <p class="pull-right"><a href="#">Back to top</a></p> + <p>Brave New Surf © 2011 Double Crown Records</p> + <p>Other footer type stuff goes down here.</p> +</div> +</footer> + +{% block end_body %}{% endblock %} +</body> +</html>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bns_website/templates/home.html Fri Oct 28 20:32:29 2011 -0500 @@ -0,0 +1,5 @@ +{% extends 'base.html' %} +{% block title %}Home{% endblock %} +{% block content %} +<h1>Welcome to The Brave New Surf!</h1> +{% endblock %}
--- a/bns_website/urls.py Thu Oct 27 20:57:52 2011 -0500 +++ b/bns_website/urls.py Fri Oct 28 20:32:29 2011 -0500 @@ -1,17 +1,19 @@ from django.conf.urls.defaults import patterns, include, url +#from django.contrib import admin +from django.views.generic.base import TemplateView -# Uncomment the next two lines to enable the admin: -# from django.contrib import admin -# admin.autodiscover() + +#admin.autodiscover() urlpatterns = patterns('', + url(r'^$', + TemplateView.as_view(template_name="home.html"), + name="home"), + # Examples: # url(r'^$', 'bns_website.views.home', name='home'), # url(r'^bns_website/', include('bns_website.foo.urls')), - # Uncomment the admin/doc line below to enable admin documentation: # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), - - # Uncomment the next line to enable the admin: # url(r'^admin/', include(admin.site.urls)), )