Commit 4f97b2b1 authored by Romain Courteaud's avatar Romain Courteaud

erp5_forge: drop the vcs_dialog page template

Use usual ERP5 page template to commit bt5 changes from ERP5.

Use an hidden field to propagate all needed input values in case of an exception.
This single field will keep a json value, to simplify the maintainance of all forms using it (instead of many string fields).

Stop accessing the REQUEST directly, and rely on ERP5 navigation scripts (like Base_redirect) instead.
parent e28c0d3c
......@@ -16,13 +16,13 @@
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_action</string>
<string>action_type/object_jio_action</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_action</string> </value>
<value> <string>object_jio_action</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
......
......@@ -32,7 +32,6 @@ from AccessControl.SecurityInfo import ModuleSecurityInfo
from Acquisition import aq_base
from DateTime import DateTime
from Products.ERP5Type.Message import translateString
from ZTUtils import make_query
from erp5.component.module.WorkingCopy import \
WorkingCopy, NotAWorkingCopyError, NotVersionedError, Dir, File, selfcached
......@@ -321,10 +320,8 @@ class Git(WorkingCopy):
return self.git('rev-parse', '--short', 'HEAD') + '+'
return self.git('rev-parse', 'HEAD')
def commit(self, changelog, added=(), modified=(), removed=()):
def commit(self, changelog, push, added=(), modified=(), removed=()):
context = self.aq_parent
request = context.REQUEST
push = request.get('push')
reset = 1
if push:
# if we can't push because we are not up-to-date, we'll either 'merge' or
......@@ -390,9 +387,9 @@ class Git(WorkingCopy):
portal_status_message = translateString(
'Files committed successfully in revision ${revision}',
mapping=dict(revision=head))
return request.RESPONSE.redirect('%s/view?%s' % (
context.absolute_url_path(),
make_query(portal_status_message=portal_status_message)))
return context.Base_redirect('view', keep_items={
'portal_status_message': portal_status_message
})
def log(self, path='.'):
log = []
......
from ZTUtils import make_query
from Products.ERP5Type.Message import translateString
form_results = context.BusinessTemplate_viewCreateWorkingCopy.validate_all(REQUEST)
working_copy = form_results['your_repository']
context.getVcsTool(path=working_copy).createBusinessTemplateWorkingCopy()
query_string = make_query(portal_status_message='Business Template Working Copy created')
REQUEST.response.redirect('%s/BusinessTemplate_viewVcsStatus?%s' %
(context.absolute_url_path(), query_string))
return context.Base_redirect('BusinessTemplate_viewVcsStatus', keep_items=dict(
portal_status_message=translateString('Business Template Working Copy created')
))
kw = {}
request = container.REQUEST
for k in 'added', 'modified', 'removed':
file_list = request.get(k, ())
# XXX: ERP5VCS_doCreateJavaScriptStatus should send lists
if isinstance(file_list, basestring):
file_list = file_list != 'none' and filter(None, file_list.split(',')) or ()
kw[k] = file_list
changelog = request.get('changelog', '')
if not changelog.strip():
import json
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
if isinstance(file_list, basestring):
file_list = file_list != 'none' and filter(None, file_list.split(',')) or ()
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 information 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']
if commit_dict['changelog'].strip():
request.form['your_changelog'] = commit_dict['changelog']
else:
from Products.ERP5Type.Message import translateString
error_msg = "Please set a ChangeLog message."
request.set('portal_status_message', translateString(error_msg))
request.set('cancel_url', context.absolute_url() +
'/BusinessTemplate_viewVcsStatus?do_extract:int=0'
'&portal_status_message=Commit%20cancelled.')
return context.asContext(**kw).BusinessTemplate_viewVcsChangelog()
return context.Base_renderForm('BusinessTemplate_viewVcsChangelog', keep_items={
'portal_status_message': translateString(error_msg),
'cancel_url': context.absolute_url() +
'/BusinessTemplate_viewVcsStatus?do_extract:int=0'
'&portal_status_message=Commit%20cancelled.'
})
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:
return context.BusinessTemplate_handleException(error, script.id)
return context.BusinessTemplate_handleException(error, script.id, commit_dict)
......@@ -50,7 +50,7 @@
</item>
<item>
<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>
<key> <string>id</string> </key>
......
if caller_kw is None:
caller_kw = {}
context.getVcsTool().setLogin(auth, user, password)
return context.restrictedTraverse(caller)(**caller_kw)
import json
commit_dict = json.loads(commit_json)
return context.restrictedTraverse(commit_dict['caller'].encode())(commit_json=commit_json)
......@@ -50,7 +50,7 @@
</item>
<item>
<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>
<key> <string>id</string> </key>
......
import json
commit_dict = json.loads(commit_json) if commit_json is not None else {
'keep': keep
}
if keep:
commit_dict['keep'] = keep
try:
new_bt = context.getVcsTool().update(keep)
new_bt = context.getVcsTool().update(commit_dict['keep'])
except Exception, error:
return context.BusinessTemplate_handleException(
error, script.id, form_id=form_id, keep=keep)
error, script.id, commit_dict)
request = context.REQUEST
request.set('portal_status_message', 'Working copy updated successfully.')
return request.RESPONSE.redirect(
'%s/BusinessTemplate_viewInstallationDialog?workflow_action=install_action&form_id=%s'
% (new_bt.absolute_url_path(), form_id))
return new_bt.Base_redirect('BusinessTemplate_viewInstallationDialog', keep_items={
'portal_status_message': 'Working copy updated successfully.',
'workflow_action': 'install_action',
'form_id': 'view'
})
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>form_id=\'view\', keep=False</string> </value>
<value> <string>commit_json=None, keep=False</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
from erp5.component.module.Git import GitLoginError
from erp5.component.module.SubversionClient import SubversionSSLTrustError, SubversionLoginError
import json
try:
raise exception
......@@ -16,5 +17,11 @@ except GitLoginError, e:
kw = dict(remote_url=context.getVcsTool().getRemoteUrl())
method = 'BusinessTemplate_viewGitLogin'
context.REQUEST.set('portal_status_message', message)
return getattr(context.asContext(**kw), method)(caller=caller, caller_kw=caller_kw)
commit_dict['caller'] = caller
# Always propage all information throught formulator hidden field
request = context.REQUEST
request.form['your_commit_json'] = json.dumps(commit_dict)
return context.asContext(**kw).Base_renderForm(method, keep_items={
'portal_status_message': message
})
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>exception, caller, **caller_kw</string> </value>
<value> <string>exception, caller, commit_dict</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......
......@@ -37,6 +37,10 @@
<key> <string>action</string> </key>
<value> <string>BusinessTemplate_doVcsLogin</string> </value>
</item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
......@@ -74,7 +78,9 @@
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
<list>
<string>your_commit_json</string>
</list>
</value>
</item>
<item>
......@@ -123,7 +129,7 @@
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>vcs_dialog</string> </value>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
......
......@@ -37,6 +37,10 @@
<key> <string>action</string> </key>
<value> <string>BusinessTemplate_doVcsLogin</string> </value>
</item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
......@@ -61,6 +65,8 @@
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
</list>
</value>
</item>
......@@ -68,6 +74,20 @@
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list>
<string>your_commit_json</string>
</list>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
......@@ -102,7 +122,7 @@
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>vcs_dialog</string> </value>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
......
......@@ -37,6 +37,10 @@
<key> <string>action</string> </key>
<value> <string>BusinessTemplate_doSvnSslTrust</string> </value>
</item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
......@@ -61,6 +65,8 @@
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
</list>
</value>
</item>
......@@ -68,6 +74,20 @@
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list>
<string>your_commit_json</string>
</list>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
......@@ -113,7 +133,7 @@
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>vcs_dialog</string> </value>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
......
......@@ -37,6 +37,10 @@
<key> <string>action</string> </key>
<value> <string>BusinessTemplate_doVcsCommit</string> </value>
</item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
......@@ -60,6 +64,7 @@
<value>
<list>
<string>center</string>
<string>bottom</string>
</list>
</value>
</item>
......@@ -67,6 +72,14 @@
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list>
<string>your_commit_json</string>
</list>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
......@@ -74,9 +87,9 @@
<string>your_push</string>
<string>your_changelog</string>
<string>reminder</string>
<string>added_files</string>
<string>modified_files</string>
<string>removed_files</string>
<string>your_added</string>
<string>your_modified</string>
<string>your_removed</string>
</list>
</value>
</item>
......@@ -97,7 +110,7 @@
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>vcs_dialog</string> </value>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
......
......@@ -10,7 +10,6 @@
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>editable</string>
<string>title</string>
</list>
......@@ -18,7 +17,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>added_files</string> </value>
<value> <string>your_added</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -55,10 +54,8 @@
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
......@@ -72,6 +69,10 @@
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......@@ -79,12 +80,6 @@
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
......@@ -111,17 +106,4 @@
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.added</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -10,7 +10,6 @@
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>editable</string>
<string>title</string>
</list>
......@@ -18,7 +17,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>modified_files</string> </value>
<value> <string>your_modified</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -55,10 +54,8 @@
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
......@@ -72,6 +69,10 @@
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......@@ -79,12 +80,6 @@
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
......@@ -111,17 +106,4 @@
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.modified</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -10,7 +10,6 @@
<key> <string>delegated_list</string> </key>
<value>
<list>
<string>default</string>
<string>editable</string>
<string>title</string>
</list>
......@@ -18,7 +17,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>removed_files</string> </value>
<value> <string>your_removed</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
......@@ -55,10 +54,8 @@
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>field_id</string> </key>
......@@ -72,6 +69,10 @@
<key> <string>target</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
......@@ -79,12 +80,6 @@
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>default</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</int> </value>
......@@ -111,17 +106,4 @@
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.removed</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -37,6 +37,10 @@
<key> <string>action</string> </key>
<value> <string>BusinessTemplate_doVcsMultiDiff</string> </value>
</item>
<item>
<key> <string>action_title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
......@@ -110,7 +114,7 @@
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>vcs_dialog</string> </value>
<value> <string>form_dialog</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>vcs_dialog</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<tal:block xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:metal="http://xml.zope.org/namespaces/metal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n">
<tal:block define="local_parameter_list python: dict((x, request[x])
for x in ('added', 'modified', 'removed', 'changelog', 'push')
if x in request);
dummy python: local_parameter_list.update((x, options.pop(x))
for x in ('caller', 'caller_kw')
if x in options)"
tal:on-error="structure python: here.BusinessTemplate_handleException(error.value, context.id)">
<tal:block metal:use-macro="here/form_dialog/macros/master" />
</tal:block>
</tal:block>
\ No newline at end of file
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