From 6062d4782ff8006a93bf6b5ea01cc31acf921276 Mon Sep 17 00:00:00 2001 From: sanj Date: Thu, 11 Nov 2010 05:46:21 +0530 Subject: [PATCH] ups, forgot to add app --- padmaTexts/texts/admin.py | 14 ++++++++++++++ padmaTexts/texts/models.py | 16 ++++++++++++++++ padmaTexts/texts/views.py | 8 ++++++++ 3 files changed, 38 insertions(+) create mode 100644 padmaTexts/texts/admin.py create mode 100644 padmaTexts/texts/models.py create mode 100644 padmaTexts/texts/views.py diff --git a/padmaTexts/texts/admin.py b/padmaTexts/texts/admin.py new file mode 100644 index 0000000..e794bb2 --- /dev/null +++ b/padmaTexts/texts/admin.py @@ -0,0 +1,14 @@ +from models import PadmaText +from django.contrib import admin +from django import forms +from django.db import models + +class PadmaTextAdmin(admin.ModelAdmin): + formfield_overrides = { models.TextField: {'widget': forms.Textarea(attrs={'class':'ckeditor'})}, } + prepopulated_fields = {'slug': ('title',)} + + + class Media: + js = ('ckeditor/ckeditor.js',) # The , at the end of this list IS important. + +admin.site.register(PadmaText,PadmaTextAdmin) diff --git a/padmaTexts/texts/models.py b/padmaTexts/texts/models.py new file mode 100644 index 0000000..d0f8fd3 --- /dev/null +++ b/padmaTexts/texts/models.py @@ -0,0 +1,16 @@ +from django.db import models + +class PadmaText(models.Model): + slug = models.SlugField() + title = models.CharField(max_length=512) + author = models.CharField(max_length=512, blank=True) + author_bio = models.TextField(blank=True) + abstract = models.TextField(blank=True) + html = models.TextField() + + def __unicode__(self): + return self.title + + def get_absolute_url(self): + return self.slug + diff --git a/padmaTexts/texts/views.py b/padmaTexts/texts/views.py new file mode 100644 index 0000000..ff160b0 --- /dev/null +++ b/padmaTexts/texts/views.py @@ -0,0 +1,8 @@ +# Create your views here. +from models import PadmaText +from django.http import HttpResponse +from django.shortcuts import get_object_or_404, render_to_response + +def text(request, slug): + text = get_object_or_404(PadmaText, slug=slug) + return render_to_response("text_embed.html", {'text': text})