Skip to content

Commit d643f9d

Browse files
committed
added .settings to .hgignore
1 parent b323a0b commit d643f9d

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

.hgignore

+1
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ src/*.egg-info
1313
.DS_Store
1414
.project
1515
.pydevproject
16+
.settings

image_filer/models/__init__.py

+27-2
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,17 @@ def thumbnails(self):
316316
self._thumbnails = tns
317317
return self._thumbnails
318318
def __unicode__(self):
319-
return self.label
319+
# this simulates the way a file field works and
320+
# allows the sorl thumbnail tag to use the Image model
321+
# as if it was a image field
322+
try:
323+
rel_url = u"%s" % self.file.url
324+
rel_url = rel_url.lstrip('/media/')
325+
print " image unicode returning %s" % rel_url
326+
return rel_url
327+
except:
328+
print "image unicode failed"
329+
return ""
320330

321331

322332
class FolderPermissionManager(models.Manager):
@@ -505,15 +515,27 @@ def children(self):
505515
parent_url = None
506516

507517
if 'cms' in settings.INSTALLED_APPS:
508-
from cms.models import CMSPlugin
518+
from cms.models import CMSPlugin, Page
509519
from sorl.thumbnail.main import DjangoThumbnail
510520
class ImagePublication(CMSPlugin):
521+
LEFT = "left"
522+
RIGHT = "right"
523+
FLOAT_CHOICES = ((LEFT, _("left")),
524+
(RIGHT, _("right")),
525+
)
511526
image = ImageFilerModelImageField()
512527
alt_text = models.CharField(null=True, blank=True, max_length=255)
513528
caption = models.CharField(null=True, blank=True, max_length=255)
514529
width = models.PositiveIntegerField(null=True, blank=True)
515530
height = models.PositiveIntegerField(null=True, blank=True)
516531

532+
longdesc = models.TextField(null=True, blank=True)
533+
free_link = models.CharField(_("link"), max_length=255, blank=True, null=True, help_text=_("if present image will be clickable"))
534+
page_link = models.ForeignKey(Page, verbose_name=_("page"), null=True, blank=True, help_text=_("if present image will be clickable"))
535+
float = models.CharField(_("side"), max_length=10, blank=True, null=True, choices=FLOAT_CHOICES)
536+
537+
538+
517539
#crop_ax = models.PositiveIntegerField(null=True, blank=True)
518540
#crop_ay = models.PositiveIntegerField(null=True, blank=True)
519541
#crop_bx = models.PositiveIntegerField(null=True, blank=True)
@@ -534,6 +556,9 @@ def __unicode__(self):
534556
else:
535557
return u"Image Publication %s" % self.caption
536558
return ''
559+
@property
560+
def alt(self):
561+
return self.alt_text
537562
if 'reversion' in settings.INSTALLED_APPS:
538563
import reversion
539564
reversion.register(ImagePublication, follow=["cmsplugin_ptr"])

0 commit comments

Comments
 (0)