From 9d32b35a7b5f4effa1551c67bde8cef733a151d4 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 7 Mar 2012 15:19:19 +0100 Subject: Deport the "iframe status" to multimedia types --- chimere/fixtures/initial_data.json | 48 ++++++++++++++++++++++------------- chimere/models.py | 31 +++++++++++++++++++--- chimere/templates/chimere/detail.html | 4 +-- 3 files changed, 60 insertions(+), 23 deletions(-) diff --git a/chimere/fixtures/initial_data.json b/chimere/fixtures/initial_data.json index 43664fb..629c092 100644 --- a/chimere/fixtures/initial_data.json +++ b/chimere/fixtures/initial_data.json @@ -918,30 +918,13 @@ ] } }, - { - "pk": 1, - "model": "auth.user", - "fields": { - "username": "etienne", - "first_name": "", - "last_name": "", - "is_active": true, - "is_superuser": true, - "is_staff": true, - "last_login": "2012-02-18 20:58:02", - "groups": [], - "user_permissions": [], - "password": "sha1$3d587$c8d723a756209c1741618e9b7d87bb0973170fbe", - "email": "etienne@peacefrogs.net", - "date_joined": "2012-02-18 19:13:42" - } - }, { "pk": 7, "model": "chimere.multimediatype", "fields": { "available": true, "media_type": "V", + "iframe": false, "name": "Matroska (mkv)", "mime_type": "video/x-matroska" } @@ -952,6 +935,7 @@ "fields": { "available": true, "media_type": "A", + "iframe": false, "name": "MP4 (mp4)", "mime_type": "audio/mp4" } @@ -962,6 +946,7 @@ "fields": { "available": true, "media_type": "A", + "iframe": false, "name": "MP3 (mp3)", "mime_type": "audio/mpeg" } @@ -972,6 +957,7 @@ "fields": { "available": true, "media_type": "A", + "iframe": false, "name": "Ogg Vorbis (ogg)", "mime_type": "audio/ogg" } @@ -982,6 +968,7 @@ "fields": { "available": true, "media_type": "V", + "iframe": false, "name": "MP4 (mp4)", "mime_type": "video/mp4" } @@ -992,6 +979,7 @@ "fields": { "available": true, "media_type": "V", + "iframe": false, "name": "MPEG-1 (mpg, mpeg)", "mime_type": "video/mpeg" } @@ -1002,6 +990,7 @@ "fields": { "available": true, "media_type": "V", + "iframe": false, "name": "AVI - xvid, mp3 (avi)", "mime_type": "video/msvideo; codecs='xvid,mp3'" } @@ -1012,8 +1001,31 @@ "fields": { "available": true, "media_type": "V", + "iframe": false, "name": "Ogg Theora (ogg, ogm, ogv)", "mime_type": "video/ogg" } + }, + { + "pk": 9, + "model": "chimere.multimediatype", + "fields": { + "available": true, + "media_type": "V", + "iframe": true, + "name": "Youtube", + "mime_type": "" + } + }, + { + "pk": 10, + "model": "chimere.multimediatype", + "fields": { + "available": true, + "media_type": "O", + "iframe": true, + "name": "Iframe", + "mime_type": "" + } } ] diff --git a/chimere/models.py b/chimere/models.py index 52b13f4..1933ba3 100644 --- a/chimere/models.py +++ b/chimere/models.py @@ -237,6 +237,16 @@ class Marker(GeographicItem): def __unicode__(self): return self.name + def get_init_multi(self): + multis = [forms.model_to_dict(multi) + for multi in self.multimedia_files.all()] + return multis + + def get_init_picture(self): + picts = [forms.model_to_dict(pict) + for pict in self.pictures.all()] + return picts + @property def multimedia_items(self): pict = list(self.pictures.filter(miniature=False).all()) @@ -350,12 +360,14 @@ class Marker(GeographicItem): class MultimediaType(models.Model): MEDIA_TYPES = (('A', _(u"Audio")), ('V', _(u"Video")), - ('I', _(u"Image"))) + ('I', _(u"Image")), + ('O', _(u"Other")),) media_type = models.CharField(_(u"Media type"), max_length=1, choices=MEDIA_TYPES) name = models.CharField(_(u"Name"), max_length=150) mime_type = models.CharField(_(u"Mime type"), max_length=50, blank=True, null=True) + iframe = models.BooleanField(u"Inside an iframe", default=False) available = models.BooleanField(_(u"Available"), default=True) def __unicode__(self): @@ -364,7 +376,6 @@ class MultimediaType(models.Model): class MultimediaFile(models.Model): name = models.CharField(_(u"Name"), max_length=150, blank=True, null=True) url = models.CharField(_(u"Url"), max_length=200) - iframe = models.BooleanField(u"Iframe", default=False) order = models.IntegerField(_(u"Order"), default=1) multimedia_type = models.ForeignKey(MultimediaType, blank=True, null=True) @@ -381,12 +392,12 @@ class MultimediaFile(models.Model): u"to an iframe.")) class PictureFile(models.Model): - miniature = models.BooleanField(_(u"Miniature")) name = models.CharField(_(u"Name"), max_length=150, blank=True, null=True) picture = models.ImageField(_(u"Image"), upload_to='upload', height_field='height', width_field='width') height = models.IntegerField(_(u"Height")) width = models.IntegerField(_(u"Width")) + miniature = models.BooleanField(_(u"Display inside the resume ?")) order = models.IntegerField(_(u"Order"), default=1) def __unicode__(self): @@ -469,6 +480,20 @@ class Route(GeographicItem): ordering = ('status', 'name') verbose_name = _(u"Route") + def get_init_multi(self): + if not self.associated_file: + return [] + multis = [forms.model_to_dict(multi) + for multi in self.associated_file.multimedia_files.all()] + return multis + + def get_init_picture(self): + if not self.associated_file: + return [] + picts = [forms.model_to_dict(pict) + for pict in self.associated_file.pictures.all()] + return picts + def getProperty(self, propertymodel, safe=None): """Get the property of an associated property model. If safe set to True, verify if the property is available diff --git a/chimere/templates/chimere/detail.html b/chimere/templates/chimere/detail.html index e9c061c..d7c9449 100644 --- a/chimere/templates/chimere/detail.html +++ b/chimere/templates/chimere/detail.html @@ -36,7 +36,7 @@
{% if multimedia_item.picture %} {{multimedia_picture.name}}{% endif %} - {% if multimedia_item.url and not multimedia_item.iframe %} + {% if multimedia_item.url and not multimedia_item.multimedia_type.iframe %}
{{multimedia_item.name}}
{% endif %} - {% if multimedia_item.iframe %} + {% if multimedia_item.multimedia_type.iframe %} {% endif %} {% endfor %} -- cgit v1.2.3