From 2f5dd859916d7699e0005dedfabf262ef107143b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Benoi=CC=82t=20Pin?= Date: Mon, 22 Jul 2013 16:58:04 +0200 Subject: [PATCH 1/1] =?utf8?q?Cr=C3=A9ation=20script=20/=20zpt=20pour=20le?= =?utf8?q?=20rendu=20d'une=20thumbnail=20(uniquement)=20pour=20affichage?= =?utf8?q?=20apr=C3=A8s=20upload=20en=20js.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- skins/getPhotoInfo.py | 57 ++++++++++++++++++++++++++++++++++++ skins/photo_gridthumbnail.pt | 13 ++++++++ skins/photo_layout_macros.pt | 3 +- 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100755 skins/getPhotoInfo.py create mode 100644 skins/photo_gridthumbnail.pt diff --git a/skins/getPhotoInfo.py b/skins/getPhotoInfo.py new file mode 100755 index 0000000..2947778 --- /dev/null +++ b/skins/getPhotoInfo.py @@ -0,0 +1,57 @@ +##parameters= +from Products.CMFCore.utils import getToolByName +from Products.CMFCore.permissions import ReviewPortalContent +mtool = getToolByName(context, 'portal_membership') +pptool = getToolByName(context, 'portal_photo_print', None) +uidtool = getToolByName(context, 'portal_uidhandler') + +features = {} +def toggleSelection(o, selected) : + if selected : + return '%s/remove_to_selection' % o.absolute_url() + else : + return '%s/add_to_selection' % o.absolute_url() + +features['select'] = toggleSelection +features['cart'] = lambda o : '%s/get_slide_buyable_items' % o.absolute_url() + +if mtool.checkPermission(ReviewPortalContent, context) : + features['hideAnonymous'] = True + +sd = context.session_data_manager.getSessionData(create = 1) +selDict = sd.get('objects_selection_dict', {}) +cart = sd.get('cart', None) + +p = context +className = '' +uid = getattr(p, 'cmf_uid', None) +if uid is not None : + uid = uid() +absUrl = p.absolute_url() +selected = selDict.has_key(uid) +hiddenForAnonymous = p.hiddenForAnonymous() +if pptool : + buyable = bool(pptool.getPrintingOptionsFor(p)) + if cart and cart.locked : + buyable = False +else : + buyable = False + +if selected : + className = 'selected' +if hiddenForAnonymous : + className = 'hidden-slide' + +d = {'href' : absUrl + ,'thumbUrl' : '%s/getThumbnail' % absUrl + ,'thumbSize': p.getThumbnailSize() + ,'title' : ('%s - %s' % (p.Title(), p.Description())).strip(' -') + ,'selected' : selected + ,'hiddenForAnonymous' : hiddenForAnonymous + ,'cmf_uid' : uidtool.register(p) + ,'buyable' : buyable + ,'className': className + ,'o' : p + } + +return {'info' : d, 'features' : features} diff --git a/skins/photo_gridthumbnail.pt b/skins/photo_gridthumbnail.pt new file mode 100644 index 0000000..0e410a0 --- /dev/null +++ b/skins/photo_gridthumbnail.pt @@ -0,0 +1,13 @@ +
+ +
+ +
+
+
+
\ No newline at end of file diff --git a/skins/photo_layout_macros.pt b/skins/photo_layout_macros.pt index 82511dd..f3fb5ca 100644 --- a/skins/photo_layout_macros.pt +++ b/skins/photo_layout_macros.pt @@ -18,7 +18,8 @@ margin_left python:(slide_size - size['width']) / 2; selected info/selected|nothing" tal:attributes="class info/className; - name info/cmf_uid"> + name info/cmf_uid" + metal:define-macro="thumbnail">