Duplicate fragment feature and languages updated
authorcavaliet
Mon, 04 Mar 2013 15:29:30 +0100
changeset 84 b2fbd34b259c
parent 83 f44ce0a08750
child 85 4d320fbfc550
Duplicate fragment feature and languages updated
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/templates/egonomy_create_fragment.html
src/egonomy/templates/egonomy_view_fragment.html
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	Fri Mar 01 12:05:58 2013 +0100
+++ b/src/egonomy/locale/en/LC_MESSAGES/django.po	Mon Mar 04 15:29:30 2013 +0100
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-02-26 09:32-0600\n"
+"POT-Creation-Date: 2013-03-04 08:25-0600\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,7 +25,7 @@
 msgid "English"
 msgstr ""
 
-#: views.py:68 views.py:87
+#: views.py:71 views.py:95
 msgid "You are not allowed to modify this fragment."
 msgstr ""
 
@@ -50,10 +50,10 @@
 msgid "Fragments created by"
 msgstr ""
 
-#: templates/egonomy_all_fragments.html:59
-#: templates/egonomy_annotate_picture.html:123
-#: templates/egonomy_create_fragment.html:184 templates/egonomy_home.html:81
-#: templates/egonomy_view_fragment.html:102
+#: templates/egonomy_all_fragments.html:40
+#: templates/egonomy_annotate_picture.html:102
+#: templates/egonomy_create_fragment.html:163 templates/egonomy_home.html:62
+#: templates/egonomy_view_fragment.html:107
 msgid "Annotated by"
 msgstr ""
 
@@ -66,7 +66,7 @@
 #: templates/egonomy_all_pictures.html:48
 #: templates/egonomy_annotate_picture.html:12
 #: templates/egonomy_create_fragment.html:101 templates/egonomy_home.html:39
-#: templates/egonomy_home.html.py:80 templates/egonomy_view_fragment.html:41
+#: templates/egonomy_home.html.py:61 templates/egonomy_view_fragment.html:38
 msgid "No title"
 msgstr ""
 
@@ -128,18 +128,18 @@
 msgstr ""
 
 #: templates/egonomy_annotate_picture.html:80 templates/egonomy_base.html:36
-#: templates/egonomy_view_fragment.html:53
+#: templates/egonomy_view_fragment.html:50
 msgid "by"
 msgstr ""
 
 #: templates/egonomy_annotate_picture.html:85
-#: templates/egonomy_view_fragment.html:64
+#: templates/egonomy_view_fragment.html:65
 msgid "Create a fragment"
 msgstr ""
 
 #: templates/egonomy_annotate_picture.html:91
 #: templates/egonomy_create_fragment.html:152
-#: templates/egonomy_view_fragment.html:70
+#: templates/egonomy_view_fragment.html:96
 msgid "Fragments from this picture"
 msgstr ""
 
@@ -172,7 +172,7 @@
 msgstr ""
 
 #: templates/egonomy_create_fragment.html:100
-#: templates/egonomy_view_fragment.html:40
+#: templates/egonomy_view_fragment.html:37
 msgid "Source picture"
 msgstr ""
 
@@ -182,12 +182,12 @@
 msgstr ""
 
 #: templates/egonomy_create_fragment.html:108
-#: templates/egonomy_view_fragment.html:44
+#: templates/egonomy_view_fragment.html:41
 msgid "Fragment's description"
 msgstr ""
 
 #: templates/egonomy_create_fragment.html:112
-#: templates/egonomy_view_fragment.html:48
+#: templates/egonomy_view_fragment.html:45
 msgid "Users keywords"
 msgstr ""
 
@@ -223,7 +223,7 @@
 msgid "Last created fragments"
 msgstr ""
 
-#: templates/egonomy_home.html:80
+#: templates/egonomy_home.html:61
 msgid "Fragment from"
 msgstr ""
 
@@ -231,14 +231,26 @@
 msgid "View a fragment"
 msgstr ""
 
-#: templates/egonomy_view_fragment.html:52
+#: templates/egonomy_view_fragment.html:49
 msgid "Last modification"
 msgstr ""
 
-#: templates/egonomy_view_fragment.html:58
+#: templates/egonomy_view_fragment.html:55
 msgid "Modify this fragment"
 msgstr ""
 
+#: templates/egonomy_view_fragment.html:60
+msgid "Duplicate this fragment"
+msgstr ""
+
+#: templates/egonomy_view_fragment.html:70
+msgid "See the fragment in its full picture"
+msgstr ""
+
+#: templates/egonomy_view_fragment.html:83
+msgid "See the fragment only"
+msgstr ""
+
 #: templates/registration/login.html:5
 msgid "Login"
 msgstr ""
Binary file src/egonomy/locale/fr/LC_MESSAGES/django.mo has changed
--- a/src/egonomy/locale/fr/LC_MESSAGES/django.po	Fri Mar 01 12:05:58 2013 +0100
+++ b/src/egonomy/locale/fr/LC_MESSAGES/django.po	Mon Mar 04 15:29:30 2013 +0100
@@ -8,7 +8,7 @@
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-02-26 09:34-0600\n"
+"POT-Creation-Date: 2013-03-04 08:25-0600\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,8 +26,8 @@
 msgid "English"
 msgstr "Anglais"
 
-#: views.py:68
-#: views.py:87
+#: views.py:71
+#: views.py:95
 msgid "You are not allowed to modify this fragment."
 msgstr "Vous n'être pas autorisé à modifier ce fragment."
 
@@ -53,11 +53,11 @@
 msgid "Fragments created by"
 msgstr "Fragments créés par"
 
-#: templates/egonomy_all_fragments.html:59
-#: templates/egonomy_annotate_picture.html:123
-#: templates/egonomy_create_fragment.html:184
-#: templates/egonomy_home.html:81
-#: templates/egonomy_view_fragment.html:102
+#: templates/egonomy_all_fragments.html:40
+#: templates/egonomy_annotate_picture.html:102
+#: templates/egonomy_create_fragment.html:163
+#: templates/egonomy_home.html:62
+#: templates/egonomy_view_fragment.html:107
 msgid "Annotated by"
 msgstr "Annoté par"
 
@@ -72,8 +72,8 @@
 #: templates/egonomy_annotate_picture.html:12
 #: templates/egonomy_create_fragment.html:101
 #: templates/egonomy_home.html:39
-#: templates/egonomy_home.html.py:80
-#: templates/egonomy_view_fragment.html:41
+#: templates/egonomy_home.html.py:61
+#: templates/egonomy_view_fragment.html:38
 msgid "No title"
 msgstr "Sans titre"
 
@@ -138,18 +138,18 @@
 
 #: templates/egonomy_annotate_picture.html:80
 #: templates/egonomy_base.html:36
-#: templates/egonomy_view_fragment.html:53
+#: templates/egonomy_view_fragment.html:50
 msgid "by"
 msgstr "par"
 
 #: templates/egonomy_annotate_picture.html:85
-#: templates/egonomy_view_fragment.html:64
+#: templates/egonomy_view_fragment.html:65
 msgid "Create a fragment"
 msgstr "Créer un fragment"
 
 #: templates/egonomy_annotate_picture.html:91
 #: templates/egonomy_create_fragment.html:152
-#: templates/egonomy_view_fragment.html:70
+#: templates/egonomy_view_fragment.html:96
 msgid "Fragments from this picture"
 msgstr "Fragments issus de cette image"
 
@@ -182,7 +182,7 @@
 msgstr "Nouveau fragment"
 
 #: templates/egonomy_create_fragment.html:100
-#: templates/egonomy_view_fragment.html:40
+#: templates/egonomy_view_fragment.html:37
 msgid "Source picture"
 msgstr "Image source"
 
@@ -192,12 +192,12 @@
 msgstr "Titre du fragment"
 
 #: templates/egonomy_create_fragment.html:108
-#: templates/egonomy_view_fragment.html:44
+#: templates/egonomy_view_fragment.html:41
 msgid "Fragment's description"
 msgstr "Description du fragment"
 
 #: templates/egonomy_create_fragment.html:112
-#: templates/egonomy_view_fragment.html:48
+#: templates/egonomy_view_fragment.html:45
 msgid "Users keywords"
 msgstr "Mots-clés Utilisateurs"
 
@@ -233,7 +233,7 @@
 msgid "Last created fragments"
 msgstr "Derniers fragments créés"
 
-#: templates/egonomy_home.html:80
+#: templates/egonomy_home.html:61
 msgid "Fragment from"
 msgstr "Fragment de"
 
@@ -241,14 +241,26 @@
 msgid "View a fragment"
 msgstr "Voir un fragment"
 
-#: templates/egonomy_view_fragment.html:52
+#: templates/egonomy_view_fragment.html:49
 msgid "Last modification"
 msgstr "Dernière modification"
 
-#: templates/egonomy_view_fragment.html:58
+#: templates/egonomy_view_fragment.html:55
 msgid "Modify this fragment"
 msgstr "Modifier ce fragment"
 
+#: templates/egonomy_view_fragment.html:60
+msgid "Duplicate this fragment"
+msgstr "Dupliquer ce fragment"
+
+#: templates/egonomy_view_fragment.html:70
+msgid "See the fragment in its full picture"
+msgstr "Voir le fragment dans l'image entière"
+
+#: templates/egonomy_view_fragment.html:83
+msgid "See the fragment only"
+msgstr "Voir le fragment seul"
+
 #: templates/registration/login.html:5
 msgid "Login"
 msgstr "Se connecter"
--- a/src/egonomy/templates/egonomy_create_fragment.html	Fri Mar 01 12:05:58 2013 +0100
+++ b/src/egonomy/templates/egonomy_create_fragment.html	Mon Mar 04 15:29:30 2013 +0100
@@ -68,7 +68,7 @@
                         <div class="column column-half">
                             <a href="#" class="head-button clear-fragment" title="{% trans 'Erase the drawing' %}">&times;</a>
                             <a href="#" class="head-button reset-fragment" title="{% trans 'Back to the original drawing' %}">&#8634;</a>
-                            <h2>{% if frg_to_modify %}{{ frg_to_modify.title }}{% else %}{% trans 'New fragment' %}{% endif %}&nbsp;:</h2>
+                            <h2>{% if frg_to_modify %}{{ frg_data.title }}{% else %}{% trans 'New fragment' %}{% endif %}&nbsp;:</h2>
                             <div class="center-image">
 	                            <div class="image-and-fragment">
 	                              {% with img.info.image_file as image %}
@@ -89,9 +89,9 @@
 	                                <div class="cutout-canvas"></div>
 	                            </div>
                             </div>
-                            <input name="fragment_path" id="fragment_path" type="hidden" class="fragment-path column-half" value="{% if frg_to_modify %}{{ frg_to_modify.coordinates }}{% endif %}" />
+                            <input name="fragment_path" id="fragment_path" type="hidden" class="fragment-path column-half" value="{% if frg_data %}{{ frg_data.coordinates }}{% endif %}" />
                             <input name="image_id" id="image_id" type="hidden" value="{{ img.id }}" />
-                            {% if frg_to_modify %}<input name="fragment_pk" id="fragment_pk" type="hidden" value="{{ frg_to_modify.pk }}" />{% endif %}
+                            {% if frg_to_modify %}<input name="fragment_pk" id="fragment_pk" type="hidden" value="{{ frg_data.pk }}" />{% endif %}
                             {% csrf_token %}
                         </div>
                         <div class="column column-half">
@@ -102,15 +102,15 @@
                                 </tr>
                                 <tr>
                                     <th>{% trans "Fragment's title" %}&nbsp;:</th>
-                                    <td><input type="text" class="fragment-title" placeholder="{% trans "Fragment's title" %}" name="fragment_title" id="fragment_title" {% if frg_to_modify %}value="{{ frg_to_modify.title }}"{% endif %}/></td>
+                                    <td><input type="text" class="fragment-title" placeholder="{% trans "Fragment's title" %}" name="fragment_title" id="fragment_title" {% if frg_data %}value="{{ frg_data.title }}"{% endif %}/></td>
                                 </tr>
                                 <tr>
                                     <th>{% trans "Fragment's description" %}&nbsp;:</th>
-                                    <td><textarea class="fragment-description" name="fragment_description" id="fragment_description" {% if frg_to_modify %}value="{{ frg_to_modify.description }}"{% endif %}></textarea></td>
+                                    <td><textarea class="fragment-description" name="fragment_description" id="fragment_description" {% if frg_data %}value="{{ frg_data.description }}"{% endif %}></textarea></td>
                                 </tr>
                                 <tr>
                                     <th>{% trans 'Users keywords' %}&nbsp;:</th>
-                                    <td><input id="user_keywords" name="user_keywords" class="user-keywords" {% if frg_to_modify %}value="{{ frg_to_modify.tags }}"{% endif %}></ul>
+                                    <td><input id="user_keywords" name="user_keywords" class="user-keywords" {% if frg_data %}value="{{ frg_data.tags }}"{% endif %}></ul>
                                 </tr>
                                 {% if img.metadata.mots_cles %}
                                 <tr>
--- a/src/egonomy/templates/egonomy_view_fragment.html	Fri Mar 01 12:05:58 2013 +0100
+++ b/src/egonomy/templates/egonomy_view_fragment.html	Mon Mar 04 15:29:30 2013 +0100
@@ -55,6 +55,10 @@
                                     <td><a href="{% url 'create_fragment' image_id=fragment.image.id fragment_pk=fragment.pk %}" class="big-button">{% trans "Modify this fragment" %}</a></td>
                                 </tr>
                                 {% endifequal %}
+                                <tr>
+                                    <th>&nbsp;</th>
+                                    <td><a href="{% url 'create_fragment' image_id=fragment.image.id %}?duplicate={{fragment.pk}}" class="big-button">{% trans "Duplicate this fragment" %}</a></td>
+                                </tr>
                             </table>
                         </form>
                         <div class="fullwidth">
--- a/src/egonomy/views.py	Fri Mar 01 12:05:58 2013 +0100
+++ b/src/egonomy/views.py	Mon Mar 04 15:29:30 2013 +0100
@@ -62,15 +62,21 @@
     
     img = get_object_or_404(Image.objects.select_related('info', 'metadata'), id=image_id)
     frg_list = Fragment.objects.filter(image=img).order_by('-date_saved').select_related('image', 'image__info', 'image__metadata','author')
-    frg_to_modify = None
+    frg_to_modify = False
+    frg_data = None
     if fragment_pk:
-        frg_to_modify = get_object_or_404(Fragment.objects.select_related('author'), pk=fragment_pk)
+        frg_data = get_object_or_404(Fragment.objects.select_related('author'), pk=fragment_pk)
         # We check if the current user is the fragment's author
-        if frg_to_modify.author != request.user:
+        if frg_data.author != request.user:
             return HttpResponseForbidden(_("You are not allowed to modify this fragment."))
+        frg_to_modify = True
+    else:
+        frg_duplicate_pk = request.GET.get("duplicate") or None
+        if frg_duplicate_pk:
+            frg_data = get_object_or_404(Fragment.objects.select_related('author'), pk=frg_duplicate_pk)
     
     return render_to_response("egonomy_create_fragment.html",
-                              {'img': img, 'frg_to_modify': frg_to_modify, 'fragment_list': frg_list},
+                              {'img': img, 'frg_data': frg_data,  'frg_to_modify': frg_to_modify, 'fragment_list': frg_list},
                               context_instance=RequestContext(request))
 
 @login_required