Error handling in models + templates fixes
authordurandn
Mon, 04 Jul 2016 12:11:12 +0200
changeset 58 9f7e484baf73
parent 57 9b448d5307af
child 59 b30fa6fabee8
Error handling in models + templates fixes
src/iconolab/models.py
src/iconolab/templates/iconolab/detail_annotation.html
src/iconolab/templates/partials/header.html
--- a/src/iconolab/models.py	Mon Jul 04 11:59:18 2016 +0200
+++ b/src/iconolab/models.py	Mon Jul 04 12:11:12 2016 +0200
@@ -255,7 +255,10 @@
             )
             results = json.loads(dbpedia_resp.text).get("results", {})
             variable_bindings = results.get("bindings")
-            label_json = variable_bindings.pop()
+            if variable_bindings:
+                label_json = variable_bindings.pop()
+            else:
+                label_json = {"l": {"value": "ERROR_LABEL"}}
             return label_json.get("l").get("value")
         
         final_list = []
--- a/src/iconolab/templates/iconolab/detail_annotation.html	Mon Jul 04 11:59:18 2016 +0200
+++ b/src/iconolab/templates/iconolab/detail_annotation.html	Mon Jul 04 12:11:12 2016 +0200
@@ -36,8 +36,7 @@
 				<p> <strong>Description:</strong> {{ annotation.current_revision.description }}</p>
         <p><strong>Tags:</strong></p>
         <typeahead :read-only="1" :tags="{{ tags_data }}"></typeahead>
-                
-				<a href="{% url 'annotation_edit' collection_name image_guid annotation_guid  %}">{% if user == annotation.creator %}Editer{% else %}Proposer une révision{% endif %}</a>
+				<a href="{% url 'annotation_edit' collection_name image_guid annotation_guid  %}">{% if user == annotation.author %}Editer{% else %}Proposer une révision{% endif %}</a>
                 
 			</div>
 		</div>
--- a/src/iconolab/templates/partials/header.html	Mon Jul 04 11:59:18 2016 +0200
+++ b/src/iconolab/templates/partials/header.html	Mon Jul 04 12:11:12 2016 +0200
@@ -13,7 +13,7 @@
       <ul class="nav navbar-nav">
         <li class="active"><a href="#">Accueil</a></li>
         <li><a href="#">Le projet</a></li>
-        <li><a href="{% url 'collection_home' collection_name %}">Contribuer</a></li>
+        {% if collection_name %}<li><a href="{% url 'collection_home' collection_name %}">Contribuer</a></li>{% endif %}
       </ul>
       
       <form class="navbar-form navbar-left" role="search">