1 ##############################################################################
3 # Copyright (c) 2005-2007 TINY SPRL. (http://tiny.be) All Rights Reserved.
5 # WARNING: This program as such is intended to be used by professional
6 # programmers who take the whole responsability of assessing all potential
7 # consequences resulting from its eventual inadequacies and bugs
8 # End users who are looking for a ready-to-use solution with commercial
9 # garantees and support are strongly adviced to contract a Free Software
12 # This program is Free Software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License
14 # as published by the Free Software Foundation; either version 2
15 # of the License, or (at your option) any later version.
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write to the Free Software
24 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
26 ##############################################################################
31 from base_module_publish import post_multipart
32 from urllib import urlopen
34 intro_form = '''<?xml version="1.0"?>
35 <form string="Module publication">
36 <separator string="Publication information" colspan="4"/>
37 <field name="text" colspan="4" nolabel="1"/>
41 'text': {'string': 'Introduction', 'type': 'text', 'readonly': True,
42 'default': lambda *a: """
43 This system will automatically publish and upload the selected modules to the
44 Tiny ERP official website. You can use it to quickly update a set of
47 Make sure you read the publication manual and modules guidlines
49 http://www.openerp.com/
51 Thanks you for contributing!
55 login_form = '''<?xml version="1.0"?>
56 <form string="Module publication">
57 <separator string="User information" colspan="4"/>
58 <label string="Please provide here your login on the Tiny ERP website."
59 align="0.0" colspan="4"/>
60 <label string="If you don't have an access, you can create one http://www.openerp.com/"
61 align="0.0" colspan="4"/>
64 <field name="password"/>
70 'login': {'string':'Login', 'type':'char', 'size':32, 'required':True},
71 'email': {'string':'Email', 'type':'char', 'size':100, 'required':True},
72 'password': {'string':'Password', 'type':'char', 'size':32, 'required':True,
76 end_form = '''<?xml version="1.0"?>
77 <form string="Module publication">
78 <separator string="Upload information" colspan="4"/>
79 <field name="update" colspan="4"/>
80 <field name="already" colspan="4"/>
81 <field name="error" colspan="4"/>
85 'update': {'type': 'text', 'string': 'Modules updated', 'readonly': True},
86 'already': {'type': 'text', 'string': 'Modules already updated',
88 'error': {'type': 'text', 'string': 'Modules in error', 'readonly': True},
91 def _upload(self, cr, uid, datas, context):
92 pool = pooler.get_pool(cr.dbname)
93 modules = pool.get('ir.module.module').browse(cr, uid, datas['ids'])
94 log = [[], [], []] # [update, already, error]
95 for mod in modules: # whoooouuuuffff update
96 if mod.state != 'installed':
97 result[2].append(mod.name)
99 res = module_zip.createzip(cr, uid, mod.id, context, b64enc=False,
100 src=(mod.license in ('GPL-2')))
101 download = 'http://www.openerp.com/download/modules/'+res['module_filename']
102 result = post_multipart('www.openerp.com', '/mtree_upload.php',
103 [('login', datas['form']['login']),
104 ('password', datas['form']['password']),
105 ('module_name', mod.name)
106 ], [('module', res['module_filename'],
110 raise wizard.except_wizard('Error', 'Login failed!')
111 elif result[0] == "0":
112 log[0].append(mod.name)
113 elif result[0] == "2":
114 log[1].append(mod.name)
116 log[2].append(mod.name)
118 'link_name': mod.shortdesc or '',
119 'link_desc': (mod.description or '').replace('\n','<br/>\n'),
120 'website': mod.website or '',
121 'email': datas['form']['email'] or '',
123 'cust_3': mod.url or '/',
124 'cust_6': mod.installed_version or '0',
126 'option': 'com_mtree',
127 'task': 'savelisting',
128 'Itemid': '99999999',
131 'auto_login': datas['form']['login'],
132 'auto_password': datas['form']['password']
134 a = urlopen('http://www.openerp.com/mtree_interface.php?module=%s' % (mod.name,))
137 updata['link_id']=aa.split('\n')[0]
138 updata['cat_id']=aa.split('\n')[1]
139 updata['option'] = 'mtree'
140 result = post_multipart('www.openerp.com', '/index.php', updata.items(), [])
141 return {'update': '\n'.join(log[0]), 'already': '\n'.join(log[1]),
142 'error': '\n'.join(log[2])}
144 class base_module_publish_all(wizard.interface):
151 'fields': intro_fields,
163 'fields': login_fields,
166 ('publish', 'Publish')
171 'actions': [_upload],
175 'fields': end_fields,
182 base_module_publish_all('base_module_publish.module_publish_all')