Suppression des photos d'une table lumineuse par ajax.
authorBenoît Pin <benoit.pin@gmail.com>
Fri, 29 Aug 2014 12:02:08 +0000 (14:02 +0200)
committerBenoît Pin <benoit.pin@gmail.com>
Fri, 29 Aug 2014 12:02:08 +0000 (14:02 +0200)
locales/en/LC_MESSAGES/portfolio.po
locales/fr/LC_MESSAGES/portfolio.mo
locales/fr/LC_MESSAGES/portfolio.po
locales/portfolio.pot
skins/getLightboxPhotosInfos.py
skins/lightbox_view.py
skins/lightbox_view_template.pt

index 31709aa..09f46f3 100644 (file)
@@ -74,12 +74,29 @@ msgstr ""
 msgid "Lightbox created."
 msgstr ""
 
 msgid "Lightbox created."
 msgstr ""
 
+#: o/skins/lightbox_view.py:53
+msgid "Photo removed."
+msgstr ""
+
+#: o/skins/lightbox_view.py:55
+msgid "Removed photos."
+msgstr ""
+
+#: o/skins/lightbox_view.py:57
+msgid "Nothing to remove."
+msgstr ""
+
 #. Default: ""
 #: o/skins/lightbox_view_template.pt:19
 msgid "lightbox_selected_explanations"
 msgstr ""
 
 #. Default: ""
 #: o/skins/lightbox_view_template.pt:19
 msgid "lightbox_selected_explanations"
 msgstr ""
 
-#: o/skins/lightbox_view_template.pt:22 o/skins/selection_view_template.pt:20
+#: o/skins/lightbox_view_template.pt:24 o/skins/my_cart_template.pt:59
+#: o/skins/portfolio_view.pt:88 o/skins/selection_view_template.pt:31
+msgid "delete"
+msgstr ""
+
+#: o/skins/lightbox_view_template.pt:31 o/skins/selection_view_template.pt:20
 msgid "${DYNAMIC_CONTENT}"
 msgstr ""
 
 msgid "${DYNAMIC_CONTENT}"
 msgstr ""
 
@@ -123,11 +140,6 @@ msgstr ""
 msgid "refresh amount"
 msgstr ""
 
 msgid "refresh amount"
 msgstr ""
 
-#: o/skins/my_cart_template.pt:59 o/skins/portfolio_view.pt:88
-#: o/skins/selection_view_template.pt:31
-msgid "delete"
-msgstr ""
-
 #: o/skins/my_cart_template.pt:69
 msgid "Prints"
 msgstr ""
 #: o/skins/my_cart_template.pt:69
 msgid "Prints"
 msgstr ""
index 7097597..400e2cc 100644 (file)
Binary files a/locales/fr/LC_MESSAGES/portfolio.mo and b/locales/fr/LC_MESSAGES/portfolio.mo differ
index dc2a367..00a754f 100644 (file)
@@ -1,8 +1,8 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: Plinn 2.0\n"
 msgid ""
 msgstr ""
 "Project-Id-Version: Plinn 2.0\n"
-"POT-Creation-Date: Fri Aug 29 10:44:06 2014\n"
-"PO-Revision-Date: 2014-08-29 10:45+0200\n"
+"POT-Creation-Date: Fri Aug 29 13:55:35 2014\n"
+"PO-Revision-Date: 2014-08-29 13:56+0200\n"
 "Last-Translator:  Benoît PIN\n"
 "Language-Team: CRI http://cri.ensmp.fr\n"
 "Language: \n"
 "Last-Translator:  Benoît PIN\n"
 "Language-Team: CRI http://cri.ensmp.fr\n"
 "Language: \n"
@@ -97,6 +97,18 @@ msgstr "Vous devez entrer un titre."
 msgid "Lightbox created."
 msgstr "Table lumineuse créée."
 
 msgid "Lightbox created."
 msgstr "Table lumineuse créée."
 
+#: o/skins/lightbox_view.py:53
+msgid "Photo removed."
+msgstr "Photo retirée."
+
+#: o/skins/lightbox_view.py:55
+msgid "Removed photos."
+msgstr "Photos retirées."
+
+#: o/skins/lightbox_view.py:57
+msgid "Nothing to remove."
+msgstr "Rien à retirer."
+
 #. Default: ""
 #: o/skins/lightbox_view_template.pt:19
 msgid "lightbox_selected_explanations"
 #. Default: ""
 #: o/skins/lightbox_view_template.pt:19
 msgid "lightbox_selected_explanations"
@@ -104,7 +116,12 @@ msgstr ""
 "Cette table lumineuse est sélectionnée : les images que vous sélectionnerez "
 "à présent seront automatiquement sauvegardées à cet endroit."
 
 "Cette table lumineuse est sélectionnée : les images que vous sélectionnerez "
 "à présent seront automatiquement sauvegardées à cet endroit."
 
-#: o/skins/lightbox_view_template.pt:22 o/skins/selection_view_template.pt:20
+#: o/skins/lightbox_view_template.pt:24 o/skins/my_cart_template.pt:59
+#: o/skins/portfolio_view.pt:88 o/skins/selection_view_template.pt:31
+msgid "delete"
+msgstr "supprimer"
+
+#: o/skins/lightbox_view_template.pt:31 o/skins/selection_view_template.pt:20
 msgid "${DYNAMIC_CONTENT}"
 msgstr ""
 
 msgid "${DYNAMIC_CONTENT}"
 msgstr ""
 
@@ -148,11 +165,6 @@ msgstr "Prix (TTC)"
 msgid "refresh amount"
 msgstr "actualiser le montant"
 
 msgid "refresh amount"
 msgstr "actualiser le montant"
 
-#: o/skins/my_cart_template.pt:59 o/skins/portfolio_view.pt:88
-#: o/skins/selection_view_template.pt:31
-msgid "delete"
-msgstr "supprimer"
-
 #: o/skins/my_cart_template.pt:69
 msgid "Prints"
 msgstr "Tirages"
 #: o/skins/my_cart_template.pt:69
 msgid "Prints"
 msgstr "Tirages"
index 6d8a06a..fd5694f 100644 (file)
@@ -14,7 +14,7 @@
 msgid ""
 msgstr ""
 "Project-Id-Version: 3.0\n"
 msgid ""
 msgstr ""
 "Project-Id-Version: 3.0\n"
-"POT-Creation-Date: Fri Aug 29 10:44:06 2014\n"
+"POT-Creation-Date: Fri Aug 29 13:55:35 2014\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: Zope 3 Developers <zope-dev@zope.org>\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: Zope 3 Developers <zope-dev@zope.org>\n"
@@ -106,12 +106,35 @@ msgstr ""
 msgid "Lightbox created."
 msgstr ""
 
 msgid "Lightbox created."
 msgstr ""
 
+#: o/skins/lightbox_view.py:53
+msgid "Photo removed."
+msgstr ""
+
+#: o/skins/lightbox_view.py:55
+msgid "Removed photos."
+msgstr ""
+
+#: o/skins/lightbox_view.py:57
+msgid "Nothing to remove."
+msgstr ""
+
 #: o/skins/lightbox_view_template.pt:19
 #. Default: ""
 msgid "lightbox_selected_explanations"
 msgstr ""
 
 #: o/skins/lightbox_view_template.pt:19
 #. Default: ""
 msgid "lightbox_selected_explanations"
 msgstr ""
 
-#: o/skins/lightbox_view_template.pt:22
+#: o/skins/lightbox_view_template.pt:24
+#: o/skins/lightbox_view_template.pt:24
+#: o/skins/my_cart_template.pt:59
+#: o/skins/my_cart_template.pt:59
+#: o/skins/portfolio_view.pt:88
+#: o/skins/portfolio_view.pt:88
+#: o/skins/selection_view_template.pt:31
+#: o/skins/selection_view_template.pt:31
+msgid "delete"
+msgstr ""
+
+#: o/skins/lightbox_view_template.pt:31
 #: o/skins/selection_view_template.pt:20
 msgid "${DYNAMIC_CONTENT}"
 msgstr ""
 #: o/skins/selection_view_template.pt:20
 msgid "${DYNAMIC_CONTENT}"
 msgstr ""
@@ -158,15 +181,6 @@ msgstr ""
 msgid "refresh amount"
 msgstr ""
 
 msgid "refresh amount"
 msgstr ""
 
-#: o/skins/my_cart_template.pt:59
-#: o/skins/my_cart_template.pt:59
-#: o/skins/portfolio_view.pt:88
-#: o/skins/portfolio_view.pt:88
-#: o/skins/selection_view_template.pt:31
-#: o/skins/selection_view_template.pt:31
-msgid "delete"
-msgstr ""
-
 #: o/skins/my_cart_template.pt:69
 msgid "Prints"
 msgstr ""
 #: o/skins/my_cart_template.pt:69
 msgid "Prints"
 msgstr ""
index f5afc8c..626ebd1 100644 (file)
@@ -42,7 +42,7 @@ for index, b in enumerate(batch) :
        infos.append(d)
 
 features = {}
        infos.append(d)
 
 features = {}
-features['del'] = lambda b: '%s/remove_to_lightbox?uid=%s' % (lightboxUrl, b.cmf_uid)
+features['checkbox'] = True
 features['cart'] = lambda b : '%s/get_slide_buyable_items' % b.getURL()
 
 return {'infos' : infos,
 features['cart'] = lambda b : '%s/get_slide_buyable_items' % b.getURL()
 
 return {'infos' : infos,
index 7fb12dc..1a06cef 100755 (executable)
@@ -1,27 +1,66 @@
-##parameters=load='',unload='',**kw
+##parameters=
+from Products.Portfolio.utils import translate
+_ = lambda msg : translate(msg, context)
 options = {}
 buttons = []
 options = {}
 buttons = []
-lightboxSelected = False
 
 sd = context.session_data_manager.getSessionData(create = 1)
 path  = context.getPhysicalPath()
 
 sd = context.session_data_manager.getSessionData(create = 1)
 path  = context.getPhysicalPath()
+req = context.REQUEST
+form = req.form
+fg = form.get
+
+# check if lighbox is selected
+sessionpath = sd.get('lightboxpath', None)
+lightboxSelected = False
+if sessionpath == path :
+       lightboxSelected = True
+       buttons.append({'name': 'unload', 'value': 'Unload from my selection'})
+else :
+       buttons.append({'name':'load', 'value': 'Load in my selection'})
 
 
-if load :
+# form processing
+if fg('load') :
        sd.set('lightboxpath', path)
        selection = context.getUidList()
        sd.set('objects_selection', selection)
        sd.set('objects_selection_dict', dict([(uid, True) for uid in selection]))
        sd.set('lightboxpath', path)
        selection = context.getUidList()
        sd.set('objects_selection', selection)
        sd.set('objects_selection_dict', dict([(uid, True) for uid in selection]))
-elif unload :
+
+elif fg('unload') :
        sd.set('lightboxpath', None)
        sd.set('objects_selection', [])
        sd.set('objects_selection_dict', {})
 
        sd.set('lightboxpath', None)
        sd.set('objects_selection', [])
        sd.set('objects_selection_dict', {})
 
-sessionpath = sd.get('lightboxpath', None)
-if sessionpath == path :
-       lightboxSelected = True
-       buttons.append({'name': 'unload', 'value': 'Unload from my selection'})
-else :
-       buttons.append({'name':'load', 'value': 'Load in my selection'})
+elif fg('delete.x') or form.has_key('delete') :
+    uids = fg('uids', [])
+    if not lightboxSelected :
+        for uid in [int(uid) for uid in uids] :
+            context.remove(uid)
+    else :
+        selection = sd.get('objects_selection', [])
+        selDict = sd.get('objects_selection_dict', {})
+        for uid in [int(uid) for uid in uids] :
+            context.remove(uid)
+            selection.remove(uid)
+            del selDict[uid]
+
+        sd['objects_selection'] = selection
+        sd['objects_selection_dict'] = selDict
+    
+    # ui feedback message
+    if uids :
+        if len(uids) == 1 :
+            msg = _('Photo removed.')
+        else :
+            msg = _('Removed photos.')
+    else :
+        msg = _('Nothing to remove.')
+    
+    if fg('ajax') :
+        context.REQUEST.RESPONSE.setHeader('Content-Type', 'text/xml;;charset=utf-8')
+        return '<deleted>%s</deleted>' % msg
+    else :
+        context.setStatus(True, msg)
 
 
 options['buttons'] = buttons
 
 
 options['buttons'] = buttons
index 3e73cca..5200891 100644 (file)
     <div metal:fill-slot="main" tal:omit-tag="" i18n:domain="portfolio">
       <em tal:condition="options/lightboxSelected" i18n:translate="lightbox_selected_explanations"></em>
       <form tal:attributes="action string:${here/absolute_url}/lightbox_view" tal:condition="options/buttons">
     <div metal:fill-slot="main" tal:omit-tag="" i18n:domain="portfolio">
       <em tal:condition="options/lightboxSelected" i18n:translate="lightbox_selected_explanations"></em>
       <form tal:attributes="action string:${here/absolute_url}/lightbox_view" tal:condition="options/buttons">
+        <div id="lightbox_toolbar" class="image_toolbar"
+             tal:define="ModifyPortalContent modules/Products/CMFCore/permissions/ModifyPortalContent"
+             tal:condition="python:mtool.checkPermission(ModifyPortalContent, here)">
+          <input type="image" width="17" height="27" alt="delete" title="delete"
+                 name="delete"
+                 tal:attributes="src string:$portal_url/trash_btn.gif"
+                 i18n:attributes="alt;title"/>
+          <br/>
+        </div>
         <span tal:repeat="button options/buttons" tal:omit-tag="">
           <input type="submit" tal:attributes="name button/name; value button/value" i18n:attributes="value"/>
         </span>
         <span tal:repeat="button options/buttons" tal:omit-tag="">
           <input type="submit" tal:attributes="name button/name; value button/value" i18n:attributes="value"/>
         </span>
-      </form>
-      <div tal:define="batch options/batch;
-                       infos options/infos;
-                       features options/features"
-           tal:omit-tag="">
-        <div metal:use-macro="here/photo_layout_macros/macros/grid">
-          affichage grille
+        <div tal:define="batch options/batch;
+                         infos options/infos;
+                         features options/features"
+             tal:omit-tag="">
+          <div metal:use-macro="here/photo_layout_macros/macros/grid">
+            affichage grille
+          </div>
         </div>
         </div>
-      </div>
+      </form>
       <br clear="all"/>
     </div>
   </body>
       <br clear="all"/>
     </div>
   </body>