From 7343423f34790513dad5305d4a9cf9aba8d216e8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Fri, 29 Aug 2014 10:51:46 +0200 Subject: [PATCH 1/1] =?utf8?q?Suppression=20des=20images=20d'une=20s=C3=A9?= =?utf8?q?lection=20avec=20ajax.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- locales/en/LC_MESSAGES/portfolio.po | 49 ++++++++++------ locales/fr/LC_MESSAGES/portfolio.mo | Bin 7006 -> 7238 bytes locales/fr/LC_MESSAGES/portfolio.po | 53 ++++++++++------- locales/portfolio.pot | 66 ++++++++++++--------- skins/getSelectionPhotosInfos.py | 58 +++++++++---------- skins/selection_view.py | 87 +++++++++++++++++++++------- skins/selection_view_template.pt | 49 ++++++++++------ 7 files changed, 230 insertions(+), 132 deletions(-) diff --git a/locales/en/LC_MESSAGES/portfolio.po b/locales/en/LC_MESSAGES/portfolio.po index c36a5b2..31709aa 100644 --- a/locales/en/LC_MESSAGES/portfolio.po +++ b/locales/en/LC_MESSAGES/portfolio.po @@ -48,8 +48,8 @@ msgstr "" msgid "This %s is already in the selection." msgstr "" -#: o/skins/get_slide_buyable_items.pt:21 o/skins/photo_layout_macros.pt:52 -#: o/skins/photo_layout_macros.pt:55 o/skins/photo_view.pt:91 +#: o/skins/get_slide_buyable_items.pt:21 o/skins/photo_layout_macros.pt:51 +#: o/skins/photo_layout_macros.pt:54 o/skins/photo_view.pt:91 #: o/skins/photo_view.pt:94 msgid "Add to cart" msgstr "" @@ -123,7 +123,8 @@ msgstr "" msgid "refresh amount" msgstr "" -#: o/skins/my_cart_template.pt:59 o/skins/portfolio_view.pt:81 +#: o/skins/my_cart_template.pt:59 o/skins/portfolio_view.pt:88 +#: o/skins/selection_view_template.pt:31 msgid "delete" msgstr "" @@ -175,24 +176,24 @@ msgstr "" msgid "Dimensions" msgstr "" -#: o/skins/photo_layout_macros.pt:33 o/skins/photo_layout_macros.pt:36 +#: o/skins/photo_layout_macros.pt:32 o/skins/photo_layout_macros.pt:35 msgid "Add to selection" msgstr "" -#: o/skins/photo_layout_macros.pt:42 o/skins/photo_layout_macros.pt:45 +#: o/skins/photo_layout_macros.pt:41 o/skins/photo_layout_macros.pt:44 msgid "Remove to selection" msgstr "" -#: o/skins/photo_layout_macros.pt:61 o/skins/photo_layout_macros.pt:64 +#: o/skins/photo_layout_macros.pt:60 o/skins/photo_layout_macros.pt:63 #: o/skins/portfolio_presentation_template.pt:47 msgid "Delete" msgstr "" -#: o/skins/photo_layout_macros.pt:79 o/skins/photo_layout_macros.pt:82 +#: o/skins/photo_layout_macros.pt:78 o/skins/photo_layout_macros.pt:81 msgid "Hide for anonymous" msgstr "" -#: o/skins/photo_layout_macros.pt:92 o/skins/photo_layout_macros.pt:95 +#: o/skins/photo_layout_macros.pt:91 o/skins/photo_layout_macros.pt:94 msgid "Show for anonymous" msgstr "" @@ -272,15 +273,15 @@ msgstr "" msgid "sorting:" msgstr "" -#: o/skins/portfolio_view.pt:76 +#: o/skins/portfolio_view.pt:77 msgid "manual" msgstr "" -#: o/skins/portfolio_view.pt:77 +#: o/skins/portfolio_view.pt:79 msgid "shooting" msgstr "" -#: o/skins/portfolio_view.pt:78 +#: o/skins/portfolio_view.pt:81 msgid "modification" msgstr "" @@ -292,9 +293,21 @@ msgstr "" msgid "Description" msgstr "" -#: o/skins/selection_view.py:64 o/skins/selection_view.py:66 -#: o/skins/selection_view_template.pt:18 o/skins/selectioncontext.py:115 -#: o/skins/selectioncontext.py:117 +#: o/skins/selection_view.py:56 +msgid "Photo deselected." +msgstr "" + +#: o/skins/selection_view.py:58 +msgid "Deselected photos." +msgstr "" + +#: o/skins/selection_view.py:60 +msgid "Nothing to deselect." +msgstr "" + +#: o/skins/selection_view.py:70 o/skins/selection_view.py:72 +#: o/skins/selection_view_template.pt:18 o/skins/selectioncontext.py:116 +#: o/skins/selectioncontext.py:118 msgid "My selection" msgstr "" @@ -302,20 +315,20 @@ msgstr "" msgid "You are editing this ligthbox:" msgstr "" -#: o/skins/selection_view_template.pt:30 +#: o/skins/selection_view_template.pt:42 msgid "Save as..." msgstr "" -#: o/skins/selection_view_template.pt:33 +#: o/skins/selection_view_template.pt:45 msgid "${please_login} if you want to save this selection." msgstr "" #. Default: "Please log in" -#: o/skins/selection_view_template.pt:34 +#: o/skins/selection_view_template.pt:46 msgid "login_to_save_seletion" msgstr "" -#: o/skins/selection_view_template.pt:38 +#: o/skins/selection_view_template.pt:50 msgid "Empty selection." msgstr "" diff --git a/locales/fr/LC_MESSAGES/portfolio.mo b/locales/fr/LC_MESSAGES/portfolio.mo index 7af8c86755bbe4b56df39a244fbda7366b4873f7..7097597a37bf078223fd33eb1440b297ac840da9 100644 GIT binary patch delta 2535 zcmZA1X-r&I7{>9Jr45t-7Q$G6;Vqqinh!MgAFt=8kdksS{pU` zL4r$!#2ON{#Godl(OAfjIOzo-`$E;7r-49vtb)C8(92iGEh*2+%?c3>rj zP!k+Qz4t1n;1SGWd^dk-KaZO6U#>la(U^-BpeE>{CcFY!iPd5SHewz2 zU^N~>P4JZSdyMsqe#W;9da1`vsF^*C8sHIBN}ohcXbkn@BwmWg-St}~H0s3{P$_=}wZbDvGVB;$jvu3*`w>};{fRn5 zNz7U+_HZfIpfbGE*@@~m;3NO)_yHO;vmxaC*|Vq)M{xrfMs49+sEi-Q#rpoIsc1$su?EsaK9$lEel$QW zmSP)TjRUBOj-xuB#AWy{YKy)@l4LWeiCsiJpT+W(@*-3w%K1rSd|O9FFSKAacA_2} zMh!5AEATLq96O22@jNQUK9()>kTqB#YOkxX2olsa%JXs26@k zrOroMuD~|bp5Kq!a5fwUzKelG;#e8P|-X3&MSx>LI+mmwpr|M z?SH&K7~C7|3I_w;zMlSY|KRHAH>nc|x!e20J)ypCFWm11+#@3g z(uULZOuQxPOJ9|o+cXgJHs06mRX2E5m5qLXV`bgQwyY(K>MLAJZ8V&9EU~aP*1Z>) wni!m#(2$}2zP_o6AS2e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 3 Developers \n" @@ -79,8 +79,8 @@ msgid "This %s is already in the selection." msgstr "" #: o/skins/get_slide_buyable_items.pt:21 -#: o/skins/photo_layout_macros.pt:52 -#: o/skins/photo_layout_macros.pt:55 +#: o/skins/photo_layout_macros.pt:51 +#: o/skins/photo_layout_macros.pt:54 #: o/skins/photo_view.pt:91 #: o/skins/photo_view.pt:94 msgid "Add to cart" @@ -160,8 +160,10 @@ msgstr "" #: o/skins/my_cart_template.pt:59 #: o/skins/my_cart_template.pt:59 -#: o/skins/portfolio_view.pt:81 -#: o/skins/portfolio_view.pt:81 +#: 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 "" @@ -215,29 +217,29 @@ msgstr "" msgid "Dimensions" msgstr "" -#: o/skins/photo_layout_macros.pt:33 -#: o/skins/photo_layout_macros.pt:36 +#: o/skins/photo_layout_macros.pt:32 +#: o/skins/photo_layout_macros.pt:35 msgid "Add to selection" msgstr "" -#: o/skins/photo_layout_macros.pt:42 -#: o/skins/photo_layout_macros.pt:45 +#: o/skins/photo_layout_macros.pt:41 +#: o/skins/photo_layout_macros.pt:44 msgid "Remove to selection" msgstr "" -#: o/skins/photo_layout_macros.pt:61 -#: o/skins/photo_layout_macros.pt:64 +#: o/skins/photo_layout_macros.pt:60 +#: o/skins/photo_layout_macros.pt:63 #: o/skins/portfolio_presentation_template.pt:47 msgid "Delete" msgstr "" -#: o/skins/photo_layout_macros.pt:79 -#: o/skins/photo_layout_macros.pt:82 +#: o/skins/photo_layout_macros.pt:78 +#: o/skins/photo_layout_macros.pt:81 msgid "Hide for anonymous" msgstr "" -#: o/skins/photo_layout_macros.pt:92 -#: o/skins/photo_layout_macros.pt:95 +#: o/skins/photo_layout_macros.pt:91 +#: o/skins/photo_layout_macros.pt:94 msgid "Show for anonymous" msgstr "" @@ -324,15 +326,15 @@ msgstr "" msgid "sorting:" msgstr "" -#: o/skins/portfolio_view.pt:76 +#: o/skins/portfolio_view.pt:77 msgid "manual" msgstr "" -#: o/skins/portfolio_view.pt:77 +#: o/skins/portfolio_view.pt:79 msgid "shooting" msgstr "" -#: o/skins/portfolio_view.pt:78 +#: o/skins/portfolio_view.pt:81 msgid "modification" msgstr "" @@ -344,11 +346,23 @@ msgstr "" msgid "Description" msgstr "" -#: o/skins/selection_view.py:64 -#: o/skins/selection_view.py:66 +#: o/skins/selection_view.py:56 +msgid "Photo deselected." +msgstr "" + +#: o/skins/selection_view.py:58 +msgid "Deselected photos." +msgstr "" + +#: o/skins/selection_view.py:60 +msgid "Nothing to deselect." +msgstr "" + +#: o/skins/selection_view.py:70 +#: o/skins/selection_view.py:72 #: o/skins/selection_view_template.pt:18 -#: o/skins/selectioncontext.py:115 -#: o/skins/selectioncontext.py:117 +#: o/skins/selectioncontext.py:116 +#: o/skins/selectioncontext.py:118 msgid "My selection" msgstr "" @@ -356,20 +370,20 @@ msgstr "" msgid "You are editing this ligthbox:" msgstr "" -#: o/skins/selection_view_template.pt:30 +#: o/skins/selection_view_template.pt:42 msgid "Save as..." msgstr "" -#: o/skins/selection_view_template.pt:33 +#: o/skins/selection_view_template.pt:45 msgid "${please_login} if you want to save this selection." msgstr "" -#: o/skins/selection_view_template.pt:34 +#: o/skins/selection_view_template.pt:46 #. Default: "Please log in" msgid "login_to_save_seletion" msgstr "" -#: o/skins/selection_view_template.pt:38 +#: o/skins/selection_view_template.pt:50 msgid "Empty selection." msgstr "" diff --git a/skins/getSelectionPhotosInfos.py b/skins/getSelectionPhotosInfos.py index 362f76d..20e6d61 100644 --- a/skins/getSelectionPhotosInfos.py +++ b/skins/getSelectionPhotosInfos.py @@ -15,15 +15,15 @@ toUrl = req.physicalPathToURL lightboxpath = req.SESSION.get('lightboxpath', None) selectionIsLightbox = False if lightboxpath is None : - selection = req.SESSION.get('objects_selection', []) + selection = req.SESSION.get('objects_selection', []) else : - try : - lightbox = portal.restrictedTraverse(lightboxpath) - selection = lightbox.getUidList() - selectionIsLightbox = True - except: - req.SESSION.set('lightboxpath', None) - selection = req.SESSION.get('objects_selection', []) + try : + lightbox = portal.restrictedTraverse(lightboxpath) + selection = lightbox.getUidList() + selectionIsLightbox = True + except: + req.SESSION.set('lightboxpath', None) + selection = req.SESSION.get('objects_selection', []) brains = [uidh.getBrain(uid) for uid in selection] @@ -34,29 +34,29 @@ cart = req.SESSION.get('cart', None) infos = [] for index, b in enumerate(batch) : - path = b.getPath().split('/') - path.insert(portalDepth, 'selectioncontext') - p = b.getObject() - if pptool : - buyable = bool(pptool.getPrintingOptionsFor(p)) - if cart and cart.locked : - buyable = False - else : - buyable = False - - d = {'href': toUrl('/'.join(path)) - ,'thumbUrl' : '%s/getThumbnail' % b.getURL() - ,'thumbSize' : b.getThumbnailSize - ,'title' : ('%s - %s' % (b.Title, b.Description)).strip(' -') - ,'cmf_uid':b.cmf_uid - ,'className':'' - ,'buyable' : buyable - ,'o':b - } - infos.append(d) + path = b.getPath().split('/') + path.insert(portalDepth, 'selectioncontext') + p = b.getObject() + if pptool : + buyable = bool(pptool.getPrintingOptionsFor(p)) + if cart and cart.locked : + buyable = False + else : + buyable = False + + d = {'href': toUrl('/'.join(path)) + ,'thumbUrl' : '%s/getThumbnail' % b.getURL() + ,'thumbSize' : b.getThumbnailSize + ,'title' : ('%s - %s' % (b.Title, b.Description)).strip(' -') + ,'cmf_uid':b.cmf_uid + ,'className':'' + ,'buyable' : buyable + ,'o':b + } + infos.append(d) features = {} -features['del'] = lambda b : '%s/remove_to_selection' % b.getURL() +features['checkbox'] = True features['cart'] = lambda b : '%s/get_slide_buyable_items' % b.getURL() return {'infos' : infos, diff --git a/skins/selection_view.py b/skins/selection_view.py index 0a419a7..c30d397 100755 --- a/skins/selection_view.py +++ b/skins/selection_view.py @@ -1,38 +1,85 @@ ##parameters= -from Products.CMFCore.utils import getToolByName +from Products.CMFCore.utils import getUtilityByInterfaceName from Products.Portfolio.utils import translate def _(message) : return translate(message, context).encode('utf-8') req = context.REQUEST -utool = getToolByName(context, 'portal_url') +utool = getUtilityByInterfaceName('Products.CMFCore.interfaces.IURLTool') portal = utool.getPortalObject() portal_url = utool() +form = req.form +fg = form.get +sd = context.session_data_manager.getSessionData(create = 1) + # check if a lightbox is currently selected -lightboxpath = req.SESSION.get('lightboxpath', None) +lightboxpath = sd.get('lightboxpath', None) selectionIsLightbox = False if lightboxpath is not None : - try : - lightbox = portal.restrictedTraverse(lightboxpath) - selectionIsLightbox = True - except: - req.SESSION.set('lightboxpath', None) + try : + lightbox = portal.restrictedTraverse(lightboxpath) + selectionIsLightbox = True + except: + sd['lightboxpath'] = None + +# form processing +if fg('delete.x') or form.has_key('delete') : + selection = sd.get('objects_selection', []) + selDict = sd.get('objects_selection_dict', {}) + + # get selection from session data or from selected lightbox + if not selectionIsLightbox : + selection = sd.get('objects_selection', []) + else : + try : + lightbox = portal.restrictedTraverse(lightboxpath) + selection = lightbox.getUidList() + except KeyError : + sd['lightboxpath'] = None + selection = sd.get('objects_selection', []) + + # remove items from selection + rmCpt = 0 + for uid in [int(uid) for uid in fg('uids', [])] : + if selDict.has_key(uid) : + del selDict[uid] + selection.remove(uid) + if selectionIsLightbox : + lightbox.remove(uid) + sd['objects_selection'] = selection + sd['objects_selection_dict'] = selDict + rmCpt = rmCpt + 1 + + # ui feedback message + if rmCpt : + if rmCpt == 1 : + msg = _('Photo deselected.') + else : + msg = _('Deselected photos.') + else : + msg = _('Nothing to deselect.') + + if fg('ajax') : + req.RESPONSE.setHeader('Content-Type', 'text/xml;;charset=utf-8') + return '%s' % msg + else : + context.setStatus(True, msg) # breadcrumbs customization if selectionIsLightbox : - lastBcTitle = '%s (%s)' % (_('My selection'), lightbox.title_or_id()) + lastBcTitle = '%s (%s)' % (_('My selection'), lightbox.title_or_id()) else : - lastBcTitle = _('My selection') + lastBcTitle = _('My selection') breadcrumbs = [ - { 'id' : 'root' - , 'title' : portal.title - , 'url' : portal_url}, - - {'id' : 'selection_view' - ,'title' : lastBcTitle - , 'url' : '%s/selection_view' % portal_url} - ] + { 'id' : 'root' + , 'title' : portal.title + , 'url' : portal_url}, + + {'id' : 'selection_view' + ,'title' : lastBcTitle + , 'url' : '%s/selection_view' % portal_url} + ] options = {} @@ -42,8 +89,8 @@ options['selectionIsLightbox'] = selectionIsLightbox options['breadcrumbs'] = breadcrumbs if selectionIsLightbox : - options['lightbox'] = lightbox + options['lightbox'] = lightbox else : - options['selectionName'] = 'not saved yet' + options['selectionName'] = 'not saved yet' return context.selection_view_template(**options) diff --git a/skins/selection_view_template.pt b/skins/selection_view_template.pt index 6684241..82cabe8 100644 --- a/skins/selection_view_template.pt +++ b/skins/selection_view_template.pt @@ -16,26 +16,37 @@ tal:omit-tag="" i18n:domain="portfolio">

My selection

- - (selection name) - -
- You are editing this ligthbox: - lightbox url -
-
+ + (selection name) + +
+ You are editing this ligthbox: + lightbox url +
+
+ +
+

-
- -
-
- - Please log in if you want to save this selection. -
+
+ +
+
+ + Please log in if you want to save this selection. +
Empty selection.
-- 2.20.1