collection parameters with title, delete collection, ajax add item
authorcavaliet
Mon, 01 Jul 2013 17:38:34 +0200
changeset 211 35aca8206b40
parent 210 dd0e7cded39d
child 212 2cca82dd0e79
collection parameters with title, delete collection, ajax add item
src/egonomy/locale/en/LC_MESSAGES/django.mo
src/egonomy/locale/en/LC_MESSAGES/django.po
src/egonomy/locale/fr/LC_MESSAGES/django.mo
src/egonomy/locale/fr/LC_MESSAGES/django.po
src/egonomy/static/egonomy/js/main.js
src/egonomy/templates/egonomy_all_collections.html
src/egonomy/templates/egonomy_newbase.html
src/egonomy/templates/egonomy_view_collection.html
src/egonomy/urls.py
src/egonomy/views.py
Binary file src/egonomy/locale/en/LC_MESSAGES/django.mo has changed
--- a/src/egonomy/locale/en/LC_MESSAGES/django.po	Mon Jul 01 16:31:47 2013 +0200
+++ b/src/egonomy/locale/en/LC_MESSAGES/django.po	Mon Jul 01 17:38:34 2013 +0200
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-06-28 08:44-0500\n"
+"POT-Creation-Date: 2013-07-01 10:32-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"
@@ -33,8 +33,13 @@
 msgid "You are not allowed to delete this fragment."
 msgstr ""
 
+#: views.py:490
+msgid "You are not allowed to delete this collection."
+msgstr ""
+
 #: templates/egonomy_all_collections.html:7
-msgid "All collection"
+#: templates/egonomy_all_collections.html:47
+msgid "All collections"
 msgstr ""
 
 #: templates/egonomy_all_collections.html:20
@@ -43,6 +48,8 @@
 msgstr ""
 
 #: templates/egonomy_all_collections.html:26
+#: templates/egonomy_view_collection.html:22
+#: templates/egonomy_view_collection.html:24
 msgid "Title"
 msgstr ""
 
@@ -52,10 +59,12 @@
 msgstr ""
 
 #: templates/egonomy_all_collections.html:34 templates/egonomy_newbase.html:48
+#: templates/egonomy_view_collection.html:85
 msgid "Cancel"
 msgstr ""
 
 #: templates/egonomy_all_collections.html:35 templates/egonomy_newbase.html:49
+#: templates/egonomy_view_collection.html:86
 msgid "Submit"
 msgstr ""
 
@@ -66,10 +75,6 @@
 msgstr[0] ""
 msgstr[1] ""
 
-#: templates/egonomy_all_collections.html:47
-msgid "All collections"
-msgstr ""
-
 #: templates/egonomy_all_fragments.html:7
 #: templates/egonomy_all_fragments.html:29
 #: templates/egonomy_all_fragments.html:34 templates/egonomy_home.html:33
@@ -185,21 +190,22 @@
 msgid "No collection"
 msgstr ""
 
-#: templates/egonomy_base.html:36 templates/egonomy_view_fragment.html:100
+#: templates/egonomy_base.html:36 templates/egonomy_view_collection.html:76
+#: templates/egonomy_view_fragment.html:100
 #: templates/partial/collection_in_list.html:21
 msgid "by"
 msgstr ""
 
-#: templates/egonomy_base.html:38 templates/egonomy_newbase.html:67
-#: templates/egonomy_view_collection.html:138
+#: templates/egonomy_base.html:38 templates/egonomy_newbase.html:74
+#: templates/egonomy_view_collection.html:159
 msgid "Search"
 msgstr ""
 
-#: templates/egonomy_base.html:47 templates/egonomy_newbase.html:81
+#: templates/egonomy_base.html:47 templates/egonomy_newbase.html:88
 msgid "Log out"
 msgstr ""
 
-#: templates/egonomy_base.html:49 templates/egonomy_newbase.html:83
+#: templates/egonomy_base.html:49 templates/egonomy_newbase.html:90
 msgid "Log in"
 msgstr ""
 
@@ -285,23 +291,35 @@
 msgid "Image comment"
 msgstr ""
 
-#: templates/egonomy_newbase.html:79
+#: templates/egonomy_newbase.html:57
+msgid "The item was successfully added to the collection"
+msgstr ""
+
+#: templates/egonomy_newbase.html:58
+msgid "See the collection"
+msgstr ""
+
+#: templates/egonomy_newbase.html:61
+msgid "An error occurred while adding the item to the collection"
+msgstr ""
+
+#: templates/egonomy_newbase.html:86
 msgid "Hello"
 msgstr ""
 
-#: templates/egonomy_newbase.html:88
+#: templates/egonomy_newbase.html:95
 msgid "explore"
 msgstr ""
 
-#: templates/egonomy_newbase.html:90
+#: templates/egonomy_newbase.html:97
 msgid "collect"
 msgstr ""
 
-#: templates/egonomy_newbase.html:98
+#: templates/egonomy_newbase.html:105
 msgid "my collections"
 msgstr ""
 
-#: templates/egonomy_newbase.html:100
+#: templates/egonomy_newbase.html:107
 msgid "my fragments"
 msgstr ""
 
@@ -309,19 +327,61 @@
 msgid "View a collection"
 msgstr ""
 
-#: templates/egonomy_view_collection.html:100
+#: templates/egonomy_view_collection.html:28
+msgid "Thumbnail"
+msgstr ""
+
+#: templates/egonomy_view_collection.html:32
+msgid "List"
+msgstr ""
+
+#: templates/egonomy_view_collection.html:33
+msgid "Mosaic"
+msgstr ""
+
+#: templates/egonomy_view_collection.html:34
+msgid "Slideshow"
+msgstr ""
+
+#: templates/egonomy_view_collection.html:35
+msgid "Geographical"
+msgstr ""
+
+#: templates/egonomy_view_collection.html:41
+msgid "Availability"
+msgstr ""
+
+#: templates/egonomy_view_collection.html:45
+msgid "Visible by me only"
+msgstr ""
+
+#: templates/egonomy_view_collection.html:46
+msgid "Visible for everyone"
+msgstr ""
+
+#: templates/egonomy_view_collection.html:114
 msgid "Display"
 msgstr ""
 
-#: templates/egonomy_view_collection.html:101
+#: templates/egonomy_view_collection.html:115
 msgid "Hide"
 msgstr ""
 
-#: templates/egonomy_view_collection.html:101
+#: templates/egonomy_view_collection.html:115
 msgid "the comments"
 msgstr ""
 
-#: templates/egonomy_view_collection.html:106
+#: templates/egonomy_view_collection.html:123
+msgid ""
+"Do you really want to delete this collection ? Warning : this action est "
+"irreversible."
+msgstr ""
+
+#: templates/egonomy_view_collection.html:123
+msgid "Delete this collection"
+msgstr ""
+
+#: templates/egonomy_view_collection.html:125
 msgid "Collection parameters"
 msgstr ""
 
Binary file src/egonomy/locale/fr/LC_MESSAGES/django.mo has changed
--- a/src/egonomy/locale/fr/LC_MESSAGES/django.po	Mon Jul 01 16:31:47 2013 +0200
+++ b/src/egonomy/locale/fr/LC_MESSAGES/django.po	Mon Jul 01 17:38:34 2013 +0200
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-06-28 08:46-0500\n"
+"POT-Creation-Date: 2013-07-01 10:32-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"
@@ -35,6 +35,10 @@
 msgid "You are not allowed to delete this fragment."
 msgstr "Vous n'êtes pas autorisé à supprimer ce fragment."
 
+#: views.py:490
+msgid "You are not allowed to delete this collection."
+msgstr "Vous n'êtes pas autorisé à supprimer cette collection."
+
 #: templates/egonomy_all_collections.html:7
 #: templates/egonomy_all_collections.html:47
 msgid "All collections"
@@ -46,6 +50,8 @@
 msgstr "Nouvelle collection"
 
 #: templates/egonomy_all_collections.html:26
+#: templates/egonomy_view_collection.html:22
+#: templates/egonomy_view_collection.html:24
 msgid "Title"
 msgstr "Titre"
 
@@ -56,11 +62,13 @@
 
 #: templates/egonomy_all_collections.html:34
 #: templates/egonomy_newbase.html:48
+#: templates/egonomy_view_collection.html:85
 msgid "Cancel"
 msgstr "Annuler"
 
 #: templates/egonomy_all_collections.html:35
 #: templates/egonomy_newbase.html:49
+#: templates/egonomy_view_collection.html:86
 msgid "Submit"
 msgstr "Envoyer"
 
@@ -189,24 +197,25 @@
 msgstr "Pas de collection"
 
 #: templates/egonomy_base.html:36
+#: templates/egonomy_view_collection.html:76
 #: templates/egonomy_view_fragment.html:100
 #: templates/partial/collection_in_list.html:21
 msgid "by"
 msgstr "par"
 
 #: templates/egonomy_base.html:38
-#: templates/egonomy_newbase.html:67
-#: templates/egonomy_view_collection.html:138
+#: templates/egonomy_newbase.html:74
+#: templates/egonomy_view_collection.html:159
 msgid "Search"
 msgstr "Rechercher"
 
 #: templates/egonomy_base.html:47
-#: templates/egonomy_newbase.html:81
+#: templates/egonomy_newbase.html:88
 msgid "Log out"
 msgstr "Se déconnecter"
 
 #: templates/egonomy_base.html:49
-#: templates/egonomy_newbase.html:83
+#: templates/egonomy_newbase.html:90
 msgid "Log in"
 msgstr "Se connecter"
 
@@ -292,23 +301,35 @@
 msgid "Image comment"
 msgstr "Commentaire de l'image"
 
-#: templates/egonomy_newbase.html:79
+#: templates/egonomy_newbase.html:57
+msgid "The item was successfully added to the collection"
+msgstr "L'élément a été ajouté avec succès à la collection"
+
+#: templates/egonomy_newbase.html:58
+msgid "See the collection"
+msgstr "Voir la collection"
+
+#: templates/egonomy_newbase.html:61
+msgid "An error occurred while adding the item to the collection"
+msgstr "Une erreur est survenue pendant l'ajout de l'élément à la collection"
+
+#: templates/egonomy_newbase.html:86
 msgid "Hello"
 msgstr "Bonjour"
 
-#: templates/egonomy_newbase.html:88
+#: templates/egonomy_newbase.html:95
 msgid "explore"
 msgstr "explorer"
 
-#: templates/egonomy_newbase.html:90
+#: templates/egonomy_newbase.html:97
 msgid "collect"
 msgstr "collectionner"
 
-#: templates/egonomy_newbase.html:98
+#: templates/egonomy_newbase.html:105
 msgid "my collections"
 msgstr "mes collections"
 
-#: templates/egonomy_newbase.html:100
+#: templates/egonomy_newbase.html:107
 msgid "my fragments"
 msgstr "mes fragments"
 
@@ -316,19 +337,62 @@
 msgid "View a collection"
 msgstr "Voir une collection"
 
-#: templates/egonomy_view_collection.html:100
+#: templates/egonomy_view_collection.html:28
+msgid "Thumbnail"
+msgstr "Vignette"
+
+#: templates/egonomy_view_collection.html:32
+msgid "List"
+msgstr "Liste"
+
+#: templates/egonomy_view_collection.html:33
+msgid "Mosaic"
+msgstr "Mosaïque"
+
+#: templates/egonomy_view_collection.html:34
+msgid "Slideshow"
+msgstr "Diaporama"
+
+#: templates/egonomy_view_collection.html:35
+msgid "Geographical"
+msgstr "Géographique"
+
+#: templates/egonomy_view_collection.html:41
+msgid "Availability"
+msgstr "Disponibilité"
+
+#: templates/egonomy_view_collection.html:45
+msgid "Visible by me only"
+msgstr "Visible par moi seulement"
+
+#: templates/egonomy_view_collection.html:46
+msgid "Visible for everyone"
+msgstr "Visible pour tout le monde"
+
+#: templates/egonomy_view_collection.html:114
 msgid "Display"
 msgstr "Afficher"
 
-#: templates/egonomy_view_collection.html:101
+#: templates/egonomy_view_collection.html:115
 msgid "Hide"
 msgstr "Masquer"
 
-#: templates/egonomy_view_collection.html:101
+#: templates/egonomy_view_collection.html:115
 msgid "the comments"
 msgstr "les commentaires"
 
-#: templates/egonomy_view_collection.html:106
+#: templates/egonomy_view_collection.html:123
+msgid ""
+"Do you really want to delete this collection ? Warning : this action est "
+"irreversible."
+msgstr "Voulez-vous vraiment supprimer cette collection ? Attention : cette action est "
+"irréversible."
+
+#: templates/egonomy_view_collection.html:123
+msgid "Delete this collection"
+msgstr "Supprimer cette collection"
+
+#: templates/egonomy_view_collection.html:125
 msgid "Collection parameters"
 msgstr "Paramètres de la collection"
 
--- a/src/egonomy/static/egonomy/js/main.js	Mon Jul 01 16:31:47 2013 +0200
+++ b/src/egonomy/static/egonomy/js/main.js	Mon Jul 01 17:38:34 2013 +0200
@@ -64,17 +64,17 @@
 	        url: formel.attr("action"),
 	        type: formel.attr("method"),
 	        data: formel.serialize(),
-	        success: function() {
+	        success: function(text) {
                 $('.popin-wrap').fadeIn(function(){
                     $(".additem-success").show();
                 });
-	            console.log.apply(console,arguments);
+	            //console.log("received : " + text);
+                $(".additem-success .collection-url").attr("href", text);
 	        },
             error: function() {
                 $('.popin-wrap').fadeIn(function(){
                     $(".additem-error").show();
                 });
-                console.log.apply(console,arguments);
             }
 	    });
 	    formel.parents(".popin").hide();
--- a/src/egonomy/templates/egonomy_all_collections.html	Mon Jul 01 16:31:47 2013 +0200
+++ b/src/egonomy/templates/egonomy_all_collections.html	Mon Jul 01 17:38:34 2013 +0200
@@ -21,7 +21,7 @@
                 <a href="#" class="close-popin"></a>
             </header>
             <section>
-                <form action="{% url 'new_collection' %}" method="POST">
+                <form action="{% url 'save_collection' %}" method="POST">
                     <p>
                         <label for="collection-title">{% trans "Title" %} :</label>
                         <input type="text" name="collection-title" id="collection-title">
@@ -53,7 +53,7 @@
             {% if nb_pages > 1 %}{% build_pagination nb_pages cur_page_nb url_pagination "clickable" %}{% endif %}
             <ul class="list-style-2 clearfix no-border-bot">
               {% for col in results %}
-                <li>
+                <li class="subcol-fourth">
                 {% include "partial/collection_in_list.html" %}
                 </li>
               {% endfor %}
--- a/src/egonomy/templates/egonomy_newbase.html	Mon Jul 01 16:31:47 2013 +0200
+++ b/src/egonomy/templates/egonomy_newbase.html	Mon Jul 01 17:38:34 2013 +0200
@@ -33,7 +33,7 @@
                     <p>
                         <label for="collection-name">{% trans "Add to" %} :</label>
                         <label class="styled-select">
-                            <select name="collection-pk">
+                            <select name="collection-pk" id="collection-pk">
                               {% for c in current_user_collection_list %}
                                 <option value="{{ c.pk }}">{{ c.title }}</option>
                               {% endfor %}
@@ -55,9 +55,10 @@
         </div>
         <div class="popin additem-success box-shadow">
             <h2>{% trans "The item was successfully added to the collection" %}</h2>
+            <h2><a class="collection-url" href="#">{% trans "See the collection" %}</a></h2>
         </div>
         <div class="popin additem-error box-shadow">
-            <h2>{% trans "An error occurred while addin the item to the collection" %}</h2>
+            <h2>{% trans "An error occurred while adding the item to the collection" %}</h2>
         </div>
       {% endif %}
       {% block popins %}{% endblock %}
--- a/src/egonomy/templates/egonomy_view_collection.html	Mon Jul 01 16:31:47 2013 +0200
+++ b/src/egonomy/templates/egonomy_view_collection.html	Mon Jul 01 17:38:34 2013 +0200
@@ -5,63 +5,75 @@
 {% block title %}{% trans "View a collection" %}{% endblock %}
 
 {% block popins %}
+    {% if user.is_authenticated %}
+      {% ifequal user col.author %}
         <div id="collection-parameters" class="popin big-popin box-shadow">
             <header>
                 <h2>PARAMÈTRES DE LA COLLECTION</h2>
                 <a href="#" class="close-popin"></a>
             </header>
             <section>
-                <form action="#">
+                <form action="{% url 'save_collection' %}" method="POST">
                     <div class="col-left">
+                        <input name="collection-pk" type="hidden" value="{{ col.pk }}">
                         <table>
                             <tbody>
                                 <tr>
-                                    <th>Vignette :</th>
+                                    <th><label for="collection-title">{% trans "Title" %} :</label></th>
+                                    <td>
+                                        <input name="collection-title" id="collection-title" class="w-194" type="text" placeholder="{% trans 'Title' %}" value="{{ col.title }}">
+                                    </td>
+                                </tr>
+                                <tr>
+                                    <th><label for="collection-publication-type">{% trans "Thumbnail" %} :</label></th>
                                     <td>
                                         <label class="no-margin styled-select">
-                                            <select class="w-192">
-                                                <option selected value="">Mosaïque</option>
-                                                <option value="/egonomy/allfragments/">Argumentaire</option>
+                                            <select name="collection-publication-type" id="collection-publication-type" class="w-192">
+                                                <option selected value="1">{% trans "List" %}</option>
+                                                <option value="2">{% trans "Mosaic" %}</option>
+                                                <option value="3">{% trans "Slideshow" %}</option>
+                                                <!--option value="4">{% trans "Geographical" %}</option-->
                                             </select>
                                         </label>
                                     </td>
                                 </tr>
                                 <tr>
-                                    <th>Visibilité :</th>
+                                    <th><label for="collection-public">{% trans "Availability" %} :</label></th>
                                     <td>
                                         <label class="no-margin styled-select">
-                                            <select class="w-192">
-                                                <option selected value="">Visible par moi uniquement</option>
+                                            <select id="collection-public" name="collection-public" class="w-192">
+                                                <option selected value="0">{% trans "Visible by me only" %}</option>
+                                                <option selected value="1">{% trans "Visible for everyone" %}</option>
                                             </select>
                                         </label>
                                     </td>
                                 </tr>
-                                <tr>
+                                <!--tr>
                                     <th><label for="share-collection">Partager :</label></th>
                                     <td>
                                         <input id="share-collection" class="w-194" type="text" placeholder="http://">
                                     </td>
-                                </tr>
+                                </tr-->
                                 <tr>
-                                    <th colspan="2"><label for="description-collection">Description :</label></th>
+                                    <th colspan="2"><label for="collection-description">Description :</label></th>
                                 </tr>
                                 <tr>
                                     <td colspan="2">
-                                        <textarea name="" id="description-collection"></textarea>
+                                        <textarea name="collection-description" id="collection-description">{{ col.description }}</textarea>
                                     </td>
                                 </tr>
                             </tbody>
                         </table>
                     </div>
-                     <ul class="list-style-2 clearfix">
+                    <ul class="list-style-2 clearfix">
                         <li>
                             <div class="top clearfix">
                                 <img src="{% static 'egonomy/img/empty.gif' %}" width="113px" height="113px" alt="" />
                                 <img src="{% static 'egonomy/img/empty.gif' %}" width="113px" height="113px" alt="" />
                             </div>
                             <div class="mid">
-                                <h3>Collection n°1</h3>
-                                <p>par Hubert Trucchose</p>
+                                <h3>{{ col.title }}</h3>
+                                <p>{% trans "by" %} {{ col.author }}</p>
                             </div>
                             <div class="bot clearfix">
                                 <img src="{% static 'egonomy/img/empty.gif' %}" width="113px" height="113px" alt="" />
@@ -70,12 +82,14 @@
                         </li>
                     </ul>
                     <div class="buttons">
-                        <a href="#" class="btn close-popin">Annuler</a>
-                        <input class="btn" type="submit" value="Valider">
-                    </div>
+                        <a href="#" class="btn close-popin">{% trans "Cancel" %}</a>
+                        <input class="btn" type="submit" value="{% trans 'Submit' %}">
+                    </div>{% csrf_token %}
                 </form>
             </section>
         </div>
+      {% endifequal %}
+    {% endif %}
 {% endblock %}
 
 {% block content %}
@@ -95,15 +109,22 @@
             </div>
             <div class="bar-tools clearfix">
                 <ul class="clearfix">
-                    {% ifequal display "mosaic" %}
+                  {% ifequal display "mosaic" %}
                     <li><a class="toggle-comment" href="#">
                         <span class="show-comment">{% trans "Display" %}</span>
                         <span class="hide-comment">{% trans "Hide" %}</span> {% trans "the comments" %}</a>
                     </li>
-                    {% endifequal %}
+                  {% endifequal %}
                     <!--li><a href="#">lire le diaporama</a></li>
                     <li><a class="icon save" href="#">enregistrer sous</a></li-->
+                  {% if user.is_authenticated %}
+                    {% ifequal user col.author %}
+                    <li>
+                        <a class="icon trash" href="{% url 'delete_collection' %}?collection_pk={{col.pk}}" onclick="return confirm('{% trans "Do you really want to delete this collection ? Warning : this action est irreversible." %}')">{% trans "Delete this collection" %}</a>
+                    </li>
                     <li><a class="open-popin" href="#collection-parameters">{% trans "Collection parameters" %}</a></li>
+                    {% endifequal %}
+                  {% endif %}
                 </ul>
             </div>
         {% if items %}
@@ -151,7 +172,7 @@
 {% endblock %}
 
 {% block js_page %}
-<script type="text/javascript" src="{% static 'egonomy/js/keyword-mosaic.js' %}"></script>
+{% ifequal display "mosaic" %}<script type="text/javascript" src="{% static 'egonomy/js/keyword-mosaic.js' %}"></script>{% endifequal %}
 <script type="text/javascript">
 $(function() {
     $("#search-type-big").change(function() {
--- a/src/egonomy/urls.py	Mon Jul 01 16:31:47 2013 +0200
+++ b/src/egonomy/urls.py	Mon Jul 01 17:38:34 2013 +0200
@@ -21,7 +21,8 @@
     url(r'^deletefragment/$', 'egonomy.views.delete_fragment', name='delete_fragment'),
     url(r'^allcollections/$', 'egonomy.views.all_collections', name='all_collections'),
     url(r'^usercollections/(?P<username>.*)/$', 'egonomy.views.user_collections', name='user_collections'),
-    url(r'^newcollection/$', 'egonomy.views.new_collection', name='new_collection'),
+    url(r'^savecollection/$', 'egonomy.views.save_collection', name='save_collection'),
+    url(r'^deletecollection/$', 'egonomy.views.delete_collection', name='delete_collection'),
     url(r'^viewcollection/(?P<collection_pk>.*)/$', 'egonomy.views.view_collection', name='view_collection'),
     url(r'^additem/$', 'egonomy.views.add_item_to_collection', name='add_item'),
     url(r'^embedslideshow/(?P<collection_pk>.*)/$', 'egonomy.views.embed_slideshow', name='embed_slideshow'),
--- a/src/egonomy/views.py	Mon Jul 01 16:31:47 2013 +0200
+++ b/src/egonomy/views.py	Mon Jul 01 17:38:34 2013 +0200
@@ -422,15 +422,35 @@
 
 
 @login_required
-def new_collection(request):
-        
+def save_collection(request):
+    
+    # Get common datas
     col_title = request.POST["collection-title"]
     col_desc = request.POST["collection-description"]
+    # Get datas available only when we update the collection
+    col_pk = None
+    if "collection-pk" in request.POST:
+        col_pk =  request.POST["collection-pk"]
+    col_publication_type = 1
+    if "collection-publication-type" in request.POST:
+        col_publication_type = int(request.POST["collection-publication-type"])
+    col_public = True
+    if "collection-public" in request.POST:
+        col_public = request.POST["collection-public"]
     
-    col = Collection()
+    if col_pk:
+        # Update existing collection
+        col = get_object_or_404(Collection, pk=col_pk)
+    else:
+        # New collection
+        col = Collection() 
+        col.author = request.user
+    
+    # Save datas
     col.title = col_title
     col.description = col_desc
-    col.author = request.user
+    col.publication_type = col_publication_type
+    col.public = col_public
     col.save()
     
     return redirect("view_collection", collection_pk=col.pk)
@@ -457,6 +477,25 @@
 
 
 
+@login_required
+def delete_collection(request):
+    
+    # Get collection primary key
+    collection_pk = request.GET["collection_pk"]
+    if collection_pk:
+        # Update existing collection
+        col = get_object_or_404(Collection.objects.select_related('author'), pk=collection_pk)
+        # We check if the current user is the collection's author
+        if col.author != request.user:
+            return HttpResponseForbidden(_("You are not allowed to delete this collection."))
+        # Delete the collection
+        col.delete()
+    
+    # Redirect to user's list of collections
+    return redirect("user_collections", username=request.user)
+
+
+
 
 def embed_slideshow(request, collection_pk):
     
@@ -519,6 +558,8 @@
         max_order = 0
     col_item.order = max_order + 1
     col_item.save()
-        
-    return redirect("view_collection", collection_pk=col.pk)
+    
+    #return redirect("view_collection", collection_pk=col.pk)
+    # It is an ajax call, everything is saved and we return the collection's url
+    return HttpResponse(reverse("view_collection", args=[col_pk]))