Refactoring.
[Portfolio.git] / skins / photo_view_ajax.py
1 ##parameters=
2 from Products.CMFCore.utils import getToolByName
3 from ZTUtils import make_query as mq
4 utool = getToolByName(context, 'portal_url')
5 pptool = getToolByName(context, 'portal_photo_print', None)
6 portal_url = utool()
7 sd = context.session_data_manager.getSessionData(create = 1)
8 cart = sd.get('cart', None)
9 bsize = 20
10 options = {}
11
12 portfolio = context.getParentNode()
13 posOfPhoto = portfolio.getObjectPosition(context.getId())
14 options['backToContextUrl'] = '%s?b_start:int=%s' % (portfolio.absolute_url(), posOfPhoto/bsize*bsize)
15 options['lastBcUrl'] = context.absolute_url()
16 if pptool :
17 buyable = bool(pptool.getPrintingOptionsFor(context))
18 if cart and cart.locked :
19 buyable = False
20 else :
21 buyable = False
22
23 options['buyable'] = buyable
24
25 return context.photo_view_ajax_template(**options)