# HG changeset patch # User Alexandre Segura # Date 1493132281 -7200 # Node ID f34b7f73777c749ccd7901291ad232e254b44d11 # Parent ed4fb56b213061da5f586ec49c5e83d5ed2960c2 Clean & simplify user home. diff -r ed4fb56b2130 -r f34b7f73777c src/iconolab/templates/iconolab/user_base.html --- 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 - {% if profile_user == request.user %} + +
+ {% if profile_user == request.user %} {% notifications_unread as unread_count %} - {% if unread_count %} {{ unread_count }} {% endif %} Notifications - - Paramètres - - {% endif %} {% if profile_user.profile.managed_collections.exists %} Collections {% endif %} + + Paramètres + + {% endif %}
{% block user_content %}{% endblock %}
diff -r ed4fb56b2130 -r f34b7f73777c src/iconolab/templates/iconolab/user_home.html --- 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 %}

{% if profile_user == request.user %}Mes dernières annotations{% else %}Dernières annotations de {{profile_user.username}}{% endif %}

- {% if not user_annotations %} -

Aucune annotation à afficher

+
Aucune annotation à afficher
{% else %} Voir toutes les annotations {% endif %}
-
-

{% if profile_user == request.user %}Mes contributions{% else %}Contributions de {{profile_user.username}}{% endif %}

-
-
- {% 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 %} -
-
- {% if not user_contributed_annotations %} -

Aucune annotation à afficher

- {% else %} -
    - {% for annotation_data in user_contributed_annotations %} - {% include "partials/user_pages/annotations_contributed_panel.html" with annotation_data=annotation_data user=profile_user %} - {% endfor %} -
  • - Voir toutes les contributions -
  • -
- {% endif %} -
-
- {% 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 %} -
-
- {% if not user_commented_annotations %} -

Aucune annotation à afficher

- {% else %} -
    - {% for annotation_data in user_commented_annotations %} - {% include "partials/user_pages/annotations_commented_panel.html" with annotation_data=annotation_data user=profile_user %} - {% endfor %} -
  • - Voir toutes les annotations commentées -
  • -
- {% endif %} -
-
-
- {% endblock %} {% block footer_js %} diff -r ed4fb56b2130 -r f34b7f73777c src/iconolab/templates/partials/user_pages/activity.html --- /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 %} +
  • +
    +
    + {% if action == 'create' %} + + {% endif %} + {% if action == 'contribute' %} + + {% endif %} + {% if action == 'comment' %} + + {% endif %} + + {{ user }} + + {% if action == 'create' %} + a créé + {% endif %} + {% if action == 'contribute' %} + a contribué à + {% endif %} + {% if action == 'comment' %} + commenté + {% endif %} + + {% if annotation.current_revision.title %} + {{annotation.current_revision.title}} + {% else %} + Annotation sans titre + {% endif %} +
    +
    +
    + {% if large_image %} + {% thumbnail annotation.image.media "400x400" crop=False as im %} + + + + + + + + + {% endthumbnail %} + {% else %} + {% thumbnail annotation.image.media "150x150" crop=False as im %} + + + + + + + + + {% endthumbnail %} + {% endif %} +
    +
    +
    +
    +
    A créé l'annotation le :
    +
    {{annotation.created}}
    +
    Commentaires :
    +
    {{annotation.stats.comments_count}}
    +
    Révisions en attente :
    +
    {{annotation.stats.awaiting_revisions_count}}
    +
    +
    + Voir annotation +
    + {% if with_stats %} +
    + {% include "partials/annotation_stats_panel.html" with annotation=annotation label="Statistiques sur cette annotation:" %} +
    + {% endif %} +
    +
    +
  • diff -r ed4fb56b2130 -r f34b7f73777c src/iconolab/views/userpages.py --- 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):