Commit b2d6c146 authored by Romain Courteaud's avatar Romain Courteaud

erp5_forge: commit from xhtml_style and from erp5js

parent 2061bb75
kw = {} import json
request = container.REQUEST
for k in 'added', 'modified', 'removed': context.log('BusinessTemplate_viewVcsStatusDialog\nchnagelog %s\npush %s\nadded %s\nmodified %s\nremoved %s\njson %s\nkw %s' % (changelog, push, added, modified, removed, commit_json, str(kw)))
file_list = request.get(k, ())
commit_dict = json.loads(commit_json) if commit_json is not None else {
'added': (),
'modified': (),
'removed': (),
'changelog': '',
'push': False
}
for key, file_list in (('added', added), ('modified', modified), ('removed', removed)):
if file_list is not None:
# XXX: ERP5VCS_doCreateJavaScriptStatus should send lists # XXX: ERP5VCS_doCreateJavaScriptStatus should send lists
if isinstance(file_list, basestring): if isinstance(file_list, basestring):
file_list = file_list != 'none' and filter(None, file_list.split(',')) or () file_list = file_list != 'none' and filter(None, file_list.split(',')) or ()
kw[k] = file_list commit_dict[key] = file_list
if changelog is not None:
commit_dict['changelog'] = changelog
if push is not None:
commit_dict['push'] = push
# Remover keys used when handling commit exception
commit_dict.pop('caller', None)
commit_dict.pop('caller_kw', None)
# Always propage all informations throught formulator hidden field
request = context.REQUEST
request.form['your_commit_json'] = json.dumps(commit_dict)
request.form['your_added'] = commit_dict['added']
request.form['your_modified'] = commit_dict['modified']
request.form['your_removed'] = commit_dict['removed']
changelog = request.get('changelog', '') if commit_dict['changelog'].strip():
if not changelog.strip(): request.form['your_changelog'] = commit_dict['changelog']
else:
from Products.ERP5Type.Message import translateString from Products.ERP5Type.Message import translateString
error_msg = "Please set a ChangeLog message." error_msg = "Please set a ChangeLog message."
return context.asContext(**kw).Base_renderForm('BusinessTemplate_viewVcsChangelog', keep_items={ # return context.asContext(**kw).Base_renderForm('BusinessTemplate_viewVcsChangelog', keep_items={
return context.Base_renderForm('BusinessTemplate_viewVcsChangelog', keep_items={
'portal_status_message': translateString(error_msg), 'portal_status_message': translateString(error_msg),
'cancel_url': context.absolute_url() + 'cancel_url': context.absolute_url() +
'/BusinessTemplate_viewVcsStatus?do_extract:int=0' '/BusinessTemplate_viewVcsStatus?do_extract:int=0'
...@@ -19,6 +49,12 @@ if not changelog.strip(): ...@@ -19,6 +49,12 @@ if not changelog.strip():
}) })
try: try:
return context.getVcsTool().commit(changelog, **kw) return context.getVcsTool().commit(
commit_dict['changelog'],
commit_dict['push'],
added=commit_dict['added'],
modified=commit_dict['modified'],
removed=commit_dict['removed']
)
except Exception, error: except Exception, error:
return context.BusinessTemplate_handleException(error, script.id) return context.BusinessTemplate_handleException(error, script.id, commit_dict=commit_dict)
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>**kw</string> </value> <value> <string>push=None, changelog=None, added=None, modified=None, removed=None, commit_json=None, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
if caller_kw is None:
caller_kw = {}
context.getVcsTool().setLogin(auth, user, password) context.getVcsTool().setLogin(auth, user, password)
return context.restrictedTraverse(caller)(**caller_kw) import json
commit_dict = json.loads(commit_json)
context.log('BusinessTemplate_doVcsLogin\ndict %s' % str(commit_dict))
return context.restrictedTraverse(commit_dict['caller'].encode())(commit_json=commit_json)# XXX**commit_dict['caller_kw'])
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>user, password, auth, caller, caller_kw=None, added=(), modified=(), removed=(), changelog=None, **kw</string> </value> <value> <string>user, password, auth, commit_json, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
from erp5.component.module.Git import GitLoginError from erp5.component.module.Git import GitLoginError
from erp5.component.module.SubversionClient import SubversionSSLTrustError, SubversionLoginError from erp5.component.module.SubversionClient import SubversionSSLTrustError, SubversionLoginError
import json
try: try:
raise exception raise exception
...@@ -16,5 +17,12 @@ except GitLoginError, e: ...@@ -16,5 +17,12 @@ except GitLoginError, e:
kw = dict(remote_url=context.getVcsTool().getRemoteUrl()) kw = dict(remote_url=context.getVcsTool().getRemoteUrl())
method = 'BusinessTemplate_viewGitLogin' method = 'BusinessTemplate_viewGitLogin'
context.REQUEST.set('portal_status_message', message) commit_dict['caller'] = caller
return context.asContext(**kw).Base_renderForm(method, caller=caller, caller_kw=caller_kw) # XXX caller_kw
# Always propage all informations throught formulator hidden field
request = context.REQUEST
request.form['your_commit_json'] = json.dumps(commit_dict)
return context.Base_renderForm(method, keep_items={
'portal_status_message': message
})
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>exception, caller, **caller_kw</string> </value> <value> <string>exception, caller, commit_dict, **caller_kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
...@@ -78,7 +78,9 @@ ...@@ -78,7 +78,9 @@
<item> <item>
<key> <string>bottom</string> </key> <key> <string>bottom</string> </key>
<value> <value>
<list/> <list>
<string>your_commit_json</string>
</list>
</value> </value>
</item> </item>
<item> <item>
......
...@@ -125,7 +125,7 @@ ...@@ -125,7 +125,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string>here/remote_url</string> </value> <value> <string>python: context.getVcsTool().getRemoteUrl()</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
...@@ -64,6 +64,7 @@ ...@@ -64,6 +64,7 @@
<value> <value>
<list> <list>
<string>center</string> <string>center</string>
<string>bottom</string>
</list> </list>
</value> </value>
</item> </item>
...@@ -71,6 +72,14 @@ ...@@ -71,6 +72,14 @@
<key> <string>groups</string> </key> <key> <string>groups</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list>
<string>your_commit_json</string>
</list>
</value>
</item>
<item> <item>
<key> <string>center</string> </key> <key> <string>center</string> </key>
<value> <value>
......
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>editable</string> </key> <key> <string>editable</string> </key>
<value> <int>1</int> </value> <value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>field_id</string> </key>
......
...@@ -53,6 +53,10 @@ ...@@ -53,6 +53,10 @@
<key> <string>tales</string> </key> <key> <string>tales</string> </key>
<value> <value>
<dictionary> <dictionary>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>field_id</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
...@@ -65,6 +69,10 @@ ...@@ -65,6 +69,10 @@
<key> <string>target</string> </key> <key> <string>target</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary> </dictionary>
</value> </value>
</item> </item>
...@@ -74,7 +82,7 @@ ...@@ -74,7 +82,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>editable</string> </key> <key> <string>editable</string> </key>
<value> <int>1</int> </value> <value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>field_id</string> </key>
......
...@@ -82,7 +82,7 @@ ...@@ -82,7 +82,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>editable</string> </key> <key> <string>editable</string> </key>
<value> <int>1</int> </value> <value> <int>0</int> </value>
</item> </item>
<item> <item>
<key> <string>field_id</string> </key> <key> <string>field_id</string> </key>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment