# HG changeset patch # User Brian Neal # Date 1319851949 18000 # Node ID 71f2941161e9ec560ffd1bd0423385c7abc00e33 # Parent 920ba6593732b38893aa93133cbd8ec673be8a8d 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. diff -r 920ba6593732 -r 71f2941161e9 bns_website/core/models.py --- /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. diff -r 920ba6593732 -r 71f2941161e9 bns_website/core/tests/__init__.py --- /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 * diff -r 920ba6593732 -r 71f2941161e9 bns_website/core/tests/view_tests.py --- /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') diff -r 920ba6593732 -r 71f2941161e9 bns_website/core/views.py --- /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. diff -r 920ba6593732 -r 71f2941161e9 bns_website/settings/base.py --- 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 diff -r 920ba6593732 -r 71f2941161e9 bns_website/settings/test.py --- /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', + }, +} diff -r 920ba6593732 -r 71f2941161e9 bns_website/templates/404.html --- /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 @@ + + + + Page Not Found + + + +

Not Found

+ +

The requested URL {{ request.path|escape }} was not found on this server.

+ + + diff -r 920ba6593732 -r 71f2941161e9 bns_website/templates/500.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 @@ + + + + Internal Server Error + + + +

Whoops! Internal Server Error

+ +

We're sorry, the page you requested is currently unavailable due to a server misconfiguration.

+

The server administrator has been notified, and we apologize for any inconvenience.

+ + + diff -r 920ba6593732 -r 71f2941161e9 bns_website/templates/base.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 @@ + + + +Brave New Surf | {% block title %}{% endblock %} + +{% block custom_meta %}{% endblock %} + + + +{% block custom_css %}{% endblock %} +{% block custom_js %}{% endblock %} + +{% block begin_body %}{% endblock %} + +
+ {% block content %}{% endblock %} +
+ + + +{% block end_body %}{% endblock %} + + diff -r 920ba6593732 -r 71f2941161e9 bns_website/templates/home.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 %} +

Welcome to The Brave New Surf!

+{% endblock %} diff -r 920ba6593732 -r 71f2941161e9 bns_website/urls.py --- 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)), )