From 219352ff42cb326c818525f19c9055539890deb8 Mon Sep 17 00:00:00 2001 From: Sanj Date: Tue, 1 Nov 2011 01:38:22 +0000 Subject: [PATCH] front page image slider admin --- itf/bestpractices/models.py | 5 +++-- itf/frontpage/admin.py | 6 +++++- itf/frontpage/models.py | 7 +++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/itf/bestpractices/models.py b/itf/bestpractices/models.py index cff4dab..c335c6b 100755 --- a/itf/bestpractices/models.py +++ b/itf/bestpractices/models.py @@ -53,12 +53,13 @@ class BestPractice(ItfModel): } def main_image(self): + if self.display_image: + return self.display_image imgs = self.get_images() if len(imgs) > 0: img = imgs[0] return img.image - else: - return None + return None def list_dict(self): return { diff --git a/itf/frontpage/admin.py b/itf/frontpage/admin.py index 07f1210..46951d8 100755 --- a/itf/frontpage/admin.py +++ b/itf/frontpage/admin.py @@ -16,6 +16,10 @@ class MenuHeadingAdmin(admin.ModelAdmin): list_display = ('name', 'order',) list_editable = ['order'] + +class FrontImageAdmin(admin.ModelAdmin): + pass + admin.site.register(MenuHeading, MenuHeadingAdmin) admin.site.register(SliderBox, SliderBoxAdmin) - +admin.site.register(FrontImage, FrontImageAdmin) diff --git a/itf/frontpage/models.py b/itf/frontpage/models.py index 28287c1..adeca12 100755 --- a/itf/frontpage/models.py +++ b/itf/frontpage/models.py @@ -1,5 +1,12 @@ from django.db import models +class FrontImage(models.Model): + image = models.ImageField(upload_to='upload/frontImages/') + caption = models.TextField(blank=True) + + def __unicode__(self): + return self.image.url + class SliderBox(models.Model): title = models.CharField(max_length=64) image = models.ImageField(upload_to='upload/sliderImages/')