# HG changeset patch # User Alexandre Segura # Date 1495202710 -7200 # Node ID accd1fded1a5a17efff9c683dcb8f6e77ca16863 # Parent 2d9c92c0d03a043324025a5cfcb700b201ec62d7 Improve homepage. - Add best contributors - Add latest annotations - Add most accurate tags diff -r 2d9c92c0d03a -r accd1fded1a5 src/iconolab/models.py --- a/src/iconolab/models.py Fri May 19 15:41:53 2017 +0200 +++ b/src/iconolab/models.py Fri May 19 16:05:10 2017 +0200 @@ -853,7 +853,7 @@ return self.link.startswith(settings.INTERNAL_TAGS_URL) def __str__(self): - return "Tag:" + self.label + return "Tag:" + str(self.label) class TaggingInfo(models.Model): diff -r 2d9c92c0d03a -r accd1fded1a5 src/iconolab/templates/iconolab/collection_home.html --- a/src/iconolab/templates/iconolab/collection_home.html Fri May 19 15:41:53 2017 +0200 +++ b/src/iconolab/templates/iconolab/collection_home.html Fri May 19 16:05:10 2017 +0200 @@ -80,7 +80,7 @@ {% for contributor in annotation.stats.contributors %} {{ contributor }} {% endfor %} -

+

{{ annotation.current_revision.description }}

{% for tagging_info in annotation.current_revision.tagginginfo_set.all %}

diff -r 2d9c92c0d03a -r accd1fded1a5 src/iconolab/templates/iconolab/home.html --- a/src/iconolab/templates/iconolab/home.html Fri May 19 15:41:53 2017 +0200 +++ b/src/iconolab/templates/iconolab/home.html Fri May 19 16:05:10 2017 +0200 @@ -4,6 +4,7 @@ {% load staticfiles %} {% load thumbnail %} {% load iconolab_tags %} +{% load humanize %} {% block content %}

@@ -12,10 +13,16 @@ est actuellement en cours de développement.

La première phase d'expérimentation démarrera mi-mars 2017. Pour plus d'informations, prière de contacter {{ contact }}.

+
+
+

Les collections

+
+
+ {% for collection in collections_primary %}
-
+
{% thumbnail collection.image "450x250" crop="center" as im %}
@@ -27,12 +34,82 @@ Contribuer
-

{{collection.description|safe}}

+

{{collection.description|safe}}

{% endthumbnail %}
{% endfor %}
+
+
+

Les dernières annotations

+ {% for annotation in latest_annotations %} +
+
+ +
+
+
+ {% thumbnail annotation.image.media "100x100" crop=False as im %} + + + + + + + + + {% endthumbnail %} +
+
+
+ +

+ {{ annotation.current_revision.title }} + {{ annotation.current_revision.created|naturaltime }} +

+

+ {% for contributor in annotation.stats.contributors %} + {{ contributor.username }} + {% endfor %} +

+

{{ annotation.current_revision.description }}

+

+ {% for tagging_info in annotation.current_revision.tagginginfo_set.all %} +  {{ tagging_info.tag.label }} + {% endfor %} +

+
+
+
+
+ {% endfor %} +
+
+

Les meilleurs contributeurs

+ + +

Les mots-clé les plus pertinents

+ + +
+
{% for collection in collections_secondary %}
diff -r 2d9c92c0d03a -r accd1fded1a5 src/iconolab/views/objects.py --- a/src/iconolab/views/objects.py Fri May 19 15:41:53 2017 +0200 +++ b/src/iconolab/views/objects.py Fri May 19 16:05:10 2017 +0200 @@ -13,7 +13,7 @@ from django.contrib.sites.models import Site from django.conf import settings from notifications.models import Notification -from iconolab.models import Annotation, AnnotationRevision, Collection, Folder, Item, Image, IconolabComment, MetaCategory, MetaCategoryInfo, BookmarkCategory, Bookmark +from iconolab.models import Annotation, AnnotationRevision, Collection, Folder, Item, Image, IconolabComment, MetaCategory, MetaCategoryInfo, BookmarkCategory, Bookmark, Tag, TaggingInfo from iconolab.forms.annotations import AnnotationRevisionForm from iconolab.forms.bookmarks import BookmarkForm from iconolab.serializers import AnnotationRevisionSerializer @@ -38,6 +38,38 @@ context = {} context['collections_primary'] = Collection.objects.filter(show_image_on_home=True).all() context['collections_secondary'] = Collection.objects.filter(show_image_on_home=False).all() + context['latest_annotations'] = Annotation.objects.order_by("-created").all()[:5] + + # Best contributors + count_contributions = Annotation.objects.all()\ + .values('author').annotate(contributions=Count('author')).order_by('-contributions')[:10] + best_contributors = [] + for count_contribution in count_contributions: + author = User.objects.get(id=count_contribution['author']) + best_contributors.append({ + 'author': author, + 'contributions': count_contribution['contributions'] + }) + context['best_contributors'] = best_contributors + + # Most accurate tags (tags with accuracy >= 4) + rows = TaggingInfo.objects\ + .prefetch_related('revision', 'revision__annotation')\ + .filter(accuracy__gte=4)\ + .values('tag')\ + .annotate(annotation_count=Count('revision__annotation', distinct=True))\ + .order_by('-annotation_count')\ + .all()[:10] + + most_accurate_tags = [] + for row in rows: + tag = Tag.objects.get(id=row['tag']) + most_accurate_tags.append({ + 'tag': tag, + 'annotation_count': row['annotation_count'] + }) + context['most_accurate_tags'] = most_accurate_tags + context['contact'] = settings.CONTACT_EMAIL context['homepage'] = True return render(request, 'iconolab/home.html', context) diff -r 2d9c92c0d03a -r accd1fded1a5 src_js/iconolab-bundle/src/iconolab.scss --- a/src_js/iconolab-bundle/src/iconolab.scss Fri May 19 15:41:53 2017 +0200 +++ b/src_js/iconolab-bundle/src/iconolab.scss Fri May 19 16:05:10 2017 +0200 @@ -338,6 +338,18 @@ margin-top:0px; } +.home-collection-description { + $max-lines: 5; + display: block; /* Fallback for non-webkit */ + display: -webkit-box; + line-height: $line-height-computed; + max-height: ($line-height-computed * $max-lines); + -webkit-line-clamp: $max-lines; + -webkit-box-orient: vertical; + overflow: hidden; + text-overflow: ellipsis; +} + /* COLLECTION HOME PAGE */ .collection-summary{