From 223d9d61798e344e4dc92dbd9e52b1211d8e123c Mon Sep 17 00:00:00 2001 From: sanj Date: Tue, 7 Dec 2010 15:51:24 +0100 Subject: [PATCH] fields for best practices --- itf/bestpractices/admin.py | 18 +++++++++++++++++- itf/bestpractices/models.py | 28 +++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/itf/bestpractices/admin.py b/itf/bestpractices/admin.py index 78eed6f..70c6104 100644 --- a/itf/bestpractices/admin.py +++ b/itf/bestpractices/admin.py @@ -1,4 +1,20 @@ from django.contrib import admin from models import * -admin.site.register(BestPractice) +class ImageInline(admin.StackedInline): + model = BestPracticeImage + extra = 2 + +class LinkInline(admin.StackedInline): + model = BestPracticeLink + extra = 3 + +class BestPracticeAdmin(admin.ModelAdmin): + inlines = [ImageInline, LinkInline] + list_filter = ['category'] + + +admin.site.register(BestPractice, BestPracticeAdmin) +admin.site.register(BestPracticeCategory) +admin.site.register(BestPracticeImage) +admin.site.register(BestPracticeLink) diff --git a/itf/bestpractices/models.py b/itf/bestpractices/models.py index 56aeeaa..1d628da 100644 --- a/itf/bestpractices/models.py +++ b/itf/bestpractices/models.py @@ -7,7 +7,33 @@ class BestPractice(models.Model): guideline = models.TextField(blank=True) law = models.TextField(blank=True) theatre = models.TextField(blank=True, help_text="Spotlight on Theatre text") + quick_howto = models.TextField(blank=True) tags = TagField(blank=True, help_text="Enter as many tags as you like, separated by commas.") - + category = models.ForeignKey("BestPracticeCategory") + def __unicode__(self): return self.title + +class BestPracticeCategory(models.Model): + name = models.CharField(max_length=256) + description = models.TextField(blank=True) + + def __unicode__(self): + return self.name + +class BestPracticeLink(models.Model): + url = models.URLField() + text = models.TextField(blank=True) + bestpractice = models.ForeignKey(BestPractice) + + def __unicode__(self): + return self.url + +class BestPracticeImage(models.Model): + image = models.ImageField(upload_to='upload/images/bestpractices/') + caption = models.CharField(max_length=512, blank=True) + bestpractice = models.ForeignKey(BestPractice) + + def __unicode__(self): + return self.caption +