############################################################################## # # Copyright (c) 2004-2008 TINY SPRL. (http://tiny.be) All Rights Reserved. # # $Id$ # # WARNING: This program as such is intended to be used by professional # programmers who take the whole responsability of assessing all potential # consequences resulting from its eventual inadequacies and bugs # End users who are looking for a ready-to-use solution with commercial # garantees and support are strongly adviced to contract a Free Software # Service Company # # This program is Free Software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ############################################################################## import wizard import pooler import module_zip from base_module_publish import post_multipart from urllib import urlopen intro_form = '''
''' intro_fields = { 'text': {'string': 'Introduction', 'type': 'text', 'readonly': True, 'default': lambda *a: """ This system will automatically publish and upload the selected modules to the Tiny ERP official website. You can use it to quickly update a set of module (new version). Make sure you read the publication manual and modules guidlines before continuing: http://www.openerp.com/ Thanks you for contributing! """}, } login_form = ''' ''' login_fields = { 'login': {'string':'Login', 'type':'char', 'size':32, 'required':True}, 'email': {'string':'Email', 'type':'char', 'size':100, 'required':True}, 'password': {'string':'Password', 'type':'char', 'size':32, 'required':True, 'invisible':True}, } end_form = ''' ''' end_fields= { 'update': {'type': 'text', 'string': 'Modules updated', 'readonly': True}, 'already': {'type': 'text', 'string': 'Modules already updated', 'readonly': True}, 'error': {'type': 'text', 'string': 'Modules in error', 'readonly': True}, } def _upload(self, cr, uid, datas, context): pool = pooler.get_pool(cr.dbname) modules = pool.get('ir.module.module').browse(cr, uid, datas['ids']) log = [[], [], []] # [update, already, error] for mod in modules: # whoooouuuuffff update if mod.state != 'installed': result[2].append(mod.name) continue res = module_zip.createzip(cr, uid, mod.id, context, b64enc=False, src=(mod.license in ('GPL-2'))) download = 'http://www.openerp.com/download/modules/'+res['module_filename'] result = post_multipart('www.openerp.com', '/mtree_upload.php', [('login', datas['form']['login']), ('password', datas['form']['password']), ('module_name', mod.name) ], [('module', res['module_filename'], res['module_file']) ]) if result[0] == "1": raise wizard.except_wizard('Error', 'Login failed!') elif result[0] == "0": log[0].append(mod.name) elif result[0] == "2": log[1].append(mod.name) else: log[2].append(mod.name) updata = { 'link_name': mod.shortdesc or '', 'link_desc': (mod.description or '').replace('\n','