From 7f5a997212159172fe5ed3fb17a56b0c4fbdafa4 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 1 Mar 2012 23:12:07 +0100 Subject: Work on multimedia fields --- ...add_field_picturefile_order__del_field_multi.py | 28 ++---- chimere/models.py | 39 +++----- chimere/static/chimere/css/styles.css | 35 ++++++- chimere/static/chimere/img/8thNote.png | Bin 0 -> 1988 bytes chimere/static/chimere/img/images_licences | 7 ++ chimere/templates/chimere/blocks/head_jme.html | 13 +++ chimere/templates/chimere/detail.html | 102 +++++++++++++++------ chimere/templates/chimere/main_map.html | 7 +- chimere/templatetags/chimere_tags.py | 10 ++ chimere/views.py | 3 +- 10 files changed, 165 insertions(+), 79 deletions(-) create mode 100644 chimere/static/chimere/img/8thNote.png create mode 100644 chimere/templates/chimere/blocks/head_jme.html diff --git a/chimere/migrations/0006_auto__add_multimediatype__add_field_picturefile_order__del_field_multi.py b/chimere/migrations/0006_auto__add_multimediatype__add_field_picturefile_order__del_field_multi.py index 9e369f7..908e868 100644 --- a/chimere/migrations/0006_auto__add_multimediatype__add_field_picturefile_order__del_field_multi.py +++ b/chimere/migrations/0006_auto__add_multimediatype__add_field_picturefile_order__del_field_multi.py @@ -13,7 +13,7 @@ class Migration(SchemaMigration): ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), ('media_type', self.gf('django.db.models.fields.CharField')(max_length=1)), ('name', self.gf('django.db.models.fields.CharField')(max_length=150)), - ('mime_type', self.gf('django.db.models.fields.CharField')(max_length=50)), + ('mime_type', self.gf('django.db.models.fields.CharField')(max_length=50, null=True, blank=True)), ('available', self.gf('django.db.models.fields.BooleanField')(default=True)), )) db.send_create_signal('chimere', ['MultimediaType']) @@ -25,7 +25,7 @@ class Migration(SchemaMigration): db.delete_column('chimere_multimediafile', 'file_type') # Adding field 'MultimediaFile.iframe' - db.add_column('chimere_multimediafile', 'iframe', self.gf('django.db.models.fields.CharField')(max_length=1000, null=True, blank=True), keep_default=False) + db.add_column('chimere_multimediafile', 'iframe', self.gf('django.db.models.fields.BooleanField')(default=False), keep_default=False) # Adding field 'MultimediaFile.order' db.add_column('chimere_multimediafile', 'order', self.gf('django.db.models.fields.IntegerField')(default=1), keep_default=False) @@ -33,12 +33,6 @@ class Migration(SchemaMigration): # Adding field 'MultimediaFile.multimedia_type' db.add_column('chimere_multimediafile', 'multimedia_type', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['chimere.MultimediaType'], null=True, blank=True), keep_default=False) - # Changing field 'MultimediaFile.url' - db.alter_column('chimere_multimediafile', 'url', self.gf('django.db.models.fields.CharField')(max_length=200, null=True)) - - # Removing M2M table for field multimedia_files on 'Marker' - db.delete_table('chimere_marker_multimedia_files') - def backwards(self, orm): @@ -60,17 +54,6 @@ class Migration(SchemaMigration): # Deleting field 'MultimediaFile.multimedia_type' db.delete_column('chimere_multimediafile', 'multimedia_type_id') - # User chose to not deal with backwards NULL issues for 'MultimediaFile.url' - raise RuntimeError("Cannot reverse this migration. 'MultimediaFile.url' and its values cannot be restored.") - - # Adding M2M table for field multimedia_files on 'Marker' - db.create_table('chimere_marker_multimedia_files', ( - ('id', models.AutoField(verbose_name='ID', primary_key=True, auto_created=True)), - ('marker', models.ForeignKey(orm['chimere.marker'], null=False)), - ('multimediafile', models.ForeignKey(orm['chimere.multimediafile'], null=False)) - )) - db.create_unique('chimere_marker_multimedia_files', ['marker_id', 'multimediafile_id']) - models = { 'chimere.area': { @@ -117,6 +100,7 @@ class Migration(SchemaMigration): 'categories': ('chimere.widgets.SelectMultipleField', [], {'to': "orm['chimere.SubCategory']", 'symmetrical': 'False'}), 'end_date': ('django.db.models.fields.DateField', [], {'null': 'True', 'blank': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'multimedia_files': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['chimere.MultimediaFile']", 'null': 'True', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'}), 'pictures': ('django.db.models.fields.related.ManyToManyField', [], {'symmetrical': 'False', 'to': "orm['chimere.PictureFile']", 'null': 'True', 'blank': 'True'}), 'point': ('chimere.widgets.PointField', [], {}), @@ -131,18 +115,18 @@ class Migration(SchemaMigration): 'chimere.multimediafile': { 'Meta': {'object_name': 'MultimediaFile'}, 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), - 'iframe': ('django.db.models.fields.CharField', [], {'max_length': '1000', 'null': 'True', 'blank': 'True'}), + 'iframe': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), 'multimedia_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['chimere.MultimediaType']", 'null': 'True', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '150', 'null': 'True', 'blank': 'True'}), 'order': ('django.db.models.fields.IntegerField', [], {'default': '1'}), - 'url': ('django.db.models.fields.CharField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}) + 'url': ('django.db.models.fields.CharField', [], {'max_length': '200'}) }, 'chimere.multimediatype': { 'Meta': {'object_name': 'MultimediaType'}, 'available': ('django.db.models.fields.BooleanField', [], {'default': 'True'}), 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), 'media_type': ('django.db.models.fields.CharField', [], {'max_length': '1'}), - 'mime_type': ('django.db.models.fields.CharField', [], {'max_length': '50'}), + 'mime_type': ('django.db.models.fields.CharField', [], {'max_length': '50', 'null': 'True', 'blank': 'True'}), 'name': ('django.db.models.fields.CharField', [], {'max_length': '150'}) }, 'chimere.news': { diff --git a/chimere/models.py b/chimere/models.py index 5282fca..52b13f4 100644 --- a/chimere/models.py +++ b/chimere/models.py @@ -238,16 +238,11 @@ class Marker(GeographicItem): return self.name @property - def multimedia_pictures(self): - pict = self.pictures.filter(miniature=False) - if pict.count(): - return pict.all() - - @property - def multimedia_files(self): - mm = self.multimedia_files.filter() - if mm.count(): - return mm.all() + def multimedia_items(self): + pict = list(self.pictures.filter(miniature=False).all()) + mm = list(self.multimedia_files.all()) + items = [(item.order, item) for item in pict + mm] + return [item for order, item in sorted(items)] @property def default_picture(self): @@ -359,7 +354,8 @@ class MultimediaType(models.Model): 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) + mime_type = models.CharField(_(u"Mime type"), max_length=50, blank=True, + null=True) available = models.BooleanField(_(u"Available"), default=True) def __unicode__(self): @@ -367,9 +363,8 @@ 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, blank=True, null=True) - iframe = models.CharField(_(u"Iframe"), max_length=1000, 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) @@ -378,16 +373,12 @@ class MultimediaFile(models.Model): return self.name def clean(self): - if self.url and not self.multimedia_type: - raise ValidationError(_(u"Multimedia type is mandatory if you "\ - u"provide an url.")) - if not self.url and not self.iframe: - raise ValidationError(_(u"You must provide at least provide an "\ - u" url or an iframe.")) - if self.url and self.iframe: - raise ValidationError(_(u"You must provide an url OR an"\ - u"iframe.")) - + if self.url and not self.iframe: + raise ValidationError(_(u"Multimedia type is mandatory if is "\ + u"not an iframe.")) + if self.multimedia_type and self.iframe: + raise ValidationError(_(u"There is no multimedia type associated "\ + u"to an iframe.")) class PictureFile(models.Model): miniature = models.BooleanField(_(u"Miniature")) diff --git a/chimere/static/chimere/css/styles.css b/chimere/static/chimere/css/styles.css index ef13e7d..8239a45 100644 --- a/chimere/static/chimere/css/styles.css +++ b/chimere/static/chimere/css/styles.css @@ -524,5 +524,38 @@ a#welcome_button{ .simple .cloud img{display:None;} #gallery{ - display:none; + width:700px; + height:400px; +} + + + +/** jme **/ + +/*overlay controls*/ +.media-controls-wrapper { + position: absolute; + bottom: 0; + width: 100%; +} +/* position the fullscreen-button */ +div.volume-slider { + right: 46px; + width: 60px; +} +.fullscreen { + right: 8px; +} +/* prepare fullscreen-button for flash fullscreen in modern browsers */ +html > body .media-state { + height: auto; + top: 0; + bottom: 2em; +} +.jme-flashbutton-wrapper .media-controls-wrapper { + pointer-events: none; +} + +.jme-flashbutton-wrapper .media-controls > *:not(.fullscreen) { + pointer-events: auto; } diff --git a/chimere/static/chimere/img/8thNote.png b/chimere/static/chimere/img/8thNote.png new file mode 100644 index 0000000..1351aa3 Binary files /dev/null and b/chimere/static/chimere/img/8thNote.png differ diff --git a/chimere/static/chimere/img/images_licences b/chimere/static/chimere/img/images_licences index 6dc68fd..0e732fc 100644 --- a/chimere/static/chimere/img/images_licences +++ b/chimere/static/chimere/img/images_licences @@ -23,3 +23,10 @@ Author: The Tango! Desktop Project Licence: Public domain Url: http://commons.wikimedia.org/wiki/File:Edit-find-replace.svg Url 2: http://commons.wikimedia.org/wiki/File:Internet-web-browser.svg + +* Quaver image credit + + * An 8th-note. +Author: Sbrools +Licence: Public domain +Url: https://commons.wikimedia.org/wiki/File:8thNote.svg diff --git a/chimere/templates/chimere/blocks/head_jme.html b/chimere/templates/chimere/blocks/head_jme.html new file mode 100644 index 0000000..f2b6767 --- /dev/null +++ b/chimere/templates/chimere/blocks/head_jme.html @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/chimere/templates/chimere/detail.html b/chimere/templates/chimere/detail.html index 3218d63..e9c061c 100644 --- a/chimere/templates/chimere/detail.html +++ b/chimere/templates/chimere/detail.html @@ -10,7 +10,7 @@ {% for property in marker.getProperties %}

{{ property.value|sanitize:"p b i br hr strong em span:style a:href:target ul li ol h1 h2 h3 h4"|safe}}

{% endfor %} - {% if multimedia_files or multimedia_pictures %} + {% if marker.multimedia_items %} {% trans "Show multimedia gallery" %} {% endif %} {% if share_networks %} @@ -26,34 +26,80 @@ {% endif %} -{% if multimedia_files or multimedia_pictures %} +{% if marker.multimedia_items %}