collection home page + tags in revision_detail view + optimization in views + fixture for demo
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/iconolab/fixtures/demo_data.json Fri Jul 01 15:37:42 2016 +0200
@@ -0,0 +1,136 @@
+[
+ {
+ "model": "auth.User",
+ "pk": 1,
+ "fields": {
+ "username": "contributeur1",
+ "password": "pbkdf2_sha256$24000$4t81p9toYpfc$ufZAWaUcF51dpNqHscABIoW7UyoXxYDCRlKFI87vQJM="
+ }
+ },{
+ "model": "auth.User",
+ "pk": 2,
+ "fields": {
+ "username": "contributeur2",
+ "password": "pbkdf2_sha256$24000$b9CPP5bLU4FM$1IYIBS5y2CIEFV9jHdTdZjvj59hzx+yH5Akc5LsHo+g="
+ }
+ },{
+ "model": "iconolab.Collection",
+ "pk": 1,
+ "fields": {
+ "name": "ingres"
+ }
+ },{
+ "model": "iconolab.Item",
+ "pk": 1,
+ "fields": {
+ "collection": 1
+ }
+ },{
+ "model": "iconolab.ItemMetadata",
+ "pk": 1,
+ "fields": {
+ "item": 1,
+ "domain": "dessin",
+ "title": "",
+ "description": "",
+ "joconde_ref": "1"
+ }
+ },{
+ "model": "iconolab.Image",
+ "pk": 1,
+ "fields": {
+ "image_guid" : "26aec320-dcfe-4cbc-b912-6a6c13e8916e",
+ "name" : "MIC.8.10.jpg",
+ "media" : "uploads/MIC.8.10.jpg",
+ "item": 1,
+ "height": 2478,
+ "width": 3744,
+ "created": "2016-03-23 14:13:44.913765+01"
+ }
+ },{
+ "model": "iconolab.ImageStats",
+ "pk": 1,
+ "fields": {
+ "image": 1,
+ "annotations_count": 0,
+ "submitted_revisions_count": 0,
+ "comments_count": 0,
+ "folders_inclusion_count": 0,
+ "tag_count": 0
+ }
+ },{
+ "model": "iconolab.Item",
+ "pk": 2,
+ "fields": {
+ "collection": 1
+ }
+ },{
+ "model": "iconolab.ItemMetadata",
+ "pk": 2,
+ "fields": {
+ "item": 2,
+ "domain": "dessin",
+ "title": "",
+ "description": "",
+ "joconde_ref": "2"
+ }
+ },{
+ "model": "iconolab.Image",
+ "pk": 2,
+ "fields": {
+ "image_guid" : "de734457-b600-4bed-bb60-a03d906b8e6e",
+ "name" : "MIC.1.7.jpg",
+ "media" : "uploads/MIC.1.7.jpg",
+ "item": 2,
+ "height": 4672,
+ "width": 6171,
+ "created": "2016-03-23 14:13:44.913765+01"
+ }
+ },{
+ "model": "iconolab.ImageStats",
+ "pk": 2,
+ "fields": {
+ "image": 2,
+ "annotations_count": 0,
+ "submitted_revisions_count": 0,
+ "comments_count": 0,
+ "folders_inclusion_count": 0,
+ "tag_count": 0
+ }
+ },{
+ "model": "iconolab.MetaCategory",
+ "pk": 1,
+ "fields": {
+ "collection": 1,
+ "label": "Appel à contribution"
+ }
+ },{
+ "model": "iconolab.MetaCategory",
+ "pk": 2,
+ "fields": {
+ "collection": 1,
+ "label": "Appel à expert"
+ }
+ },{
+ "model": "iconolab.MetaCategory",
+ "pk": 3,
+ "fields": {
+ "collection": 1,
+ "label": "Référence"
+ }
+ },{
+ "model": "iconolab.MetaCategory",
+ "pk": 4,
+ "fields": {
+ "collection": 1,
+ "label": "Accord"
+ }
+ },{
+ "model": "iconolab.MetaCategory",
+ "pk": 5,
+ "fields": {
+ "collection": 1,
+ "label": "Désaccord"
+ }
+ }
+]
\ No newline at end of file
--- a/src/iconolab/models.py Fri Jul 01 16:47:22 2016 +0200
+++ b/src/iconolab/models.py Fri Jul 01 15:37:42 2016 +0200
@@ -272,15 +272,19 @@
#import label from external
externaL_repos_fetch_dict = {
"http://dbpedia.org/": fetch_from_dbpedia,
+ "http://fr.dbpedia.org/": fetch_from_dbpedia
}
- fetch_label = next(handling_function for base_uri, handling_function in externaL_repos_fetch_dict.items() if tag_link.startswith(base_uri))
- tag_label = fetch_label(tag_link, "fr")
- final_list.append({
- "tag_label": tag_label,
- "tag_link": tag_link,
- "accuracy": tagging_info.accuracy,
- "relevancy": tagging_info.relevancy
- })
+ try:
+ fetch_label = next(handling_function for base_uri, handling_function in externaL_repos_fetch_dict.items() if tag_link.startswith(base_uri))
+ tag_label = fetch_label(tag_link, "fr")
+ final_list.append({
+ "tag_label": tag_label,
+ "tag_link": tag_link,
+ "accuracy": tagging_info.accuracy,
+ "relevancy": tagging_info.relevancy
+ })
+ except StopIteration:
+ pass
return json.dumps(final_list)
class IconolabComment(XtdComment):
--- a/src/iconolab/templates/iconolab/collection_home.html Fri Jul 01 16:47:22 2016 +0200
+++ b/src/iconolab/templates/iconolab/collection_home.html Fri Jul 01 15:37:42 2016 +0200
@@ -6,4 +6,27 @@
{% load iconolab_tags %}
-{% block content %}collectionhome{% endblock %}
\ No newline at end of file
+{% block content %}
+ <h2>Fonds {{collection_name}}</h2>
+
+
+<ul class="annotation-list-wrapper list-inline">
+ <p><strong>Images du fond</strong></p>
+
+ {% for item in collection.items.all %}
+ <li class="small-image-wrapper">
+
+ <div class="fragment-container" style="position: relative">
+ {% for image in item.images.all %}
+ {% thumbnail image.media "x500" crop="center" as im %}
+ <img v-el:small-image src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
+ {% endthumbnail %}
+ <div class="fragment-infos">
+ <a class="fa fa-eye" href="{% url 'image_detail' collection_name image.image_guid %}">Voir les annotations</a>
+ </div>
+ {% endfor %}
+ </li>
+{% endfor %}
+</ul>
+
+{% endblock %}
\ No newline at end of file
--- a/src/iconolab/templates/iconolab/detail_annotation.html Fri Jul 01 16:47:22 2016 +0200
+++ b/src/iconolab/templates/iconolab/detail_annotation.html Fri Jul 01 15:37:42 2016 +0200
@@ -41,7 +41,7 @@
</div>
</div>
<div class='col-md-12'>
- <h4>Comments</h4>
+ <h4>Commentaires</h4>
{% get_comment_list for annotation as comment_list %}
<ul class="list-group" id="comments">
{% for comment in comment_list %}
@@ -71,7 +71,7 @@
{{ comment_form.security_hash }}
{{ comment_form.reply_to }}
<input type="hidden" name="next" value="{% url 'annotation_detail' collection_name image_guid annotation_guid %}">
- <h4> Commenting as {{user.username}} </h4>
+ <h4> Commenter en tant que {{user.username}} </h4>
<fieldset class="form-group {% if comment_form.comment.errors %}has-error{% endif %}">
<label class="control-label" for="id_{{ comment_form.comment.name }}">{{ comment_form.comment.label }}</label>
{% if comment_form.comment.errors %}
--- a/src/iconolab/templates/iconolab/detail_image.html Fri Jul 01 16:47:22 2016 +0200
+++ b/src/iconolab/templates/iconolab/detail_image.html Fri Jul 01 15:37:42 2016 +0200
@@ -9,6 +9,7 @@
{% block content %}
<div class="row">
<div class="col-md-6 col-md-offset-3">
+ <a class="btn btn-link" href="{% url 'collection_home' collection_name %}"><i class="fa fa-list"></i> Retour à la liste d'images</a>
<a class="btn btn-link" href="{% url 'annotation_create' collection_name image_guid %}"><i class="fa fa-plus"></i> Créer une nouvelle annotation</a>
{% thumbnail image.media "x800" crop="center" as im %}
--- a/src/iconolab/templates/iconolab/detail_revision.html Fri Jul 01 16:47:22 2016 +0200
+++ b/src/iconolab/templates/iconolab/detail_revision.html Fri Jul 01 15:37:42 2016 +0200
@@ -28,12 +28,12 @@
{% endthumbnail %}
</div>
</div>
-
- <div class='col-xs-6' style="">
+ <div id="revision-detail" class='col-xs-6' style="">
<h4>Annotation</h4>
<p> <strong>Title:</strong> {{ revision.title }}</p>
<p> <strong>Description:</strong> {{ revision.description }}</p>
- <p> <strong>Tags:</strong> {{ tags_data }}</p>
+ <p><strong>Tags:</strong></p>
+ <typeahead :read-only="1" :tags="{{ tags_data }}"></typeahead>
<div class="alert alert-info" role="alert">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
<span class="sr-only">Info:</span>
@@ -45,3 +45,13 @@
</div>
</div>
{% endblock %}
+
+{% block footer_js %}
+ <script>
+ new Vue({
+ el: "#revision-detail",
+ components: {'Typeahead': iconolab.VueComponents.Typeahead },
+ methods: { yo: function(){alert(1);} }
+ });
+ </script>
+{% endblock %}
--- a/src/iconolab/templates/partials/image_annotations_list.html Fri Jul 01 16:47:22 2016 +0200
+++ b/src/iconolab/templates/partials/image_annotations_list.html Fri Jul 01 15:37:42 2016 +0200
@@ -3,28 +3,32 @@
<ul class="annotation-list-wrapper list-inline">
- <p><strong>Annotations de l'image</strong></p>
-
- {% for annotation in annotation_list %}
- <li class="small-image-wrapper">
-
- <div class="fragment-container" style="position: relative">
- {% thumbnail annotation.image.media "x300" crop="center" as im %}
- <img v-el:small-image src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
- <svg width="{{ im.width }}" height="{{ im.height }}" version="1.1" style="position:absolute; top:0px; left: 0px">
- <g transform="matrix({% transform_matrix im_width=im.width im_height=im.height max_x=100 max_y=100 %})">
- <path d="{{ annotation.current_revision.fragment|clean_path }}" opacity="0.7" fill="orange"></path>
- </g>
- </svg>
- </div>
- {% endthumbnail %}
- <div class="fragment-infos">
- <a class="fa fa-eye" href="{% url 'annotation_detail' collection_name image_guid annotation.annotation_guid %}">Voir</a>
- <p class="small">Créee par <strong>{{ annotation.author }}</strong></strong><p>
- <p class="small">Révisée par <strong>{{ annotation.current_revision.author }}</strong>
- le {{ annotation.current_revision.created|date:'d-m-Y' }}
- </p>
- </div>
- </li>
-{% endfor %}
+ <h4><strong>Annotations de l'image</strong></h4>
+
+ {% if not annotation_list %}
+ <p> Aucune annotation pour cette image </p>
+ {% else %}
+ {% for annotation in annotation_list %}
+ <li class="small-image-wrapper">
+
+ <div class="fragment-container" style="position: relative">
+ {% thumbnail annotation.image.media "x300" crop="center" as im %}
+ <img v-el:small-image src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}" />
+ <svg width="{{ im.width }}" height="{{ im.height }}" version="1.1" style="position:absolute; top:0px; left: 0px">
+ <g transform="matrix({% transform_matrix im_width=im.width im_height=im.height max_x=100 max_y=100 %})">
+ <path d="{{ annotation.current_revision.fragment|clean_path }}" opacity="0.7" fill="orange"></path>
+ </g>
+ </svg>
+ </div>
+ {% endthumbnail %}
+ <div class="fragment-infos">
+ <a class="fa fa-eye" href="{% url 'annotation_detail' collection_name image_guid annotation.annotation_guid %}">Voir</a>
+ <p class="small">Créee par <strong>{{ annotation.author }}</strong></strong><p>
+ <p class="small">Révisée par <strong>{{ annotation.current_revision.author }}</strong>
+ le {{ annotation.current_revision.created|date:'d-m-Y' }}
+ </p>
+ </div>
+ </li>
+ {% endfor %}
+ {% endif %}
</ul>
\ No newline at end of file
--- a/src/iconolab/views.py Fri Jul 01 16:47:22 2016 +0200
+++ b/src/iconolab/views.py Fri Jul 01 15:37:42 2016 +0200
@@ -26,9 +26,18 @@
class CollectionHomepageView(View, ContextMixin):
+ def check_kwargs(self, kwargs):
+ try:
+ collection = Collection.objects.prefetch_related("items", "items__images").get(name=kwargs.get('collection_name'))
+ except Collection.DoesNotExist:
+ return RedirectView.as_view(url=reverse('404error'))
+ return collection
+
def get(self, request, *args, **kwargs):
+ collection = self.check_kwargs(kwargs)
context = super(CollectionHomepageView, self).get_context_data(**kwargs)
context['collection_name'] = self.kwargs.get('collection_name', '')
+ context['collection'] = collection
return render(request, 'iconolab/collection_home.html', context);
@@ -36,11 +45,11 @@
def check_kwargs(self, kwargs):
try:
- collection = Collection.objects.get(name=kwargs.get('collection_name'))
+ collection = Collection.objects.prefetch_related("items", "items__images").get(name=kwargs.get('collection_name'))
except Collection.DoesNotExist:
return RedirectView.as_view(url=reverse('404error'))
try:
- image = Image.objects.get(image_guid=kwargs.get('image_guid'))
+ image = Image.objects.prefetch_related("annotations").get(image_guid=kwargs.get('image_guid'))
except Image.DoesNotExist:
return RedirectView.as_view(url=reverse('404error'))
return collection, image
@@ -64,11 +73,11 @@
def check_kwargs(self, kwargs):
try:
- collection = Collection.objects.get(name=kwargs.get('collection_name'))
+ collection = Collection.objects.prefetch_related("items", "items__images").get(name=kwargs.get('collection_name'))
except Collection.DoesNotExist:
return RedirectView.as_view(url=reverse('404error'))
try:
- image = Image.objects.get(image_guid=kwargs.get('image_guid'))
+ image = Image.objects.prefetch_related("annotations").get(image_guid=kwargs.get('image_guid'))
except Image.DoesNotExist:
return RedirectView.as_view(url=reverse('404error'))
return collection, image
@@ -123,11 +132,11 @@
def check_kwargs(self, kwargs):
try:
- collection = Collection.objects.get(name=kwargs.get('collection_name'))
+ collection = Collection.objects.prefetch_related("items", "items__images").get(name=kwargs.get('collection_name'))
except Collection.DoesNotExist:
return RedirectView.as_view(url=reverse('404error'))
try:
- image = Image.objects.get(image_guid=kwargs.get('image_guid'))
+ image = Image.objects.prefetch_related("annotations").get(image_guid=kwargs.get('image_guid'))
except Image.DoesNotExist:
return RedirectView.as_view(url=reverse('404error'))
try:
@@ -158,11 +167,11 @@
def check_kwargs(self, kwargs):
try:
- collection = Collection.objects.get(name=kwargs.get('collection_name'))
+ collection = Collection.objects.prefetch_related("items", "items__images").get(name=kwargs.get('collection_name'))
except Collection.DoesNotExist:
return RedirectView.as_view(url=reverse('404error'))
try:
- image = Image.objects.get(image_guid=kwargs.get('image_guid'))
+ image = Image.objects.prefetch_related("annotations").get(image_guid=kwargs.get('image_guid'))
except Image.DoesNotExist:
return RedirectView.as_view(url=reverse('404error'))
try:
@@ -226,11 +235,11 @@
def check_kwargs(self, kwargs):
try:
- collection = Collection.objects.get(name=kwargs.get('collection_name'))
+ collection = Collection.objects.prefetch_related("items", "items__images").get(name=kwargs.get('collection_name'))
except Collection.DoesNotExist:
return RedirectView.as_view(url=reverse('404error'))
try:
- image = Image.objects.get(image_guid=kwargs.get('image_guid'))
+ image = Image.objects.prefetch_related("annotations").get(image_guid=kwargs.get('image_guid'))
except Image.DoesNotExist:
return RedirectView.as_view(url=reverse('404error'))
try: