# HG changeset patch # User durandn # Date 1468424717 -7200 # Node ID 625ed1ba472f9428450df68dabac3ceb6f72cd7b # Parent 4d1e369e85d4f3135fac018ee4c5cde979eded2b Work on item model + item view to show items with multiple images instead of image detail + fix thumbnails in templates diff -r 4d1e369e85d4 -r 625ed1ba472f src/iconolab/models.py --- a/src/iconolab/models.py Mon Jul 11 14:51:49 2016 +0200 +++ b/src/iconolab/models.py Wed Jul 13 17:45:17 2016 +0200 @@ -36,11 +36,12 @@ class Item(models.Model): collection = models.ForeignKey(Collection, related_name="items") + item_guid = models.UUIDField(default=uuid.uuid4, editable=False) class ItemMetadata(models.Model): item = models.OneToOneField('Item', related_name='metadatas') - joconde_ref = models.CharField(max_length=20, null=False, blank=False, unique=True) + joconde_ref = models.CharField(max_length=20) domain = models.CharField(max_length=255) title = models.CharField(max_length=255) description = models.CharField(max_length=255) diff -r 4d1e369e85d4 -r 625ed1ba472f src/iconolab/templates/iconolab/change_annotation.html --- a/src/iconolab/templates/iconolab/change_annotation.html Mon Jul 11 14:51:49 2016 +0200 +++ b/src/iconolab/templates/iconolab/change_annotation.html Wed Jul 13 17:45:17 2016 +0200 @@ -6,7 +6,7 @@ {% block content %} -
+
diff -r 4d1e369e85d4 -r 625ed1ba472f src/iconolab/templates/partials/image_annotations_list.html --- a/src/iconolab/templates/partials/image_annotations_list.html Mon Jul 11 14:51:49 2016 +0200 +++ b/src/iconolab/templates/partials/image_annotations_list.html Wed Jul 13 17:45:17 2016 +0200 @@ -3,33 +3,46 @@
    -

    Annotations de l'image

    - +

    Annotations de l'image

    {% if not annotation_list %}

    Aucune annotation pour cette image

    {% else %} - {% for annotation in annotation_list %} -
  • -
    - {% thumbnail annotation.image.media "x300" crop="center" as im %} - - - - - - -
    - {% endthumbnail %} -
    - Voir -

    Créee par {{ annotation.author }}, dernière révision le {{ annotation.current_revision.created|date:'d-m-Y' }}

    -

    Contributeurs: - {% for contributor in annotation.stats.contributors %} - {{ contributor }}{% if not forloop.last %}, {% endif %} - {% endfor %} -

    -
    -
  • - {% endfor %} + + + + + + + + + + {% for annotation in annotation_list %} + + + + + + + + + {% endfor %} +
    TitreAuteurCréée leRévisée leContributeurs
    +
    + {% thumbnail annotation.image.media "150x150" crop=False as im %} + + + + + + + + + {% endthumbnail %} +
    +
    {{ annotation.current_revision.title }}{{ annotation.author }}{{ annotation.created|date:'d-m-Y' }}{{ annotation.current_revision.created|date:'d-m-Y' }} + {% for contributor in annotation.stats.contributors %} + {{ contributor }}{% if not forloop.last %}, {% endif %} + {% endfor %} +
    {% endif %}
\ No newline at end of file diff -r 4d1e369e85d4 -r 625ed1ba472f src/iconolab/urls.py --- a/src/iconolab/urls.py Mon Jul 11 14:51:49 2016 +0200 +++ b/src/iconolab/urls.py Wed Jul 13 17:45:17 2016 +0200 @@ -28,6 +28,7 @@ url(r'^admin/', admin.site.urls), url(r'^home$', views.GlobalHomepageView.as_view(), name="home"), url(r'^collections/(?P[a-z]+)$', views.CollectionHomepageView.as_view(), name='collection_home'), # Home fond + url(r'^collections/(?P[a-z]+)/items/(?P[^/]+)$', views.ShowItemView.as_view(), name='item_detail'), url(r'^collections/(?P[a-z]+)/images/(?P[^/]+)$', views.ShowImageView.as_view(), name='image_detail'), url(r'^collections/(?P[a-z]+)/images/(?P[^/]+)/annotations/create$', login_required(views.CreateAnnotationView.as_view()), name='annotation_create'), url(r'^collections/(?P[a-z]+)/images/(?P[^/]+)/annotations/(?P[^/]+)/detail$', views.ShowAnnotationView.as_view(), name='annotation_detail'), diff -r 4d1e369e85d4 -r 625ed1ba472f src/iconolab/views.py --- a/src/iconolab/views.py Mon Jul 11 14:51:49 2016 +0200 +++ b/src/iconolab/views.py Wed Jul 13 17:45:17 2016 +0200 @@ -11,7 +11,7 @@ from django.contrib.contenttypes.models import ContentType from django.contrib.sites.models import Site from django.conf import settings -from iconolab.models import Annotation, AnnotationRevision, Collection, Image, IconolabComment, MetaCategory, MetaCategoryInfo +from iconolab.models import Annotation, AnnotationRevision, Collection, Item, Image, IconolabComment, MetaCategory, MetaCategoryInfo from iconolab.forms.annotations import AnnotationRevisionForm import datetime import django_comments @@ -23,7 +23,7 @@ def get(self, request, *args, **kwargs): context = {} context["collections"] = Collection.objects - return render(request, 'iconolab/home.html', context); + return render(request, 'iconolab/home.html', context) class CollectionHomepageView(View, ContextMixin): @@ -43,8 +43,35 @@ context = super(CollectionHomepageView, self).get_context_data(**kwargs) context['collection_name'] = self.kwargs.get('collection_name', '') context['collection'] = collection - return render(request, 'iconolab/collection_home.html', context); + return render(request, 'iconolab/collection_home.html', context) + + +class ShowItemView(View, ContextMixin): + + def check_kwargs(self, kwargs): + try: + collection = Collection.objects.prefetch_related("items", "items__images").get(name=kwargs.get('collection_name')) + except Collection.DoesNotExist: + return False, RedirectView.as_view(url=reverse('404error')) + try: + item = Item.objects.prefetch_related("images").get(item_guid=kwargs.get('item_guid')) + except Item.DoesNotExist: + return False, RedirectView.as_view(url=reverse('404error')) + return True, (collection, item) + + def get(self, request, *args, **kwargs): + success, result = self.check_kwargs(kwargs) + if success: + (collection, item) = result + else: + return result(request) + context = super(ShowItemView, self).get_context_data(**kwargs) + context['collection_name'] = self.kwargs.get('collection_name', '') + context['item_guid'] = self.kwargs.get('image_guid', '') + context['collection'] = collection + context['item'] = item + return render(request, 'iconolab/detail_item.html', context); class ShowImageView(View, ContextMixin): @@ -70,7 +97,7 @@ context['image_guid'] = self.kwargs.get('image_guid', '') context['collection'] = collection context['image'] = image - return render(request, 'iconolab/detail_image.html', context); + return render(request, 'iconolab/detail_image.html', context) class CreateAnnotationView(View, ContextMixin):