Clean & simplify user home.
--- a/src/iconolab/templates/iconolab/user_base.html Wed Apr 19 21:42:31 2017 +0200
+++ b/src/iconolab/templates/iconolab/user_base.html Tue Apr 25 16:58:01 2017 +0200
@@ -17,27 +17,28 @@
class="list-group-item {% if request.resolver_match.url_name == 'user_annotations' %}active{% endif%}">
Annotations
</a>
- {% if profile_user == request.user %}
+ </div>
+ <div class="list-group">
+ {% if profile_user == request.user %}
<a href="{% url 'user_notifications' %}"
class="list-group-item {% if request.resolver_match.url_name == 'user_notifications' %}active{% endif%}">
{% notifications_unread as unread_count %}
-
{% if unread_count %}
<span class="badge badge-warning">{{ unread_count }}</span>
{% endif %}
Notifications
</a>
- <a href="{% url 'user_settings' %}"
- class="list-group-item {% if request.resolver_match.url_name == 'user_settings' %}active{% endif%}">
- Paramètres
- </a>
- {% endif %}
{% if profile_user.profile.managed_collections.exists %}
<a href="{% url 'user_collections' %}"
class="list-group-item {% if request.resolver_match.url_name == 'user_collections' %}active{% endif%}">
Collections
</a>
{% endif %}
+ <a href="{% url 'user_settings' %}"
+ class="list-group-item {% if request.resolver_match.url_name == 'user_settings' %}active{% endif%}">
+ Paramètres
+ </a>
+ {% endif %}
</div>
</div>
<div class="col-md-9">{% block user_content %}{% endblock %}</div>
--- a/src/iconolab/templates/iconolab/user_home.html Wed Apr 19 21:42:31 2017 +0200
+++ b/src/iconolab/templates/iconolab/user_home.html Tue Apr 25 16:58:01 2017 +0200
@@ -11,66 +11,17 @@
{% block user_content %}
<div>
<h4>{% if profile_user == request.user %}Mes dernières annotations{% else %}Dernières annotations de {{profile_user.username}}{% endif %}</h4>
-
{% if not user_annotations %}
- <h4 class="no-user-annotation"><small>Aucune annotation à afficher</small></h4>
+ <div class="alert alert-warning">Aucune annotation à afficher</div>
{% else %}
<ul class="list-unstyled">
- {% for annotation in user_annotations.all %}
- {% include "partials/user_pages/annotations_created_panel.html" with annotation=annotation user=profile_user %}
+ {% for activity_item in user_activity %}
+ {% include "partials/user_pages/activity.html" with user=profile_user annotation=activity_item.annotation action=activity_item.action %}
{% endfor %}
</ul>
<a class="btn btn-default btn-sm" href="{% url 'user_annotations' profile_user.username %}"><span class="glyphicon glyphicon-list" aria-hidden="true"></span> Voir toutes les annotations</a>
{% endif %}
</div>
- <div>
- <h4>{% if profile_user == request.user %}Mes contributions{% else %}Contributions de {{profile_user.username}}{% endif %}</h4>
- <dl>
- <dt class="dt-annotation">
- {% if profile_user == request.user %}
- Dernières annotations sur lesquelles j'ai proposé des révisions :
- {% else %}
- Dernières annotations sur lesquelles {{profile_user.username}} a proposé des révisions :
- {% endif %}
- </dt>
- <dd>
- {% if not user_contributed_annotations %}
- <h4 class="no-user-annotation"><small>Aucune annotation à afficher</small></h4>
- {% else %}
- <ul class="list-inline">
- {% for annotation_data in user_contributed_annotations %}
- {% include "partials/user_pages/annotations_contributed_panel.html" with annotation_data=annotation_data user=profile_user %}
- {% endfor %}
- <li>
- <a class="btn btn-default btn-sm" href="{% url 'user_contributed' profile_user.username %}"><span class="glyphicon glyphicon-list" aria-hidden="true"></span> Voir toutes les contributions</a>
- </li>
- </ul>
- {% endif %}
- </dd>
- <dt class="dt-annotation">
- {% if profile_user == request.user %}
- Dernières annotation sur lesquelles j'ai commenté (sans proposer de révision) :
- {% else %}
- Dernières annotations sur lesquelles {{profile_user.username}} a commenté (sans proposer de révision) :
- {% endif %}
- </dt>
- <dd>
- {% if not user_commented_annotations %}
- <h4 class="no-user-annotation"><small>Aucune annotation à afficher</small></h4>
- {% else %}
- <ul class="list-unstyled">
- {% for annotation_data in user_commented_annotations %}
- {% include "partials/user_pages/annotations_commented_panel.html" with annotation_data=annotation_data user=profile_user %}
- {% endfor %}
- <li>
- <a class="btn btn-default btn-sm" href="{% url 'user_commented' profile_user.username %}"><span class="glyphicon glyphicon-list" aria-hidden="true"></span> Voir toutes les annotations commentées</a>
- </li>
- </ul>
- {% endif %}
- </dd>
- </dl>
- </div>
-
{% endblock %}
{% block footer_js %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/iconolab/templates/partials/user_pages/activity.html Tue Apr 25 16:58:01 2017 +0200
@@ -0,0 +1,80 @@
+{% load thumbnail %}
+{% load iconolab_tags %}
+<li>
+ <div class="panel panel-default annotation-panel">
+ <div class="panel-heading">
+ {% if action == 'create' %}
+ <i class="fa fa-plus"></i>
+ {% endif %}
+ {% if action == 'contribute' %}
+ <i class="fa fa-pencil"></i>
+ {% endif %}
+ {% if action == 'comment' %}
+ <i class="fa fa-comment"></i>
+ {% endif %}
+
+ {{ user }}
+
+ {% if action == 'create' %}
+ a <strong>créé</strong>
+ {% endif %}
+ {% if action == 'contribute' %}
+ a <strong>contribué</strong> à
+ {% endif %}
+ {% if action == 'comment' %}
+ <strong>commenté</strong>
+ {% endif %}
+
+ {% if annotation.current_revision.title %}
+ {{annotation.current_revision.title}}
+ {% else %}
+ <i>Annotation sans titre</i>
+ {% endif %}
+ </div>
+ <div class="panel-body">
+ <div style="position:relative" class="{% if large_image %}large-{% endif %}image-detail">
+ {% if large_image %}
+ {% thumbnail annotation.image.media "400x400" crop=False as im %}
+ <a href="{% url 'annotation_detail' annotation.image.item.collection.name annotation.image.image_guid annotation.annotation_guid %}">
+ <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>
+ </a>
+ {% endthumbnail %}
+ {% else %}
+ {% thumbnail annotation.image.media "150x150" crop=False as im %}
+ <a href="{% url 'annotation_detail' annotation.image.item.collection.name annotation.image.image_guid annotation.annotation_guid %}">
+ <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>
+ </a>
+ {% endthumbnail %}
+ {% endif %}
+ </div>
+ <div class="annotation-detail">
+ <dl class="dl-horizontal">
+ <dl class="dl-horizontal">
+ <dt>A créé l'annotation le : </dt>
+ <dd><span>{{annotation.created}}</span></dd>
+ <dt>Commentaires : </dt>
+ <dd><span class="badge">{{annotation.stats.comments_count}}</span></dd>
+ <dt>Révisions en attente :</dt>
+ <dd><span class="badge {% if annotation.stats.awaiting_revisions_count > 0 %}badge-warning{% endif %}">{{annotation.stats.awaiting_revisions_count}}</span></dd>
+ </dl>
+ </dl>
+ <a class="btn btn-default btn-sm userpage-annotation-btn pull-left" href="{% url 'annotation_detail' annotation.image.item.collection.name annotation.image.image_guid annotation.annotation_guid %}">Voir annotation</a>
+ </div>
+ {% if with_stats %}
+ <div class="stats-annotation-userpage">
+ {% include "partials/annotation_stats_panel.html" with annotation=annotation label="Statistiques sur cette annotation:" %}
+ </div>
+ {% endif %}
+ </div>
+ </div>
+</li>
--- a/src/iconolab/views/userpages.py Wed Apr 19 21:42:31 2017 +0200
+++ b/src/iconolab/views/userpages.py Tue Apr 25 16:58:01 2017 +0200
@@ -11,6 +11,7 @@
from notifications.models import Notification
from iconolab.models import Collection, Annotation, IconolabComment, Image, MetaCategoriesCountInfo
from iconolab.auth.forms import UserForm
+from itertools import chain
from uuid import UUID
import logging
@@ -39,6 +40,14 @@
context['user_commented_annotations'] = Annotation.objects.get_annotations_commented_for_user(profile_user)[:5]
# .exclude(annotation_guid__in=[annotation.annotation_guid for annotation in context['user_revisions_annotations']])
+ user_created_annotations = [ { 'action': 'create', 'annotation': a } for a in list(context['user_annotations']) ]
+ user_contributed_annotations = [ { 'action': 'contribute', 'annotation': a['annotation_obj'] } for a in list(context['user_contributed_annotations']) ]
+ user_commented_annotations = [ { 'action': 'comment', 'annotation': a['annotation_obj'] } for a in list(context['user_commented_annotations']) ]
+
+ annotations = list(chain(user_created_annotations, user_contributed_annotations, user_commented_annotations))
+
+ context['user_activity'] = sorted(annotations, key=lambda a: a['annotation'].created, reverse=True)
+
return context
def get(self, request, *args, **kwargs):