Adding one migration and adapting templates for link images collections in iconolab-mcc
authorRiwad Salim
Thu, 05 Jul 2018 12:43:26 +0200
changeset 20 a07ea7805cc4
parent 19 b6b9e9635cec
child 21 631f70f55fed
Adding one migration and adapting templates for link images collections in iconolab-mcc
src/iconolab_mcc/migrations/0033_link_text_link_url_data.py
src/iconolab_mcc/migrations/__init__.py
src/iconolab_mcc/templates/iconolab/metadatas/detail_image_metadatas.html
src/iconolab_mcc/templates/iconolab/metadatas/detail_item_metadatas.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/iconolab_mcc/migrations/0033_link_text_link_url_data.py	Thu Jul 05 12:43:26 2018 +0200
@@ -0,0 +1,20 @@
+
+from django.db import migrations
+
+def copy_link_data(apps, schema_editor):
+    Collection = apps.get_model('iconolab', 'Collection')
+    for collection in Collection.objects.all():
+        collection.link_text = 'Cet objet dans Joconde catalogue collectif des collections des musées de France'
+        collection.link_url = "http://www.culture.gouv.fr/public/mistral/joconde_fr?ACTION=CHERCHER&FIELD_98=REF&VALUE_98={joconde_ref:0>11}"
+        collection.save()
+
+class Migration(migrations.Migration):
+    
+
+    dependencies = [
+        ('iconolab', '0032_auto_20180704_1131'),
+    ]
+
+    operations = [
+        migrations.RunPython(copy_link_data),
+    ]
--- a/src/iconolab_mcc/templates/iconolab/metadatas/detail_image_metadatas.html	Thu Jul 05 12:22:29 2018 +0200
+++ b/src/iconolab_mcc/templates/iconolab/metadatas/detail_image_metadatas.html	Thu Jul 05 12:43:26 2018 +0200
@@ -14,9 +14,14 @@
   {% if item.metadatas.metadata_obj.inventory_number %}<dt>Numéro d'inventaire</dt><dd>{{item.metadatas.metadata_obj.inventory_number}}</dd>{% endif %}
 </dl>
 {% if item.metadatas.metadata_obj.joconde_ref %}
+{% with item_link_url=item.get_item_link_url item_link_text=item.get_item_link_text %}
+{% if item_link_url and item_link_text %}
 <p class="text-center">
-  <a href= "{% joconde_link item.metadatas %}" target="_blank">
-  Cet objet dans Joconde catalogue collectif des collections des musées de France
+  <a href= "{{item_link_url}}" target="_blank">
+  {{item_link_text}}
   </a>
 </p>
 {% endif %}
+{% endwith %}
+{% endif %}
+
--- a/src/iconolab_mcc/templates/iconolab/metadatas/detail_item_metadatas.html	Thu Jul 05 12:22:29 2018 +0200
+++ b/src/iconolab_mcc/templates/iconolab/metadatas/detail_item_metadatas.html	Thu Jul 05 12:43:26 2018 +0200
@@ -11,5 +11,11 @@
 {% if item.metadatas.metadata_obj.discovery_context %}<h5>Contexte de découverte : <small>{{item.metadatas.metadata_obj.discovery_context}}</small></h5>{% endif %}
 {% if item.metadatas.metadata_obj.photo_credits %}<h5>Crédits photographiques : <small>{{item.metadatas.metadata_obj.photo_credits}}</small></h5>{% endif %}
 {% if item.metadatas.metadata_obj.inventory_number %}<h5>Numéro d'inventaire : <small>{{item.metadatas.metadata_obj.inventory_number}}</small></h5>{% endif %} 
-{% if item.metadatas.metadata_obj.joconde_ref %}<h5><a href="{% joconde_link item.metadatas %}" target="_blank">Cet objet dans Joconde, catalogue collectif des collections des musées de France</a></h5>{% endif %}
+{% if item.metadatas.metadata_obj.joconde_ref %}
+{% with item_link_url=item.get_item_link_url item_link_text=item.get_item_link_text %}
+{% if item_link_url and item_link_text %}
+<h5><a href="{{item_link_url}}" target="_blank">{{item_link_text}}</a></h5>
+{% endif %}
+{% endwith %}
+{% endif %}
 <br>