# HG changeset patch # User Alexandre Segura # Date 1489750621 -3600 # Node ID fb9bf3f479f1f527595af9cc48aa72269c0446fc # Parent de38f6ddaff5e505965ad35de92ced50944dda76 Improve user pages. - Add layout for all user pages - Add left menu - Split content into subpages. diff -r de38f6ddaff5 -r fb9bf3f479f1 src/iconolab/templates/iconolab/user_annotations.html --- a/src/iconolab/templates/iconolab/user_annotations.html Thu Mar 16 13:14:44 2017 +0100 +++ b/src/iconolab/templates/iconolab/user_annotations.html Fri Mar 17 12:37:01 2017 +0100 @@ -1,4 +1,4 @@ -{% extends 'iconolab_base.html' %} +{% extends 'iconolab/user_base.html' %} {% load staticfiles %} @@ -8,10 +8,8 @@ {% load notifications_tags %} -{% block content %} +{% block user_content %}
-

{{profile_user.username}}: Annotations créées Retour au profil

-
{% if not user_annotations %}

Aucune annotation à afficher

{% else %} diff -r de38f6ddaff5 -r fb9bf3f479f1 src/iconolab/templates/iconolab/user_base.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/iconolab/templates/iconolab/user_base.html Fri Mar 17 12:37:01 2017 +0100 @@ -0,0 +1,38 @@ +{% extends 'iconolab_base.html' %} + +{% block content %} + +
+
+
+ + Activité + + + Annotations + + {% if profile_user == request.user %} + + Notifications + + + Paramètres + + {% endif %} + {% if profile_user.profile.managed_collections.exists %} + + Collections + + {% endif %} +
+
+
{% block user_content %}{% endblock %}
+
+{% endblock %} diff -r de38f6ddaff5 -r fb9bf3f479f1 src/iconolab/templates/iconolab/user_collections.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/iconolab/templates/iconolab/user_collections.html Fri Mar 17 12:37:01 2017 +0100 @@ -0,0 +1,11 @@ +{% extends 'iconolab/user_base.html' %} + +{% block user_content %} +

Administration de Fonds

+ {% for collection in profile_user.profile.managed_collections.all %} +

{{collection.verbose_name}}

+
+ Tableau de bord +
+ {% endfor %} +{% endblock %} diff -r de38f6ddaff5 -r fb9bf3f479f1 src/iconolab/templates/iconolab/user_home.html --- a/src/iconolab/templates/iconolab/user_home.html Thu Mar 16 13:14:44 2017 +0100 +++ b/src/iconolab/templates/iconolab/user_home.html Fri Mar 17 12:37:01 2017 +0100 @@ -1,4 +1,4 @@ -{% extends 'iconolab_base.html' %} +{% extends 'iconolab/user_base.html' %} {% load staticfiles %} @@ -8,151 +8,68 @@ {% load notifications_tags %} -{% block content %} - - {% if profile_user == request.user %} -
-
-

Coordonnées

-
- {% csrf_token %} -
- - - {% if user_form.email.errors %} - {{ user_form.email.errors | striptags }} - {% endif %} -
- -
-
-
- {% 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 %} diff -r de38f6ddaff5 -r fb9bf3f479f1 src/iconolab/templates/iconolab/user_notifications.html --- a/src/iconolab/templates/iconolab/user_notifications.html Thu Mar 16 13:14:44 2017 +0100 +++ b/src/iconolab/templates/iconolab/user_notifications.html Fri Mar 17 12:37:01 2017 +0100 @@ -1,4 +1,4 @@ -{% extends 'iconolab_base.html' %} +{% extends 'iconolab/user_base.html' %} {% load staticfiles %} @@ -8,57 +8,51 @@ {% load notifications_tags %} -{% block content %} -
-
-
-

Mes notifications :

- {% if notifications %} - +{% block user_content %} +

Mes notifications

+ {% if notifications %} + - {% if notifications.has_previous or notifications.has_next %} -
    - {% if notifications.has_previous %} -
  • - - - -
  • - {% endif %} - {% for page in notifications.paginator.page_range %} - - {% endfor %} - {% if notifications.has_next %} -
  • - - - -
  • - {% endif %} -
- {% endif %} - {% endif %} -
-
-
+ {% if notifications.has_previous or notifications.has_next %} +
    + {% if notifications.has_previous %} +
  • + + + +
  • + {% endif %} + {% for page in notifications.paginator.page_range %} + + {% endfor %} + {% if notifications.has_next %} +
  • + + + +
  • + {% endif %} +
+ {% endif %} + {% endif %} {% endblock %} diff -r de38f6ddaff5 -r fb9bf3f479f1 src/iconolab/templates/iconolab/user_settings.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/iconolab/templates/iconolab/user_settings.html Fri Mar 17 12:37:01 2017 +0100 @@ -0,0 +1,25 @@ +{% extends 'iconolab/user_base.html' %} + +{% block user_content %} +
+ {% csrf_token %} +
+ +
+ + {% if user_form.email.errors %} + {{ user_form.email.errors | striptags }} + {% else %} + Spécifiez votre email pour recevoir des notifications + {% endif %} +
+
+
+
+ +
+
+
+{% endblock %} diff -r de38f6ddaff5 -r fb9bf3f479f1 src/iconolab/urls.py --- a/src/iconolab/urls.py Thu Mar 16 13:14:44 2017 +0100 +++ b/src/iconolab/urls.py Fri Mar 17 12:37:01 2017 +0100 @@ -50,6 +50,8 @@ url(r'^user/(?P[a-z0-9\-]+)/annotations/?$', views.userpages.UserAnnotationsView.as_view(), name="user_annotations"), url(r'^user/(?P[a-z0-9\-]+)/adminpanel/(?P[a-z0-9\-]+)/$', views.userpages.UserCollectionAdminView.as_view(), name="user_admin_panel"), url(r'^user/notifications/all/?$', login_required(views.userpages.UserNotificationsView.as_view()), name="user_notifications"), + url(r'^user/settings/?$', login_required(views.userpages.UserSettingsView.as_view()), name="user_settings"), + url(r'^user/collections/?$', login_required(views.userpages.UserCollectionsView.as_view()), name="user_collections"), url(r'^user/notifications/', include(notifications.urls, namespace='notifications')), url(r'^errors/404', views.misc.NotFoundErrorView.as_view(), name="404error"), diff -r de38f6ddaff5 -r fb9bf3f479f1 src/iconolab/views/userpages.py --- a/src/iconolab/views/userpages.py Thu Mar 16 13:14:44 2017 +0100 +++ b/src/iconolab/views/userpages.py Fri Mar 17 12:37:01 2017 +0100 @@ -44,7 +44,6 @@ def get(self, request, *args, **kwargs): self.object = self.get_object() context = self.get_context_data() - context['user_form'] = UserForm(instance=request.user) if request.user.is_authenticated() and self.object == request.user: if request.GET.get('clear_notifications', False): @@ -54,21 +53,6 @@ return render(request, 'iconolab/user_home.html', context) - def post(self, request, *args, **kwargs): - self.object = self.get_object() - context = self.get_context_data() - - user_form = UserForm(data=request.POST, instance=request.user) - context['user_form'] = user_form - - if request.user.is_authenticated() and self.object == request.user: - if user_form.is_valid(): - user = user_form.save(commit=False) - user.save() - return redirect(reverse('user_home', kwargs={'slug': user.id})) - - return render(request, 'iconolab/user_home.html', context) - class UserNotificationsView(View): """ View that displays the notifications the user received @@ -77,6 +61,7 @@ context = {} notifications = Notification.objects.filter(recipient=request.user) context['notifications_unread_ids'] = notifications.unread().values_list('id', flat=True) + context['profile_user'] = request.user page = request.GET.get('page', 1) paginator = Paginator(notifications, 50) try: @@ -273,3 +258,34 @@ logger.debug(ordering) logger.debug(annotation_queryset) return render(request, 'iconolab/user_collection_admin.html', context) + +class UserSettingsView(View): + + def get(self, request, *args, **kwargs): + context = {} + context['profile_user'] = request.user + context['user_form'] = UserForm(instance=request.user) + + return render(request, 'iconolab/user_settings.html', context) + + def post(self, request, *args, **kwargs): + context = {} + context['profile_user'] = request.user + + user_form = UserForm(data=request.POST, instance=request.user) + if user_form.is_valid(): + user = user_form.save(commit=False) + user.save() + return redirect(reverse('user_settings', kwargs={'slug': user.id})) + + context['user_form'] = user_form + + return render(request, 'iconolab/user_settings.html', context) + +class UserCollectionsView(View): + + def get(self, request, *args, **kwargs): + context = {} + context['profile_user'] = request.user + + return render(request, 'iconolab/user_collections.html', context)