1 ##parameters=addTemplate='', edit='', deleteOptionContainer='', createOptionsContainer=''
2 from Products
.CMFCore
.utils
import getToolByName
3 from Products
.photoprint
.utils
import translate
as _
5 utool
= getToolByName(context
, 'portal_url')
6 pptool
= getToolByName(context
, 'portal_photo_print')
7 form
= context
.REQUEST
.form
.copy()
10 context
.REQUEST
.RESPONSE
.setHeader('Content-Type', 'text/xml;;charset=utf-8');
14 orderTemplate
= pptool
.addPrintOrderTemplate( context
16 , description
=fg('description')
17 , productReference
=fg('productReference')
18 , maxCopies
=fg('maxCopies')
20 , VATRate
=fg('VATRate')
23 templateOptions
['o'] = orderTemplate
25 if context
.printingOptions
.getObjectPosition(orderTemplate
.getId()) % 2 == 0 :
27 templateOptions
['classRowName'] = classRowName
28 templateOptions
['portal_url'] = utool()
29 widget
= context
.get_photo_print_order_template(**templateOptions
).encode('utf-8').strip()
30 return '<computedField type="added">%s</computedField>' % widget
33 return '<error>%s</error>' % _(e
)
36 context
.REQUEST
.RESPONSE
.setHeader('Content-Type', 'text/xml;;charset=utf-8');
39 orderTemplate
= pptool
.editPrintOrderTemplate(context
, id, **form
)
42 templateOptions
['o'] = orderTemplate
44 if context
.printingOptions
.getObjectPosition(orderTemplate
.getId()) % 2 == 0 :
46 templateOptions
['classRowName'] = classRowName
47 templateOptions
['portal_url'] = utool()
48 widget
= context
.get_photo_print_order_template(**templateOptions
).encode('utf-8').strip()
49 return '<computedField type="edited">%s</computedField>' % widget
50 except ValueError, e
:
51 return '<error>%s</error>' % _(e
)
53 elif createOptionsContainer
:
54 pptool
.createPrintingOptionsContainer(context
)
55 context
.setStatus(True, _('Printing options added.'))
57 elif deleteOptionContainer
:
58 pptool
.deletePrintingOptionsContainer(context
)
59 context
.setStatus(True, _('Printing options deleted.'))
63 options
['pptool'] = pptool
64 options
['hasPO'] = pptool
.hasPrintingOptions(context
)
65 pOptionsSrc
= pptool
.getPrintingOptionsSrc(context
)
67 pourl
= pOptionsSrc
.getActionInfo('object/printing_settings')['url']
70 options
['pourl'] = pourl
72 return context
.photoprint_templates_edit_template(**options
)