From 6b5fd58eca1fc2bb6529b62afbbc9b241cd947fb Mon Sep 17 00:00:00 2001 From: Sanj Date: Fri, 19 Oct 2012 14:57:52 +0530 Subject: [PATCH] noteworthy images --- urbstudio/urb/admin.py | 7 ++++++- urbstudio/urb/models.py | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/urbstudio/urb/admin.py b/urbstudio/urb/admin.py index 616bdcf..34080e7 100755 --- a/urbstudio/urb/admin.py +++ b/urbstudio/urb/admin.py @@ -7,6 +7,11 @@ class ProjectImageInline(admin.TabularInline): extra = 20 +class NoteworthyImageInline(admin.TabularInline): + model = NoteworthyImage + extra = 3 + + class ProjectAdmin(admin.ModelAdmin): class Media: js = ( @@ -28,7 +33,7 @@ class NoteworthyAdmin(admin.ModelAdmin): 'js/jquery-ui-1.8.16.custom.min.js', 'js/admin_list_reorder.js', ) - + inlines = [NoteworthyImageInline] list_display = ('__unicode__', 'position',) list_editable = ('position',) exclude = ('position',) diff --git a/urbstudio/urb/models.py b/urbstudio/urb/models.py index 2ac3a3e..66ecf78 100755 --- a/urbstudio/urb/models.py +++ b/urbstudio/urb/models.py @@ -96,7 +96,7 @@ class Link(models.Model): class Noteworthy(models.Model): position = models.IntegerField(null=True) - image = models.ImageField(blank=True, upload_to='noteworthy_imgs/') + image = models.ImageField(blank=True, upload_to='noteworthy_imgs/', help_text="main image") title = models.CharField(max_length=255) description = models.TextField(blank=True) url = models.URLField(blank=True) @@ -122,5 +122,19 @@ class Noteworthy(models.Model): def __unicode__(self): return self.title + +class NoteworthyImage(models.Model): + noteworthy = models.ForeignKey(Noteworthy) + image = models.ImageField(upload_to='noteworthy_imgs/') + order = models.IntegerField(default=1) + name = models.CharField(max_length=128, blank=True) + + def __unicode__(self): + return self.image.url + + class Meta: + ordering = ['order', 'id'] + + # Create your models here.