Working publication system:
Upload of a new module to TinyERP.com works. TODO: Modification of a module (detection done) Create and upload a .ZIP file bzr revid: fp@tinyerp.com-eb4ec461b6c6d6ebc7ca878d85ae7d25c61cf883
This commit is contained in:
parent
458aa657a6
commit
b18bc7bf21
|
@ -5,15 +5,15 @@
|
|||
"website" : "http://tinyerp.com",
|
||||
"category" : "Generic Modules/Base",
|
||||
"description": """
|
||||
This module can be used by developpers to automatically publish their modules
|
||||
in a few click to the following websites:
|
||||
* http://TinyERP.com, section module
|
||||
* http://TinyForge.org
|
||||
* PyPi, The python offical repository
|
||||
* http://Freshmeat.net
|
||||
This module can be used by developpers to automatically publish their modules
|
||||
in a few click to the following websites:
|
||||
* http://TinyERP.com, section module
|
||||
* http://TinyForge.org
|
||||
* PyPi, The python offical repository
|
||||
* http://Freshmeat.net
|
||||
|
||||
It adds a button "Publish module" on each module, so that you simply have
|
||||
to call this button when you want to release a new version of your module.
|
||||
It adds a button "Publish module" on each module, so that you simply have
|
||||
to call this button when you want to release a new version of your module.
|
||||
""",
|
||||
"depends" : ["base"],
|
||||
"init_xml" : [ ],
|
||||
|
|
|
@ -29,6 +29,7 @@ import time
|
|||
import wizard
|
||||
import osv
|
||||
import pooler
|
||||
import urllib
|
||||
|
||||
intro_form = '''<?xml version="1.0"?>
|
||||
<form string="Module publication">
|
||||
|
@ -50,15 +51,35 @@ Thank you for contributing !
|
|||
"""},
|
||||
}
|
||||
|
||||
def _get_selection(*Args):
|
||||
a = urllib.urlopen('http://www.tinyerp.com/mtree_interface.php')
|
||||
contents = a.read()
|
||||
content = filter(None, contents.split('\n'))
|
||||
return map(lambda x:x.split('='), content)
|
||||
|
||||
|
||||
check_form = '''<?xml version="1.0"?>
|
||||
<form string="Module publication">
|
||||
<separator string="Verify your module information" colspan="4"/>
|
||||
<field name="name"/>
|
||||
<field name="version"/>
|
||||
<field name="author"/>
|
||||
<field name="website" widget="url"/>
|
||||
<field name="shortdesc" colspan="3"/>
|
||||
<field name="description" colspan="3"/>
|
||||
<notebook>
|
||||
<page string="General">
|
||||
<field name="name"/>
|
||||
<field name="version"/>
|
||||
<field name="author"/>
|
||||
<field name="website" widget="url"/>
|
||||
<field name="shortdesc"/>
|
||||
<field name="operation"/>
|
||||
<field name="category"/>
|
||||
<field name="licence"/>
|
||||
<field name="url_download"/>
|
||||
<label colspan="2" string="(Keep empty for an auto upload of the module)"/>
|
||||
<field name="docurl"/> <label colspan="2" string="(empty to keep existing value)"/>
|
||||
<field name="demourl"/> <label colspan="2" string="(empty to keep existing value)"/>
|
||||
<field name="image"/> <label colspan="2" string="(support only .png files)"/>
|
||||
</page><page string="Description">
|
||||
<field name="description" colspan="3"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>'''
|
||||
|
||||
check_fields = {
|
||||
|
@ -67,35 +88,11 @@ check_fields = {
|
|||
'author': {'string':'Author', 'type':'char', 'size':128, 'readonly':True},
|
||||
'website': {'string':'Website', 'type':'char', 'size':200, 'readonly':True},
|
||||
'url': {'string':'Download URL', 'type':'char', 'size':200, 'readonly':True},
|
||||
'image': {'string':'Image file', 'type':'binary'},
|
||||
'description': {'string':'Description', 'type':'text', 'readonly':True},
|
||||
'version': {'string':'Version', 'type':'char', 'readonly':True},
|
||||
}
|
||||
|
||||
|
||||
upload_info_form = '''<?xml version="1.0"?>
|
||||
<form string="Module publication">
|
||||
<separator string="User information" colspan="4"/>
|
||||
<label align="0.0" string="Please provide here your login on the Tiny ERP website." colspan="4"/>
|
||||
<label align="0.0" string="If you don't have an access, you can create one online." colspan="4"/>
|
||||
<field name="login"/>
|
||||
<newline/>
|
||||
<field name="password"/>
|
||||
<separator string="Module information" colspan="4"/>
|
||||
<field name="category"/>
|
||||
<field name="licence"/>
|
||||
<field name="url_download"/>
|
||||
<label align="0.0" colspan="2" string="(Keep empty for an auto upload of the module)"/>
|
||||
</form>'''
|
||||
|
||||
def _get_selection(*Args):
|
||||
import urllib
|
||||
a = urllib.urlopen('http://www.tinyerp.com/mtree_interface.php')
|
||||
res = filter(None, a.read().split('\n'))
|
||||
return map(lambda x:x.split('='), res)
|
||||
|
||||
upload_info_fields = {
|
||||
'login': {'string':'Login', 'type':'char', 'size':32, 'required':True},
|
||||
'password': {'string':'Password', 'type':'char', 'size':32, 'required':True},
|
||||
'demourl': {'string':'Demo URL', 'type':'char', 'size':100},
|
||||
'docurl': {'string':'Documentation URL', 'type':'char', 'size':100},
|
||||
'category': {'string':'Category', 'type':'selection', 'size':64, 'required':True,
|
||||
'selection': _get_selection
|
||||
},
|
||||
|
@ -104,13 +101,54 @@ upload_info_fields = {
|
|||
'selection': [('GPL', 'GPL'), ('Other proprietary','Other proprietary')],
|
||||
'default': lambda *args: 'GPL'
|
||||
},
|
||||
'operation': {
|
||||
'string':'Operation',
|
||||
'type':'selection',
|
||||
'readonly':True,
|
||||
'selection':[('0','Creation'),('1','Modification')],
|
||||
},
|
||||
'url_download': {'string':'Download URL', 'type':'char', 'size':128},
|
||||
}
|
||||
|
||||
|
||||
upload_info_form = '''<?xml version="1.0"?>
|
||||
<form string="Module publication">
|
||||
<separator string="User information" colspan="4"/>
|
||||
<label align="0.0" string="Please provide here your login on the Tiny ERP website." colspan="4"/>
|
||||
<label align="0.0" string="If you don't have an access, you can create one http://tinyerp.com." colspan="4"/>
|
||||
<field name="login"/>
|
||||
<field name="password"/>
|
||||
<newline/>
|
||||
<field name="email"/>
|
||||
</form>'''
|
||||
|
||||
def _get_edit(self, cr, uid, datas, *args):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
name = pool.get('ir.module.module').read(cr, uid, [datas['id']], ['name'])[0]['name']
|
||||
a = urllib.urlopen('http://www.tinyerp.com/mtree_interface.php?module=%s' % (name,))
|
||||
content = a.read()
|
||||
try:
|
||||
email = self.pool.get('res.users').browse(cr, uid, uid).address.email or ''
|
||||
except:
|
||||
email =''
|
||||
return {'operation': content[0], 'email':email}
|
||||
|
||||
|
||||
upload_info_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 = '''<?xml version="1.0"?>
|
||||
<form string="Module publication">
|
||||
<separator string="Publication result" colspan="4"/>
|
||||
<field name="text_end" colspan="4" nolabel="1"/>
|
||||
<notebook>
|
||||
<page string="Information">
|
||||
<field name="text_end" colspan="4" nolabel="1"/>
|
||||
</page><page string="Result">
|
||||
<field name="result" colspan="4" nolabel="1"/>
|
||||
</page>
|
||||
</notebook>
|
||||
</form>'''
|
||||
|
||||
end_fields = {
|
||||
|
@ -121,8 +159,82 @@ Your module has been successfully uploaded to the official website.
|
|||
You must wait a few hours/days so that the Tiny ERP core team review
|
||||
your module for approval on the website.
|
||||
"""},
|
||||
'result': {'string':'Result page', 'type':'text', 'readonly':True}
|
||||
}
|
||||
|
||||
import httplib, mimetypes
|
||||
|
||||
def post_multipart(host, selector, fields, files):
|
||||
def encode_multipart_formdata(fields, files):
|
||||
BOUNDARY = '----------ThIs_Is_tHe_bouNdaRY_$'
|
||||
CRLF = '\r\n'
|
||||
L = []
|
||||
for (key, value) in fields:
|
||||
L.append('--' + BOUNDARY)
|
||||
L.append('Content-Disposition: form-data; name="%s"' % key)
|
||||
L.append('')
|
||||
L.append(value)
|
||||
for (key,value) in files:
|
||||
L.append('--' + BOUNDARY)
|
||||
L.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (key, key+'.png'))
|
||||
L.append('Content-Type: application/octet-stream')
|
||||
L.append('')
|
||||
L.append(value)
|
||||
L.append('--' + BOUNDARY + '--')
|
||||
L.append('')
|
||||
body = CRLF.join(L)
|
||||
content_type = 'multipart/form-data; boundary=%s' % BOUNDARY
|
||||
return content_type, body
|
||||
content_type, body = encode_multipart_formdata(fields, files)
|
||||
import httplib
|
||||
|
||||
headers = {"Content-type": content_type, "Accept": "*/*"}
|
||||
conn = httplib.HTTPConnection(host)
|
||||
conn.request("POST", selector, body, headers = headers)
|
||||
response = conn.getresponse()
|
||||
val = response.status
|
||||
res = response.read()
|
||||
print res
|
||||
print host, selector, val
|
||||
conn.close()
|
||||
return res
|
||||
|
||||
|
||||
def _upload(self, cr, uid, datas, context):
|
||||
download = datas['form']['downloadurl'] or ''
|
||||
if not download:
|
||||
# Create a .ZIP file and send them online
|
||||
# Set the download url to this .ZIP file
|
||||
download = '/'
|
||||
lpool = pooler.get_pool(cr.dbname)
|
||||
mod = pool.get('ir.module.module').browse(cr, uid, datas['id'])
|
||||
updata = {
|
||||
'link_name': mod.shortdesc or '',
|
||||
'new_cat_id': datas['form']['category'],
|
||||
'link_desc': (mod.description or '').replace('\n','<br/>\n'),
|
||||
'website': mod.website or '',
|
||||
'price': '0.0',
|
||||
'email': datas['form']['email'] or '',
|
||||
'cust_1': download,
|
||||
'cust_2': datas['form']['demourl'] or '', # Put here the download url
|
||||
'cust_3': mod.url or '/',
|
||||
'cust_4': datas['form']['docurl'] or '',
|
||||
'cust_5': datas['form']['licence'] or '',
|
||||
'cust_6': mod.latest_version or '',
|
||||
'cust_7': mod.name,
|
||||
'option': 'com_mtree',
|
||||
'task': 'savelisting',
|
||||
'Itemid': '99999999',
|
||||
'cat_id': '0',
|
||||
'adminForm': '',
|
||||
'auto_login': datas['form']['login'],
|
||||
'auto_password': datas['form']['password']
|
||||
}
|
||||
files = []
|
||||
if datas['form']['image']:
|
||||
files.append(('link_image', datas['form']['image']))
|
||||
result = post_multipart('www.tinyerp.com', '/index.php', updata.items(), [])
|
||||
return {'result': result}
|
||||
|
||||
def module_check(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
|
@ -152,7 +264,7 @@ class base_module_publish(wizard.interface):
|
|||
}
|
||||
},
|
||||
'step1': {
|
||||
'actions': [module_check],
|
||||
'actions': [module_check,_get_edit],
|
||||
'result': {
|
||||
'type':'form',
|
||||
'arch':check_form,
|
||||
|
@ -178,7 +290,7 @@ class base_module_publish(wizard.interface):
|
|||
}
|
||||
},
|
||||
'publish': {
|
||||
'actions': [], # Action to develop: upload method
|
||||
'actions': [_upload], # Action to develop: upload method
|
||||
'result': {
|
||||
'type':'form',
|
||||
'arch':end_form,
|
||||
|
|
Loading…
Reference in New Issue