Commit d08aec98 authored by Romain Courteaud's avatar Romain Courteaud Committed by Rafael Monnerat

Allow to proxify to form with the same ID

parent 2d63d709
...@@ -769,6 +769,54 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate): ...@@ -769,6 +769,54 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
# FTP/DAV Access # FTP/DAV Access
manage_FTPget = ZMIForm.get_xml manage_FTPget = ZMIForm.get_xml
def PUT(self, REQUEST, RESPONSE):
"""Handle HTTP PUT requests."""
self.dav__init(REQUEST, RESPONSE)
self.dav__simpleifhandler(REQUEST, RESPONSE, refresh=1)
if REQUEST.environ['REQUEST_METHOD'] != 'PUT':
raise Forbidden('REQUEST_METHOD should be PUT.')
body=REQUEST.get('BODY', '')
# Empty the form (XMLToForm is unable to empty things before reopening)
for k in self.get_field_ids():
try:
self._delObject(k)
except AttributeError:
pass
self.groups = {}
self.group_list = []
# And reimport
XMLToForm(body, self)
self.ZCacheable_invalidate()
RESPONSE.setStatus(204)
return RESPONSE
manage_FTPput = PUT
security.declarePrivate('getSimilarSkinFolderIdList')
def getSimilarSkinFolderIdList(self):
"""
Find other skins id installed in the same time
"""
portal = self.getPortalObject()
folder_id = self.aq_parent.id
# Find a business template which manages the context skin folder.
folder_id_set = {folder_id}
for template in portal.portal_templates.getInstalledBusinessTemplateList():
template_skin_id_list = template.getTemplateSkinIdList()
if folder_id in template_skin_id_list:
folder_id_set.update(template_skin_id_list)
# Find folders which can be surcharged by this skin folder
if '_' in folder_id:
surcharged_folder_id = 'erp5_%s' % folder_id.split('_', 1)[-1]
if (surcharged_folder_id != folder_id) and \
(getattr(portal.portal_skins, surcharged_folder_id, None) \
is not None):
folder_id_set.add(surcharged_folder_id)
break
return list(folder_id_set)
#Methods for Proxify tab. #Methods for Proxify tab.
security.declareProtected('View management screens', 'getFormFieldList') security.declareProtected('View management screens', 'getFormFieldList')
def getFormFieldList(self): def getFormFieldList(self):
...@@ -782,7 +830,7 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate): ...@@ -782,7 +830,7 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
if (i.meta_type=='ERP5 Form' and if (i.meta_type=='ERP5 Form' and
i.id.startswith('Base_view') and i.id.startswith('Base_view') and
i.id.endswith('FieldLibrary') and i.id.endswith('FieldLibrary') and
'_view' in i.getId()): '_view' in i.getId()) or (i.id == self.id):
form_id = i.getId() form_id = i.getId()
form_path = '%s.%s' % (obj.getId(), form_id) form_path = '%s.%s' % (obj.getId(), form_id)
field_list = [] field_list = []
...@@ -1061,7 +1109,17 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate): ...@@ -1061,7 +1109,17 @@ class ERP5Form(Base, ZMIForm, ZopePageTemplate):
for field_id in field_dict.keys(): for field_id in field_dict.keys():
target = field_dict[field_id] target = field_dict[field_id]
target_form_id, target_field_id = target.split('.') target_list = target.split('.')
if len(target_list) == 2:
target_form_id, target_field_id = target_list
elif len(target_list) == 3:
target_field_id = target_list[2]
if target_list[1] == self.id:
target_form_id = '/'.join(target_list[:2])
else:
target_form_id = target_list[1]
else:
raise NotImplementedError("Not supported path: %s" % target)
# keep current group and position. # keep current group and position.
group, position = get_group_and_position(field_id) group, position = get_group_and_position(field_id)
......
...@@ -49,7 +49,7 @@ Keep empty values <input type="checkbox" name="keep_empty_value"> <br/> ...@@ -49,7 +49,7 @@ Keep empty values <input type="checkbox" name="keep_empty_value"> <br/>
field_id="field_object.getId()" field_id="field_object.getId()"
field_type="item['field_type']" field_type="item['field_type']"
proxy_mark="item['proxy_flag'] and ' (Proxy)' or ''"> proxy_mark="item['proxy_flag'] and ' (Proxy)' or ''">
<option value="<dtml-var "'%s.%s' % (form_id, field_id)">"> <option value="<dtml-var "'%s.%s' % (form_path, field_id)">">
<dtml-var "'%s%s' % (field_id, proxy_mark)"> <dtml-var "'%s%s' % (field_id, proxy_mark)">
</option> </option>
</dtml-let> </dtml-let>
......
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