From bddfc31eaf67003a04f79f7cf168b8d840920fd6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Beno=C3=AEt=20Pin?= Date: Mon, 25 Oct 2010 22:04:49 +0200 Subject: [PATCH 1/1] Copie de photoprint depuis : URL: http://svn.luxia.fr/svn/labo/projects/zope/photoprint/trunk Repository Root: http://svn.luxia.fr/svn/labo Repository UUID: 7eb47c9a-6e02-46bb-968b-2b2bf1974b8d Revision: 1390 Node Kind: directory Schedule: normal Last Changed Author: pin Last Changed Rev: 1357 Last Changed Date: 2009-09-07 18:06:05 +0200 (Lun, 07 sep 2009) --- __init__.py | 31 ++ _utils/import_printing_list.py | 108 ++++ cart.py | 166 ++++++ configure.zcml | 37 ++ exceptions.py | 21 + graphics/tampon.psd | Bin 0 -> 565807 bytes interfaces.py | 76 +++ locales/fr/LC_MESSAGES/photoprint.mo | Bin 0 -> 10391 bytes locales/fr/LC_MESSAGES/photoprint.po | 574 ++++++++++++++++++++ locales/photoprint-manual.pot | 85 +++ locales/photoprint.pot | 567 +++++++++++++++++++ order.py | 517 ++++++++++++++++++ permissions.py | 37 ++ permissions.zcml | 18 + price.py | 95 ++++ skins/confirm_join_template.pt | 31 ++ skins/customer_add_control.py | 57 ++ skins/customer_join_form.py | 57 ++ skins/customer_join_template.pt | 131 +++++ skins/customer_login_form.pt | 100 ++++ skins/get_photo_print_order_template.pt | 6 + skins/my_orders.py | 75 +++ skins/my_orders_template.pt | 40 ++ skins/order_cancel_form.pt | 66 +++ skins/order_list.py | 95 ++++ skins/order_list_template.pt | 56 ++ skins/order_manual_payment_form.pt | 33 ++ skins/order_notify_done_form.pt | 30 + skins/order_notify_sent_form.pt | 79 +++ skins/order_payment_template.pt | 19 + skins/order_printing_list.py | 39 ++ skins/order_printing_list_template.pt | 45 ++ skins/order_printing_list_template_xml.pt | 34 ++ skins/order_states/canceled-en.gif | Bin 0 -> 2665 bytes skins/order_states/canceled-fr.gif | Bin 0 -> 2580 bytes skins/order_states/done-en.gif | Bin 0 -> 2150 bytes skins/order_states/done-fr.gif | Bin 0 -> 2764 bytes skins/order_states/paid-en.gif | Bin 0 -> 2054 bytes skins/order_states/paid-fr.gif | Bin 0 -> 2278 bytes skins/order_states/recorded-en.gif | Bin 0 -> 2722 bytes skins/order_states/recorded-fr.gif | Bin 0 -> 3011 bytes skins/order_states/refused-en.gif | Bin 0 -> 2546 bytes skins/order_states/refused-fr.gif | Bin 0 -> 2576 bytes skins/order_states/sent-en.gif | Bin 0 -> 2152 bytes skins/order_states/sent-fr.gif | Bin 0 -> 2645 bytes skins/order_view.py | 62 +++ skins/order_view_template.pt | 207 +++++++ skins/personalize_form.pt | 101 ++++ skins/photoprint_templates_edit_form.py | 73 +++ skins/photoprint_templates_edit_template.pt | 170 ++++++ tool.gif | Bin 0 -> 166 bytes tool.py | 284 ++++++++++ utils.py | 37 ++ 53 files changed, 4259 insertions(+) create mode 100755 __init__.py create mode 100755 _utils/import_printing_list.py create mode 100644 cart.py create mode 100644 configure.zcml create mode 100755 exceptions.py create mode 100644 graphics/tampon.psd create mode 100755 interfaces.py create mode 100644 locales/fr/LC_MESSAGES/photoprint.mo create mode 100644 locales/fr/LC_MESSAGES/photoprint.po create mode 100644 locales/photoprint-manual.pot create mode 100644 locales/photoprint.pot create mode 100755 order.py create mode 100755 permissions.py create mode 100644 permissions.zcml create mode 100755 price.py create mode 100644 skins/confirm_join_template.pt create mode 100755 skins/customer_add_control.py create mode 100755 skins/customer_join_form.py create mode 100644 skins/customer_join_template.pt create mode 100644 skins/customer_login_form.pt create mode 100644 skins/get_photo_print_order_template.pt create mode 100755 skins/my_orders.py create mode 100644 skins/my_orders_template.pt create mode 100644 skins/order_cancel_form.pt create mode 100755 skins/order_list.py create mode 100644 skins/order_list_template.pt create mode 100644 skins/order_manual_payment_form.pt create mode 100644 skins/order_notify_done_form.pt create mode 100644 skins/order_notify_sent_form.pt create mode 100644 skins/order_payment_template.pt create mode 100755 skins/order_printing_list.py create mode 100644 skins/order_printing_list_template.pt create mode 100644 skins/order_printing_list_template_xml.pt create mode 100644 skins/order_states/canceled-en.gif create mode 100644 skins/order_states/canceled-fr.gif create mode 100644 skins/order_states/done-en.gif create mode 100644 skins/order_states/done-fr.gif create mode 100644 skins/order_states/paid-en.gif create mode 100644 skins/order_states/paid-fr.gif create mode 100644 skins/order_states/recorded-en.gif create mode 100644 skins/order_states/recorded-fr.gif create mode 100644 skins/order_states/refused-en.gif create mode 100644 skins/order_states/refused-fr.gif create mode 100644 skins/order_states/sent-en.gif create mode 100644 skins/order_states/sent-fr.gif create mode 100755 skins/order_view.py create mode 100644 skins/order_view_template.pt create mode 100755 skins/personalize_form.pt create mode 100755 skins/photoprint_templates_edit_form.py create mode 100644 skins/photoprint_templates_edit_template.pt create mode 100644 tool.gif create mode 100755 tool.py create mode 100755 utils.py diff --git a/__init__.py b/__init__.py new file mode 100755 index 0000000..72d13c0 --- /dev/null +++ b/__init__.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +############################################################ +# Copyright © 2009 Benoît PIN # +# Cliché - http://luxia.fr # +# # +# This program is free software; you can redistribute it # +# and/or modify it under the terms of the Creative Commons # +# "Attribution-Noncommercial 2.0 Generic" # +# http://creativecommons.org/licenses/by-nc/2.0/ # +############################################################ +""" +Photo print product. Used to order photo prints. + +$Id: __init__.py 1100 2009-06-01 21:48:59Z pin $ +$URL: http://svn.luxia.fr/svn/labo/projects/zope/photoprint/trunk/__init__.py $ +""" +from Products.CMFCore import utils as cmfutils +import tool +import utils +import order +import cart +import exceptions + + +tools = (tool.PhotoPrintTool,) + +def initialize(registrar) : + cmfutils.ToolInit('Photoprint Tool', + tools = tools, + icon = 'tool.gif' + ).initialize(registrar) diff --git a/_utils/import_printing_list.py b/_utils/import_printing_list.py new file mode 100755 index 0000000..5e8e303 --- /dev/null +++ b/_utils/import_printing_list.py @@ -0,0 +1,108 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +#################################################### +# Copyright © 2009 Luxia SAS. All rights reserved. # +# # +# Contributors: # +# - Benoît Pin # +#################################################### +""" +Downloads RSS based order description and make a local human readable file tree +to facilitate printing tasks. + +$Id: import_printing_list.py 1153 2009-06-12 14:07:29Z pin $ +$URL: http://svn.luxia.fr/svn/labo/projects/zope/photoprint/trunk/_utils/import_printing_list.py $ +""" + + +from urllib2 import HTTPBasicAuthHandler +from urllib2 import build_opener +from urllib2 import urlopen +from xml.dom.minidom import parseString +from xml.dom import Node +from os import mkdir, chdir +from os.path import abspath, join, expanduser, exists +from getpass import getpass + +ELEMENT_NODE = Node.ELEMENT_NODE + +def getHttpOpener(url, login, password) : + auth_handler = HTTPBasicAuthHandler() + host = '/'.join(url.split('/', 3)[:3]) + auth_handler.add_password('Zope', host, login, password) + opener = build_opener(auth_handler) + return opener + +def getXml(url, opener) : + url = '%s?disable_cookie_login__=1' % url + xml = opener.open(url).read() + return xml + +def genFileTree(url, login, password, dest) : + opener = getHttpOpener(url, login, password) + xml = getXml(url, opener) + d = parseString(xml) + doc = d.documentElement + + channel = doc.getElementsByTagName('channel')[0] + orderName = getContentOf(channel, 'title') + + chdir(dest) + mkdir(orderName) + + for item in iterElementChildsByTagName(d.documentElement, 'item') : + ppTitle = getContentOf(item, 'pp:title') + ppQuantity = getContentOf(item, 'pp:quantity') + + printTypePath = join(orderName, ppTitle) + printQuantityPath = join(orderName, ppTitle, ppQuantity) + + if not exists(printTypePath) : + mkdir(printTypePath) + infoFile = open(join(printTypePath, 'info.txt'), 'w') + infoFile.write(getContentOf(item, 'pp:title')) + infoFile.write('\n\n') + infoFile.write(getContentOf(item, 'pp:description')) + infoFile.close() + + if not exists(printQuantityPath) : + mkdir(printQuantityPath) + + hdUrl = '%s?disable_cookie_login__=1' % getContentOf(item, 'link') + localFileName = getContentOf(item, 'title') + print localFileName + localFile = open(join(printQuantityPath, localFileName), 'w') + localFile.write(opener.open(hdUrl).read()) + localFile.close() + +def iterElementChildsByTagName(parent, tagName) : + child = parent.firstChild + while child : + if child.nodeType == ELEMENT_NODE and child.tagName == tagName : + yield child + child = child.nextSibling + +def getContentOf(parent, tagName) : + child = parent.firstChild + while child : + if child.nodeType == ELEMENT_NODE and child.tagName == tagName : + return child.firstChild.nodeValue.encode('utf-8') + child = child.nextSibling + + raise ValueError("%r tag not found" % tagName) + + +def main() : + url = raw_input('url flux xml de la commande : ') + login = raw_input('login : ') + password = getpass('mot de passe : ') + dest = raw_input('cible [~/Desktop]') + if not dest : + dest = expanduser('~/Desktop') + + genFileTree(url, login, password, dest) + +if __name__ == '__main__' : + main() + + diff --git a/cart.py b/cart.py new file mode 100644 index 0000000..fef5a85 --- /dev/null +++ b/cart.py @@ -0,0 +1,166 @@ +# -*- coding: utf-8 -*- +#################################################### +# Copyright © 2009 Luxia SAS. All rights reserved. # +# # +# Contributors: # +# - Benoît Pin # +#################################################### +""" Cart definition used to store buyable prints + +$Id$ +$URL$ +""" +from Globals import InitializeClass, Persistent, PersistentMapping +from Acquisition import Implicit +from AccessControl import ModuleSecurityInfo +from Products.CMFCore.utils import getToolByName +from exceptions import SoldOutError, CartLockedError +from tool import COPIES_COUNTERS +from order import CopiesCounters + +from logging import getLogger +console = getLogger('Products.photoprint.cart') + +CART_ITEM_KEYS = ['cmf_uid', 'printing_template', 'quantity'] + +msecurity = ModuleSecurityInfo('Products.photoprint.cart') +msecurity.declarePublic('PrintCart') + +class PrintCart(Persistent, Implicit) : + """ + items are store like that: + {: + {