collections in fragment and image page. debug delete fragment.
Binary file src/egonomy/locale/en/LC_MESSAGES/django.mo has changed
--- a/src/egonomy/locale/en/LC_MESSAGES/django.po Fri Jul 12 14:59:52 2013 +0200
+++ b/src/egonomy/locale/en/LC_MESSAGES/django.po Mon Jul 15 18:00:57 2013 +0200
@@ -8,7 +8,7 @@
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-07-12 05:48-0500\n"
+"POT-Creation-Date: 2013-07-15 10:51-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -25,19 +25,24 @@
msgid "English"
msgstr ""
-#: views.py:106 views.py:130
+#: views.py:114 views.py:138
msgid "You are not allowed to modify this fragment."
msgstr ""
-#: views.py:332
+#: views.py:340
msgid "You are not allowed to delete this fragment."
msgstr ""
-#: views.py:586
+#: views.py:344
+msgid ""
+"You can not delete this fragment, it is used in one or several collections."
+msgstr ""
+
+#: views.py:598
msgid "You are not allowed to delete this collection."
msgstr ""
-#: views.py:616 templates/egonomy_annotate_picture.html:14
+#: views.py:630 templates/egonomy_annotate_picture.html:14
#: templates/egonomy_create_fragment.html:14
#: templates/egonomy_create_fragment.html:77
#: templates/egonomy_view_fragment.html:100
@@ -47,7 +52,7 @@
msgid "No title"
msgstr ""
-#: views.py:654 views.py:708 views.py:743
+#: views.py:668 views.py:722 views.py:757
msgid "You are not allowed to modify this collection."
msgstr ""
@@ -193,18 +198,24 @@
msgid "No fragment"
msgstr ""
-#: templates/egonomy_annotate_picture.html:136
-#: templates/egonomy_create_fragment.html:138
-#: templates/egonomy_view_fragment.html:185
-msgid "No collection"
+#: templates/egonomy_annotate_picture.html:135
+msgid "Collections including this picture"
msgstr ""
-#: templates/egonomy_base.html:36 templates/egonomy_view_collection.html:76
+#: templates/egonomy_annotate_picture.html:142 templates/egonomy_base.html:36
+#: templates/egonomy_view_collection.html:76
#: templates/egonomy_view_fragment.html:112
+#: templates/egonomy_view_fragment.html:191
#: templates/partial/collection_in_list.html:21
msgid "by"
msgstr ""
+#: templates/egonomy_annotate_picture.html:147
+#: templates/egonomy_create_fragment.html:138
+#: templates/egonomy_view_fragment.html:196
+msgid "No collection"
+msgstr ""
+
#: templates/egonomy_base.html:38 templates/egonomy_newbase.html:74
#: templates/egonomy_view_collection.html:183
msgid "Search"
@@ -369,6 +380,10 @@
msgstr ""
#: templates/egonomy_view_collection.html:93
+#: templates/partial/item_in_collection_list.html:35
+#: templates/partial/item_in_collection_list.html:93
+#: templates/partial/item_in_collection_mosaic.html:39
+#: templates/partial/item_in_collection_mosaic.html:81
msgid "Modify the item's comment"
msgstr ""
@@ -438,6 +453,10 @@
msgid "See the fragment only"
msgstr ""
+#: templates/egonomy_view_fragment.html:184
+msgid "Collections including this fragment"
+msgstr ""
+
#: templates/partial/fragment_in_list.html:15
msgid "Fragment from"
msgstr ""
Binary file src/egonomy/locale/fr/LC_MESSAGES/django.mo has changed
--- a/src/egonomy/locale/fr/LC_MESSAGES/django.po Fri Jul 12 14:59:52 2013 +0200
+++ b/src/egonomy/locale/fr/LC_MESSAGES/django.po Mon Jul 15 18:00:57 2013 +0200
@@ -8,7 +8,7 @@
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-07-12 05:48-0500\n"
+"POT-Creation-Date: 2013-07-15 10:51-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -26,20 +26,26 @@
msgid "English"
msgstr "Anglais"
-#: views.py:106
-#: views.py:130
+#: views.py:114
+#: views.py:138
msgid "You are not allowed to modify this fragment."
msgstr "Vous n'êtes pas autorisé à modifier ce fragment."
-#: views.py:332
+#: views.py:340
msgid "You are not allowed to delete this fragment."
msgstr "Vous n'êtes pas autorisé à supprimer ce fragment."
-#: views.py:586
+#: views.py:344
+msgid ""
+"You can not delete this fragment, it is used in one or several collections."
+msgstr "Vous ne pouvez pas supprimer ce fragment, il est utilisé dans une ou "
+"plusieurs collections."
+
+#: views.py:598
msgid "You are not allowed to delete this collection."
msgstr "Vous n'êtes pas autorisé à supprimer cette collection."
-#: views.py:616
+#: views.py:630
#: templates/egonomy_annotate_picture.html:14
#: templates/egonomy_create_fragment.html:14
#: templates/egonomy_create_fragment.html:77
@@ -50,9 +56,9 @@
msgid "No title"
msgstr "Sans titre"
-#: views.py:654
-#: views.py:708
-#: views.py:743
+#: views.py:668
+#: views.py:722
+#: views.py:757
msgid "You are not allowed to modify this collection."
msgstr "Vous n'êtes pas autorisé à modifier cette collection."
@@ -202,19 +208,25 @@
msgid "No fragment"
msgstr "Pas de fragment"
-#: templates/egonomy_annotate_picture.html:136
-#: templates/egonomy_create_fragment.html:138
-#: templates/egonomy_view_fragment.html:185
-msgid "No collection"
-msgstr "Pas de collection"
+#: templates/egonomy_annotate_picture.html:135
+msgid "Collections including this picture"
+msgstr "Collections incluant cette image"
+#: templates/egonomy_annotate_picture.html:142
#: templates/egonomy_base.html:36
#: templates/egonomy_view_collection.html:76
#: templates/egonomy_view_fragment.html:112
+#: templates/egonomy_view_fragment.html:191
#: templates/partial/collection_in_list.html:21
msgid "by"
msgstr "par"
+#: templates/egonomy_annotate_picture.html:147
+#: templates/egonomy_create_fragment.html:138
+#: templates/egonomy_view_fragment.html:196
+msgid "No collection"
+msgstr "Pas de collection"
+
#: templates/egonomy_base.html:38
#: templates/egonomy_newbase.html:74
#: templates/egonomy_view_collection.html:183
@@ -383,6 +395,10 @@
msgstr "Visible pour tout le monde"
#: templates/egonomy_view_collection.html:93
+#: templates/partial/item_in_collection_list.html:35
+#: templates/partial/item_in_collection_list.html:93
+#: templates/partial/item_in_collection_mosaic.html:39
+#: templates/partial/item_in_collection_mosaic.html:81
msgid "Modify the item's comment"
msgstr "Modifier le commentaire de cet élément"
@@ -454,6 +470,10 @@
msgid "See the fragment only"
msgstr "Voir le fragment seul"
+#: templates/egonomy_view_fragment.html:184
+msgid "Collections including this fragment"
+msgstr "Collections incluant ce fragment"
+
#: templates/partial/fragment_in_list.html:15
msgid "Fragment from"
msgstr "Fragment de"
--- a/src/egonomy/static/egonomy/css/style.css Fri Jul 12 14:59:52 2013 +0200
+++ b/src/egonomy/static/egonomy/css/style.css Mon Jul 15 18:00:57 2013 +0200
@@ -302,14 +302,14 @@
.subcol-seventh {
width: 110px; margin-left: 12px;
}
-
.subcol-seventh:nth-child(even) {
margin-left: 13px;
}
-
.subcol-seventh:nth-child(7n+1) {
margin-left: 0; clear: left;
}
+.subcol-seventh h3 { color:#000000; }
+.subcol-seventh p { color:#777777; }
.center-image {
text-align: center;
}
--- a/src/egonomy/templates/egonomy_annotate_picture.html Fri Jul 12 14:59:52 2013 +0200
+++ b/src/egonomy/templates/egonomy_annotate_picture.html Mon Jul 15 18:00:57 2013 +0200
@@ -132,8 +132,20 @@
{% endif %}
</div>
<div class="box-edition">
- <h3>Collections liées à cette image :</h3>
+ <h3>{% trans "Collections including this picture" %} :</h3>
+ {% if related_collections %}
+ <ul class="fullwidth clearfix">
+ {% for c in related_collections %}
+ <li class="subcol subcol-seventh">
+ <a href="{% url 'view_collection' collection_pk=c.pk %}">
+ <h3>{{ c.title }}</h3></a>
+ <p>{% trans "by" %} <strong><a href="{% url 'user_collections' username=c.author %}">{{ c.author }}</a></strong></p>
+ </li>
+ {% endfor %}
+ </ul>
+ {% else %}
<p class="null">{% trans "No collection" %}</p>
+ {% endif %}
</div>
</article>
{% endblock %}
--- a/src/egonomy/templates/egonomy_view_fragment.html Fri Jul 12 14:59:52 2013 +0200
+++ b/src/egonomy/templates/egonomy_view_fragment.html Mon Jul 15 18:00:57 2013 +0200
@@ -147,7 +147,7 @@
<table>
<tbody>
<tr>
- <th class="va-top">{% trans "Fragment's keywords" %}</th>
+ <th class="va-top">{% trans "Fragment's keywords" %} :</th>
<td>
<ul class="list-key-search no-before list-keywords clearfix">
{% for t in fragment.tag_list %}
@@ -181,8 +181,20 @@
{% endif %}
</div>
<div class="box-edition">
- <h3>Collections liées à cette image :</h3>
+ <h3>{% trans "Collections including this fragment" %} :</h3>
+ {% if related_collections %}
+ <ul class="fullwidth clearfix">
+ {% for c in related_collections %}
+ <li class="subcol subcol-seventh">
+ <a href="{% url 'view_collection' collection_pk=c.pk %}">
+ <h3>{{ c.title }}</h3></a>
+ <p>{% trans "by" %} <strong><a href="{% url 'user_collections' username=c.author %}">{{ c.author }}</a></strong></p>
+ </li>
+ {% endfor %}
+ </ul>
+ {% else %}
<p class="null">{% trans "No collection" %}</p>
+ {% endif %}
</div>
</article>
{% endblock %}
--- a/src/egonomy/views.py Fri Jul 12 14:59:52 2013 +0200
+++ b/src/egonomy/views.py Mon Jul 15 18:00:57 2013 +0200
@@ -63,9 +63,13 @@
if nb_results:
nb_results = int(nb_results)
+ # Get collections
+ related_collections = Collection.objects.filter(public=True, pk__in=CollectionItem.objects.filter(content_type=ContentType.objects.get_for_model(img), object_id=img.id).values_list('collection', flat=True)).select_related('author')
+
return render_to_response("egonomy_annotate_picture.html",
{'img': img, 'fragment_list': frg_list, 'last_frg':last_frg,
'search': search, 'index_search': index_search, 'nb_results': nb_results,
+ 'related_collections':related_collections,
'current_user_collection_list':current_user_collection_list(request)},
context_instance=RequestContext(request))
@@ -86,9 +90,13 @@
if nb_results:
nb_results = int(nb_results)
+ # Get collections
+ related_collections = Collection.objects.filter(public=True, pk__in=CollectionItem.objects.filter(content_type=ContentType.objects.get_for_model(frg), object_id=str(frg.pk)).values_list('collection', flat=True)).select_related('author')
+
return render_to_response("egonomy_view_fragment.html",
{'fragment': frg, 'fragment_list': frg_list, 'fragment_only':fragment_only,
'search': search, 'index_search': index_search, 'nb_results': nb_results,
+ 'related_collections':related_collections,
'current_user_collection_list':current_user_collection_list(request)},
context_instance=RequestContext(request))
@@ -330,6 +338,10 @@
# We check if the current user is the fragment's author
if frg.author != request.user:
return HttpResponseForbidden(_("You are not allowed to delete this fragment."))
+ # We check if the fragment is not part of a collection
+ nb_items = CollectionItem.objects.filter(content_type=ContentType.objects.get_for_model(frg), object_id=str(frg.pk)).count()
+ if nb_items > 0:
+ return HttpResponseForbidden(_("You can not delete this fragment, it is used in one or several collections."))
# Delete the fragment
frg.delete()
if "next" in request.GET:
@@ -603,21 +615,23 @@
for item in items:
if item.content_type.model == "fragment":
fragment = item.content_object
- slides.append({"type":"fragment",
- "title": fragment.title,
- "author": str(fragment.author),
- "src": fragment.image.info.image_file.url,
- "path": fragment.coordinates,
- "description": item.description
- })
+ if fragment:
+ slides.append({"type":"fragment",
+ "title": fragment.title,
+ "author": str(fragment.author),
+ "src": fragment.image.info.image_file.url,
+ "path": fragment.coordinates,
+ "description": item.description
+ })
elif item.content_type.model == "image":
image = item.content_object
- slides.append({"type":"image",
- "title": image.metadata.titre or _('No title'),
- "author": image.metadata.auteur or "",
- "src": image.info.image_file.url,
- "description": item.description
- })
+ if image:
+ slides.append({"type":"image",
+ "title": image.metadata.titre or _('No title'),
+ "author": image.metadata.auteur or "",
+ "src": image.info.image_file.url,
+ "description": item.description
+ })
return render_to_response("egonomy_embed_slideshow.html",
{'col':col, 'items':items, "slides":json.dumps(slides)},