base,kernel,base_module_publish: improve publication of module, add repository, etc...
- add repository for module - improve version number - add check to remove module - can not upload module with the same version number - add version compare from portage (gentoo) - add release in context of eval - add active = True to base module - add wizard to update all installed modules - add check to not upload module that is not installed - add posibility to include source - fix license - now load zip module in preference bzr revid: ced-cd441fca164f32bf2a1243a4ebf8c6afdf240cdf
This commit is contained in:
parent
792fc3cf97
commit
22e5e30532
|
@ -19,6 +19,5 @@ to call this button when you want to release a new version of your module.
|
|||
"init_xml" : [ ],
|
||||
"demo_xml" : [ ],
|
||||
"update_xml" : [ "base_module_publish_wizard.xml" ],
|
||||
"active": True,
|
||||
"installable": True
|
||||
}
|
||||
|
|
|
@ -1,12 +1,20 @@
|
|||
<?xml version="1.0"?>
|
||||
<terp>
|
||||
<data>
|
||||
<wizard
|
||||
<wizard
|
||||
id="wizard_base_module_publish"
|
||||
string="Publish your module"
|
||||
string="Publish module"
|
||||
model="ir.module.module"
|
||||
name="base_module_publish.module_publish"/>
|
||||
|
||||
<wizard
|
||||
id="wizard_base_module_publish_all"
|
||||
string="Publish all modules"
|
||||
model="ir.module.module"
|
||||
name="base_module_publish.module_publish_all"
|
||||
client_action_multi="True"
|
||||
/>
|
||||
|
||||
<wizard
|
||||
string="Export module"
|
||||
model="ir.module.module"
|
||||
|
|
|
@ -6,17 +6,13 @@
|
|||
fclose($fp);
|
||||
}
|
||||
|
||||
// Check module name
|
||||
if (strcmp(substr($_FILES['module']['name'],-4,4),'.zip')) {
|
||||
return '0';
|
||||
}
|
||||
|
||||
$port=mysql_connect(":/var/run/mysqld/mysqld.sock","tiny","XXXX");
|
||||
// Verify user and password
|
||||
$query = mysql_db_query("tiny_terp", "select id,password from jos_users where username='".addslashes($_POST['login'])."' and password=md5('".addslashes($_POST['password'])."')");
|
||||
$user = mysql_fetch_object($query);
|
||||
if (!$user) {
|
||||
return "0";
|
||||
echo "1\n";
|
||||
return;
|
||||
}
|
||||
|
||||
// Verify module owner
|
||||
|
@ -26,9 +22,17 @@
|
|||
if ((!$row) or $row[0]==$user[0]) {
|
||||
// save .zip module
|
||||
$dest = '/home/tiny/www/tinyerp.com/download/modules/'.$_FILES['module']['name'];
|
||||
if(move_uploaded_file($_FILES['module']['tmp_name'], $dest)) {
|
||||
} else{
|
||||
if (!file_exists($dest)) {
|
||||
if(move_uploaded_file($_FILES['module']['tmp_name'], $dest)) {
|
||||
echo "0\n";
|
||||
return;
|
||||
} else{
|
||||
echo "3\n";
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
echo "2\n";
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -27,4 +27,5 @@
|
|||
##############################################################################
|
||||
|
||||
import base_module_publish
|
||||
import base_module_publish_all
|
||||
import wizard_module_export
|
||||
|
|
|
@ -51,7 +51,7 @@ Make sure you read the publication manual and modules guidelines
|
|||
before continuing:
|
||||
http://www.tinyerp.com
|
||||
|
||||
Thank you for contributing !
|
||||
Thank you for contributing!
|
||||
"""},
|
||||
}
|
||||
|
||||
|
@ -237,6 +237,13 @@ def _upload(self, cr, uid, datas, context):
|
|||
], [
|
||||
('module', res['module_filename'], res['module_file'])
|
||||
])
|
||||
if result[0] == "1":
|
||||
raise wizard.except_wizard('Error', 'Login failed!')
|
||||
elif result[0] == "2":
|
||||
raise wizard.except_wizard('Error',
|
||||
'This version of the module is already exist on the server')
|
||||
elif result[0] != "0":
|
||||
raise wizard.except_wizard('Error', 'Failed to upload the file')
|
||||
|
||||
updata = {
|
||||
'link_name': mod.shortdesc or '',
|
||||
|
@ -250,7 +257,7 @@ def _upload(self, cr, uid, datas, context):
|
|||
'cust_3': mod.url or '/',
|
||||
'cust_4': datas['form']['docurl'] or '',
|
||||
'cust_5': datas['form']['license'] or '',
|
||||
'cust_6': mod.latest_version or '',
|
||||
'cust_6': mod.installed_version or '0',
|
||||
'cust_7': mod.name,
|
||||
'option': 'com_mtree',
|
||||
'task': 'savelisting',
|
||||
|
@ -277,6 +284,8 @@ def _upload(self, cr, uid, datas, context):
|
|||
def module_check(self, cr, uid, data, context):
|
||||
pool = pooler.get_pool(cr.dbname)
|
||||
module = pool.get('ir.module.module').browse(cr, uid, data['id'], context)
|
||||
if module.state != 'installed':
|
||||
raise wizard.except_wizard('Error', 'You could not publish a module that is not installed!')
|
||||
return {
|
||||
'name': module.name,
|
||||
'shortdesc': module.shortdesc,
|
||||
|
@ -284,7 +293,7 @@ def module_check(self, cr, uid, data, context):
|
|||
'website': module.website,
|
||||
'url': module.url,
|
||||
'description': module.description,
|
||||
'version': module.latest_version,
|
||||
'version': module.installed_version,
|
||||
'license': module.license,
|
||||
}
|
||||
|
||||
|
@ -324,7 +333,7 @@ class base_module_publish(wizard.interface):
|
|||
'state':[
|
||||
('end','Cancel'),
|
||||
('step1', 'Previous'),
|
||||
('publish','Publish Now !')
|
||||
('publish','Publish')
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
|
@ -0,0 +1,181 @@
|
|||
##############################################################################
|
||||
#
|
||||
# Copyright (c) 2005-2007 TINY SPRL. (http://tiny.be) All Rights Reserved.
|
||||
#
|
||||
# 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 = '''<?xml version="1.0"?>
|
||||
<form string="Module publication">
|
||||
<separator string="Publication information" colspan="4"/>
|
||||
<field name="text" colspan="4" nolabel="1"/>
|
||||
</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.tinyerp.com/
|
||||
|
||||
Thanks you for contributing!
|
||||
"""},
|
||||
}
|
||||
|
||||
login_form = '''<?xml version="1.0"?>
|
||||
<form string="Module publication">
|
||||
<separator string="User information" colspan="4"/>
|
||||
<label string="Please provide here your login on the Tiny ERP website."
|
||||
align="0.0" colspan="4"/>
|
||||
<label string="If you don't have an access, you can create one http://www.tinyerp.com/"
|
||||
align="0.0" colspan="4"/>
|
||||
<field name="login"/>
|
||||
<newline/>
|
||||
<field name="password"/>
|
||||
<newline/>
|
||||
<field name="email"/>
|
||||
</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 = '''<?xml version="1.0"?>
|
||||
<form string="Module publication">
|
||||
<separator string="Upload information" colspan="4"/>
|
||||
<field name="update" colspan="4"/>
|
||||
<field name="already" colspan="4"/>
|
||||
<field name="error" colspan="4"/>
|
||||
</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.tinyerp.com/download/modules/'+res['module_filename']
|
||||
result = post_multipart('www.tinyerp.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','<br/>\n'),
|
||||
'website': mod.website or '',
|
||||
'email': datas['form']['email'] or '',
|
||||
'cust_1': download,
|
||||
'cust_3': mod.url or '/',
|
||||
'cust_6': mod.installed_version or '0',
|
||||
'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']
|
||||
}
|
||||
a = urlopen('http://www.tinyerp.com/mtree_interface.php?module=%s' % (mod.name,))
|
||||
aa = a.read()
|
||||
if aa[0]<>'0':
|
||||
updata['link_id']=aa.split('\n')[0]
|
||||
updata['option'] = 'mtree'
|
||||
result = post_multipart('www.tinyerp.com', '/index.php', updata.items(), [])
|
||||
return {'update': '\n'.join(log[0]), 'already': '\n'.join(log[1]),
|
||||
'error': '\n'.join(log[2])}
|
||||
|
||||
class base_module_publish_all(wizard.interface):
|
||||
states = {
|
||||
'init': {
|
||||
'actions': [],
|
||||
'result': {
|
||||
'type': 'form',
|
||||
'arch': intro_form,
|
||||
'fields': intro_fields,
|
||||
'state': [
|
||||
('end', 'Cancel'),
|
||||
('login', 'Ok'),
|
||||
]
|
||||
}
|
||||
},
|
||||
'login': {
|
||||
'actions': [],
|
||||
'result': {
|
||||
'type': 'form',
|
||||
'arch': login_form,
|
||||
'fields': login_fields,
|
||||
'state': [
|
||||
('end', 'Cancel'),
|
||||
('publish', 'Publish')
|
||||
]
|
||||
}
|
||||
},
|
||||
'publish': {
|
||||
'actions': [_upload],
|
||||
'result': {
|
||||
'type': 'form',
|
||||
'arch': end_form,
|
||||
'fields': end_fields,
|
||||
'state': [
|
||||
('end', 'Close')
|
||||
]
|
||||
}
|
||||
},
|
||||
}
|
||||
base_module_publish_all('base_module_publish.module_publish_all')
|
|
@ -11,7 +11,7 @@ import base64
|
|||
def _zippy(archive, fromurl, path, src=True):
|
||||
url = os.path.join(fromurl, path)
|
||||
if os.path.isdir(url):
|
||||
if path.split('/')[-1]=='.svn':
|
||||
if path.split('/')[-1].startswith('.'):
|
||||
return False
|
||||
for fname in os.listdir(url):
|
||||
_zippy(archive, fromurl, path and os.path.join(path, fname) or fname, src=src)
|
||||
|
@ -27,7 +27,7 @@ def _zippy(archive, fromurl, path, src=True):
|
|||
def createzip(cr, uid, moduleid, context, b64enc=True, src=True):
|
||||
module_obj=pooler.get_pool(cr.dbname).get('ir.module.module')
|
||||
module_name = module_obj.browse(cr, uid, moduleid).name
|
||||
module_version = module_obj.browse(cr, uid, moduleid).latest_version
|
||||
module_version = module_obj.browse(cr, uid, moduleid).installed_version
|
||||
|
||||
ad = tools.config['addons_path']
|
||||
if os.path.isdir(os.path.join(ad,module_name)):
|
||||
|
@ -41,8 +41,8 @@ def createzip(cr, uid, moduleid, context, b64enc=True, src=True):
|
|||
elif os.path.isfile(os.path.join(ad,module_name+'.zip')):
|
||||
val = file(os.path.join(ad,module_name+'.zip'),'rb').read()
|
||||
else:
|
||||
raise wizard.except_wizard('Error !', 'Could not find the module to export !')
|
||||
raise wizard.except_wizard('Error', 'Could not find the module to export!')
|
||||
if b64enc:
|
||||
val =base64.encodestring(val)
|
||||
return {'module_file':val, 'module_filename': module_name+'-'+(module_version or 'x')+'.zip'}
|
||||
return {'module_file':val, 'module_filename': module_name+'-'+(module_version or '0')+'.zip'}
|
||||
|
||||
|
|
Loading…
Reference in New Issue