94851be2f24ae797b0326717f1a08f55cc4a1a07
1 ##parameters=addTemplate='', edit='', deleteOptionContainer='', createOptionsContainer=''
2 from Products
.CMFCore
.utils
import getToolByName
3 from Products
.photoprint
.utils
import translate
4 _
= lambda msg
: translate(msg
, context
)
6 utool
= getToolByName(context
, 'portal_url')
7 pptool
= getToolByName(context
, 'portal_photo_print')
8 form
= context
.REQUEST
.form
.copy()
11 context
.REQUEST
.RESPONSE
.setHeader('Content-Type', 'text/xml;;charset=utf-8');
15 orderTemplate
= pptool
.addPrintOrderTemplate( context
17 , description
=fg('description')
18 , productReference
=fg('productReference')
19 , maxCopies
=fg('maxCopies')
21 , VATRate
=fg('VATRate')
24 templateOptions
['o'] = orderTemplate
26 if context
.printingOptions
.getObjectPosition(orderTemplate
.getId()) % 2 == 0 :
28 templateOptions
['classRowName'] = classRowName
29 templateOptions
['portal_url'] = utool()
30 widget
= context
.get_photo_print_order_template(**templateOptions
).encode('utf-8').strip()
31 return '<computedField type="added">%s</computedField>' % widget
34 return '<error>%s</error>' % _(e
)
37 context
.REQUEST
.RESPONSE
.setHeader('Content-Type', 'text/xml;;charset=utf-8');
40 orderTemplate
= pptool
.editPrintOrderTemplate(context
, id, **form
)
43 templateOptions
['o'] = orderTemplate
45 if context
.printingOptions
.getObjectPosition(orderTemplate
.getId()) % 2 == 0 :
47 templateOptions
['classRowName'] = classRowName
48 templateOptions
['portal_url'] = utool()
49 widget
= context
.get_photo_print_order_template(**templateOptions
).encode('utf-8').strip()
50 return '<computedField type="edited">%s</computedField>' % widget
51 except ValueError, e
:
52 return '<error>%s</error>' % _(e
)
54 elif createOptionsContainer
:
55 pptool
.createPrintingOptionsContainer(context
)
56 context
.setStatus(True, _('Printing options added.'))
58 elif deleteOptionContainer
:
59 pptool
.deletePrintingOptionsContainer(context
)
60 context
.setStatus(True, _('Printing options deleted.'))
64 options
['pptool'] = pptool
65 options
['hasPO'] = pptool
.hasPrintingOptions(context
)
66 pOptionsSrc
= pptool
.getPrintingOptionsSrc(context
)
68 pourl
= pOptionsSrc
.getActionInfo('object/printing_settings')['url']
71 options
['pourl'] = pourl
73 return context
.photoprint_templates_edit_template(**options
)