Forgot to add textbook directory

This commit is contained in:
Piotr Mitros
2011-12-25 12:52:19 -05:00
parent e76083e7e9
commit b973f3583a
4 changed files with 37 additions and 0 deletions

0
textbook/__init__.py Normal file
View File

3
textbook/models.py Normal file
View File

@@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

16
textbook/tests.py Normal file
View File

@@ -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)

18
textbook/views.py Normal file
View File

@@ -0,0 +1,18 @@
from djangomako.shortcuts import render_to_response, render_to_string
from django.shortcuts import redirect
import os
from django.conf import settings
from django.http import Http404
# We don't do subdirectories to reduce odds of possible future
# security issues. Feel free to re-add them if needed -- just make
# sure things like /../../etc/passwd are handled okay.
valid_files=os.listdir(settings.TEXTBOOK_DIR)
def index(request, filename):
if filename in valid_files:
text=open(settings.TEXTBOOK_DIR+filename).read()
return render_to_response('textbook.html',{'text':text})
else:
raise Http404