+picture_storage = FileSystemStorage(location=path.join(
+ settings.MEDIA_ROOT, 'pictures'),
+ base_url=settings.MEDIA_URL + "pictures/")
+
+
+class PictureArea(models.Model):
+ picture = models.ForeignKey('picture.Picture', related_name='areas')
+ area = jsonfield.JSONField(_('area'), default={}, editable=False)
+ kind = models.CharField(_('kind'), max_length=10, blank=False,
+ null=False, db_index=True,
+ choices=(('thing', _('thing')),
+ ('theme', _('theme'))))
+
+ objects = models.Manager()
+ tagged = managers.ModelTaggedItemManager(catalogue.models.Tag)
+ tags = managers.TagDescriptor(catalogue.models.Tag)
+
+ @classmethod
+ def rectangle(cls, picture, kind, coords):
+ pa = PictureArea()
+ pa.picture = picture
+ pa.kind = kind
+ pa.area = coords
+ return pa
+
+ def short_html(self):
+ short_html = unicode(render_to_string(
+ 'picture/picturearea_short.html', {'area': self}))
+ return mark_safe(short_html)