# HG changeset patch # User durandn # Date 1479208278 -3600 # Node ID 430188380ba80329eac62e5dd6f2c8bd16d08436 # Parent 06c88bfd5c8dd4297d6711cbaf03d72369fe68b2 Added option to assign multiple managed collections on one account + small correction on stats template #41 diff -r 06c88bfd5c8d -r 430188380ba8 src/iconolab/migrations/0015_auto_20161115_1031.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/iconolab/migrations/0015_auto_20161115_1031.py Tue Nov 15 12:11:18 2016 +0100 @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2016-11-15 10:31 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('iconolab', '0014_auto_20161108_1458'), + ] + + operations = [ + migrations.RemoveField( + model_name='userprofile', + name='administers_collection', + ), + migrations.AddField( + model_name='userprofile', + name='managed_collections', + field=models.ManyToManyField(blank=True, related_name='admins', to='iconolab.Collection'), + ), + ] diff -r 06c88bfd5c8d -r 430188380ba8 src/iconolab/models.py --- a/src/iconolab/models.py Mon Nov 14 16:15:26 2016 +0100 +++ b/src/iconolab/models.py Tue Nov 15 12:11:18 2016 +0100 @@ -688,7 +688,7 @@ class UserProfile(models.Model): user = models.OneToOneField(User, related_name='profile', on_delete=models.CASCADE) - administers_collection = models.ForeignKey('Collection', related_name='collection', blank=True, null=True) + managed_collections = models.ManyToManyField('Collection', related_name='admins', blank=True) def __str__(self): return "profile:"+self.user.username \ No newline at end of file diff -r 06c88bfd5c8d -r 430188380ba8 src/iconolab/templates/iconolab/user_home.html --- a/src/iconolab/templates/iconolab/user_home.html Mon Nov 14 16:15:26 2016 +0100 +++ b/src/iconolab/templates/iconolab/user_home.html Tue Nov 15 12:11:18 2016 +0100 @@ -117,17 +117,15 @@ - {% if profile_user == request.user and profile_user.profile.administers_collection %} + {% if profile_user.profile.managed_collections %}
-
- -
- L'accès à ces fonctionnalités n'est pas encore disponible. +
+ {% for collection in profile_user.profile.managed_collections.all %} +

Administration du Fonds {{collection.verbose_name}}

+
+ Tableau de bord
-

Administration du Fonds {{user.profile.administers_collection.verbose_name}}

- + {% endfor %}
{% endif %} diff -r 06c88bfd5c8d -r 430188380ba8 src/iconolab/templates/partials/annotation_stats_panel.html --- a/src/iconolab/templates/partials/annotation_stats_panel.html Mon Nov 14 16:15:26 2016 +0100 +++ b/src/iconolab/templates/partials/annotation_stats_panel.html Tue Nov 15 12:11:18 2016 +0100 @@ -8,7 +8,7 @@
{{ annotation.stats.comments_count }}
{% with annotation.stats.metacategoriescountinfo_set.all as annotation_metacategories_infos %} {% if annotation_metacategories_infos %} -
.. Métacatégories :
+
... Métacatégories :
{% for metacategory_info in annotation_metacategories_infos %} {{metacategory_info.count}} {{metacategory_info.metacategory.label}}
diff -r 06c88bfd5c8d -r 430188380ba8 src/iconolab/templates/partials/image_annotations_list.html --- a/src/iconolab/templates/partials/image_annotations_list.html Mon Nov 14 16:15:26 2016 +0100 +++ b/src/iconolab/templates/partials/image_annotations_list.html Tue Nov 15 12:11:18 2016 +0100 @@ -56,7 +56,7 @@ Espace de travail
Suivre le lien

Etat courant
- Suivre le lien
+ Suivre le lien
{% endif %} diff -r 06c88bfd5c8d -r 430188380ba8 src/iconolab/urls.py --- a/src/iconolab/urls.py Mon Nov 14 16:15:26 2016 +0100 +++ b/src/iconolab/urls.py Tue Nov 15 12:11:18 2016 +0100 @@ -47,7 +47,7 @@ url(r'^user/(?P[a-z0-9\-]+)/commented/?$', views.userpages.UserCommentedView.as_view(), name="user_commented"), url(r'^user/(?P[a-z0-9\-]+)/contributed/?$', views.userpages.UserContributedView.as_view(), name="user_contributed"), url(r'^user/(?P[a-z0-9\-]+)/annotations/?$', views.userpages.UserAnnotationsView.as_view(), name="user_annotations"), - url(r'^user/(?P[a-z0-9\-]+)/adminpanel/$', views.userpages.UserCollectionAdminView.as_view(), name="user_admin_panel"), + 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/notifications/', include(notifications.urls, namespace='notifications')), diff -r 06c88bfd5c8d -r 430188380ba8 src/iconolab/views/userpages.py --- a/src/iconolab/views/userpages.py Mon Nov 14 16:15:26 2016 +0100 +++ b/src/iconolab/views/userpages.py Tue Nov 15 12:11:18 2016 +0100 @@ -9,7 +9,7 @@ from django.conf import settings from django.urls import reverse from notifications.models import Notification -from iconolab.models import Annotation, IconolabComment, Image, MetaCategoriesCountInfo +from iconolab.models import Collection, Annotation, IconolabComment, Image, MetaCategoriesCountInfo from uuid import UUID import logging @@ -157,10 +157,13 @@ self.object = self.get_object() profile_user = self.object context = self.get_context_data() - - if not request.user.is_staff and not request.user.is_authenticated or profile_user != request.user or not request.user.profile.administers_collection: + collection_name = kwargs.get("collection_name") + collection_qs = Collection.objects.filter(name=collection_name) + if not request.user.is_staff and not request.user.is_authenticated or profile_user != request.user or not collection_qs.exists(): return redirect(reverse_lazy('user_home', kwargs={'slug': profile_user.id})) - collection = request.user.profile.administers_collection + collection = collection_qs.first() + if collection not in profile_user.profile.managed_collections.all(): + return redirect(reverse_lazy('user_home', kwargs={'slug': profile_user.id})) annotation_queryset = Annotation.objects.distinct().filter(image__item__collection=collection).prefetch_related('current_revision', 'stats', 'image', 'image__item')