Commit 255d239c authored by Sebastien Robin's avatar Sebastien Robin

many updates so that we can do selection on many pages


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@519 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 91214ab6
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# Updates attributes of an Zope document # Updates attributes of an Zope document
# which is in a class inheriting from ERP5 Base # which is in a class inheriting from ERP5 Base
sdmlkjsdmlkjfdsdfmlj()
request=context.REQUEST request=context.REQUEST
o = context.portal_catalog.getObject(object_uid) o = context.portal_catalog.getObject(object_uid)
...@@ -60,6 +60,8 @@ try: ...@@ -60,6 +60,8 @@ try:
kw['portal_type'] = my_field.get_value('portal_type') kw['portal_type'] = my_field.get_value('portal_type')
request.set('base_category', base_category) request.set('base_category', base_category)
request.set('portal_type', my_field.get_value('portal_type')) request.set('portal_type', my_field.get_value('portal_type'))
request.set('form_id', 'search_relation')
request.set('form_toto', 'search_relation')
request.set(my_field.get_value('catalog_index'), request.get( my_field.id, None)) request.set(my_field.get_value('catalog_index'), request.get( my_field.id, None))
relation_list = context.portal_catalog(**kw) relation_list = context.portal_catalog(**kw)
if len(relation_list) > 0: if len(relation_list) > 0:
......
## Script (Python) "base_folder_delete" ## Script (Python) "base_folder_delete"
##title=Delete objects from a folder ##title=Delete objects from a folder
##parameters=selection_index=None,form_id='',uids=None,ids=None,form_from=None ##parameters=selection_index=None,form_id='',uids=[], listbox_uid=[],selection_name=''
request=context.REQUEST request=context.REQUEST
selection_index=None
#return uids #return uids
#request.set('uid',uids) selected_uids = context.portal_selections.updateSelectionCheckedUidList(selection_name,listbox_uid,uids)
#request.set('reset',1) uids = context.portal_selections.getSelectionCheckedUidsFor(selection_name)
#request.set('portal_type','Tissu')
kw = {'uid': uids} kw = {'uid': uids}
request.set('object_uid', context.getUid()) request.set('object_uid', context.getUid())
request.set('uids', uids)
context.portal_selections.setSelectionParamsFor('folder_delete_selection', kw) context.portal_selections.setSelectionParamsFor('folder_delete_selection', kw)
return context.folder_delete_view(REQUEST=request, uid=uids) #return context.folder_delete_view(REQUEST=request, uid=uids)
\ No newline at end of file return context.folder_delete_view(uids=uids, REQUEST=request)
...@@ -26,7 +26,8 @@ if dialog_method == 'update_relation': ...@@ -26,7 +26,8 @@ if dialog_method == 'update_relation':
selection_name=selection_name, selection_name=selection_name,
selection_index=request.get('selection_index'), selection_index=request.get('selection_index'),
object_uid=request.get('object_uid'), object_uid=request.get('object_uid'),
uids=request.get('uids')) uids=request.get('uids'),
listbox_uid=request.get('listbox_uid'))
if dialog_method == 'base_create_relation': if dialog_method == 'base_create_relation':
return context.base_create_relation(form_id=form_id, return context.base_create_relation(form_id=form_id,
selection_name=selection_name, selection_name=selection_name,
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
from Products.Formulator.Errors import ValidationError, FormValidationError from Products.Formulator.Errors import ValidationError, FormValidationError
from cgi import escape
from ZTUtils import make_query
...@@ -15,6 +17,7 @@ request=context.REQUEST ...@@ -15,6 +17,7 @@ request=context.REQUEST
base_category = None base_category = None
o = context.portal_catalog.getObject(object_uid) o = context.portal_catalog.getObject(object_uid)
redirect_url = None
if o is None: if o is None:
return "Sorrry, Error, the calling object was not catalogued. Do not know how to do ?" return "Sorrry, Error, the calling object was not catalogued. Do not know how to do ?"
...@@ -119,7 +122,20 @@ try: ...@@ -119,7 +122,20 @@ try:
selection_name = selection_name, selection_name = selection_name,
uids = uids, uids = uids,
object_uid = object_uid) object_uid = object_uid)
return o.search_relation( REQUEST=request ) kw = {}
kw['form_id'] = 'search_relation'
kw['selection_index'] = selection_index
kw['object_uid'] = object_uid
kw['field_id'] = my_field.id
kw['portal_type'] = portal_type
kw['base_category'] = base_category
kw['selection_name'] = 'search_relation'
kw['cancel_url'] = request.get('HTTP_REFERER')
kw['previous_form_id'] = form_id
redirect_url = '%s/%s?%s' % ( o.absolute_url()
, 'search_relation'
, make_query(kw)
)
else: else:
request.set('catalog_index', my_field.get_value('catalog_index')) request.set('catalog_index', my_field.get_value('catalog_index'))
if my_field.meta_type == 'MultiRelationStringField': if my_field.meta_type == 'MultiRelationStringField':
...@@ -137,12 +153,13 @@ except FormValidationError, validation_errors: ...@@ -137,12 +153,13 @@ except FormValidationError, validation_errors:
else: else:
message = 'Relation+Unchanged.' message = 'Relation+Unchanged.'
if not selection_index: if redirect_url is None:
if not selection_index:
redirect_url = '%s/%s?%s' % ( o.absolute_url() redirect_url = '%s/%s?%s' % ( o.absolute_url()
, form_id , form_id
, 'portal_status_message=%s' % message , 'portal_status_message=%s' % message
) )
else: else:
redirect_url = '%s/%s?selection_index=%s&selection_name=%s&%s' % ( o.absolute_url() redirect_url = '%s/%s?selection_index=%s&selection_name=%s&%s' % ( o.absolute_url()
, form_id , form_id
, selection_index , selection_index
......
##parameters=form_id ##parameters=form_id, uids=[], listbox_uid=[],selection_name=''
selected_uids = context.portal_selections.updateSelectionCheckedUidList(selection_name,listbox_uid,uids)
uids = context.portal_selections.getSelectionCheckedUidsFor(selection_name)
# make sure nothing is checked after
context.portal_selections.setSelectionCheckedUidsFor(selection_name, [])
REQUEST=context.REQUEST REQUEST=context.REQUEST
if REQUEST.has_key('ids'): # Do we still needs ids ???
context.manage_copyObjects(ids=REQUEST['ids'], REQUEST=REQUEST, RESPONSE=REQUEST.RESPONSE) #if REQUEST.has_key('ids'):
return REQUEST.RESPONSE.redirect(context.absolute_url() + '/' + form_id + '?portal_status_message=Item(s)+Copied.') # context.manage_copyObjects(ids=REQUEST['ids'], REQUEST=REQUEST, RESPONSE=REQUEST.RESPONSE)
elif REQUEST.has_key('uids'): # return REQUEST.RESPONSE.redirect(context.absolute_url() + '/' + form_id + '?portal_status_message=Item(s)+Copied.')
context.manage_copyObjects(uids=REQUEST['uids'], REQUEST=REQUEST, RESPONSE=REQUEST.RESPONSE) #elif REQUEST.has_key('uids'):
if uids != []:
#context.manage_copyObjects(uids=REQUEST['uids'], REQUEST=REQUEST, RESPONSE=REQUEST.RESPONSE)
context.manage_copyObjects(uids=uids, REQUEST=REQUEST, RESPONSE=REQUEST.RESPONSE)
return REQUEST.RESPONSE.redirect(context.absolute_url() + '/' + form_id + '?portal_status_message=Item(s)+Copied.') return REQUEST.RESPONSE.redirect(context.absolute_url() + '/' + form_id + '?portal_status_message=Item(s)+Copied.')
else: else:
return REQUEST.RESPONSE.redirect(context.absolute_url() + '/' + form_id + '?portal_status_message=Please+select+one+or+more+items+to+copy+first.') return REQUEST.RESPONSE.redirect(context.absolute_url() + '/' + form_id + '?portal_status_message=Please+select+one+or+more+items+to+copy+first.')
## Script (Python) "folder_cut" ## Script (Python) "folder_cut"
##title=Cut objects from a folder and copy to the clipboard ##title=Cut objects from a folder and copy to the clipboard
##parameters= ##parameters=form_id,selection_name='',uids=[],listbox_uid=[]
selected_uids = context.portal_selections.updateSelectionCheckedUidList(selection_name,listbox_uid,uids)
uids = context.portal_selections.getSelectionCheckedUidsFor(selection_name)
# make sure nothing is checked after
context.portal_selections.setSelectionCheckedUidsFor(selection_name, [])
REQUEST=context.REQUEST REQUEST=context.REQUEST
if REQUEST.has_key('ids'): # do we still need ids ? XXX finish the work here
context.manage_cutObjects(REQUEST['ids'], REQUEST) #if REQUEST.has_key('ids'):
return REQUEST.RESPONSE.redirect(context.absolute_url() + '/' + form_id + '/folder_contents?portal_status_message=Item(s)+Cut.') # context.manage_cutObjects(REQUEST['ids'], REQUEST)
elif REQUEST.has_key('uids'): # return REQUEST.RESPONSE.redirect(context.absolute_url() + '/' + form_id + '/folder_contents?portal_status_message=Item(s)+Cut.')
context.manage_cutObjects(uids=REQUEST['uids'], REQUEST=REQUEST) #elif REQUEST.has_key('uids'):
if uids != []:
#context.manage_cutObjects(uids=REQUEST['uids'], REQUEST=REQUEST)
context.manage_cutObjects(uids=uids, REQUEST=REQUEST)
return REQUEST.RESPONSE.redirect(context.absolute_url() + '/' + form_id + '?portal_status_message=Item(s)+Cut.') return REQUEST.RESPONSE.redirect(context.absolute_url() + '/' + form_id + '?portal_status_message=Item(s)+Cut.')
else: else:
return REQUEST.RESPONSE.redirect(context.absolute_url() + '/folder_contents?portal_status_message=Please+select+one+or+more+items+to+cut+first.') return REQUEST.RESPONSE.redirect(context.absolute_url() + '/folder_contents?portal_status_message=Please+select+one+or+more+items+to+cut+first.')
## Script (Python) "folder_delete" ## Script (Python) "folder_delete"
##title=Delete objects from a folder ##title=Delete objects from a folder
##parameters=form_id='',selection_index=None,object_uid=None,selection_name=None,field_id=None,uids=None,cancel_url='' ##parameters=form_id='',selection_index=None,object_uid=None,selection_name=None,field_id=None,uids=None,cancel_url='',listbox_uid=[]
selected_uids = context.portal_selections.updateSelectionCheckedUidList(selection_name,listbox_uid,uids)
uids = context.portal_selections.getSelectionCheckedUidsFor(selection_name)
#return 'uids: %s, ids: %s' % (str(uids),str(ids))
#return form_from
REQUEST=context.REQUEST REQUEST=context.REQUEST
REQUEST.set('uids',uids)
qs = '' qs = ''
ret_url = '' ret_url = ''
if REQUEST.has_key('ids') and (len(REQUEST['ids'])>0): if REQUEST.has_key('uids') and (len(REQUEST['uids'])>0):
ret_url = context.absolute_url() + '/' + form_id
context.manage_delObjects(ids=REQUEST['ids'], REQUEST=REQUEST)
qs = '?portal_status_message=Deleted.'
elif REQUEST.has_key('uids') and (len(REQUEST['uids'])>0):
ret_url = context.absolute_url() + '/' + form_id ret_url = context.absolute_url() + '/' + form_id
context.manage_delObjects(uids=REQUEST['uids'], REQUEST=REQUEST) context.manage_delObjects(uids=REQUEST['uids'], REQUEST=REQUEST)
qs = '?portal_status_message=Deleted.' qs = '?portal_status_message=Deleted.'
......
##parameters=form_id, field_id, selection_index, selection_name, uids, object_uid ##parameters=form_id, field_id, selection_index, selection_name, uids, object_uid, listbox_uid
# Updates attributes of an Zope document # Updates attributes of an Zope document
# which is in a class inheriting from ERP5 Base # which is in a class inheriting from ERP5 Base
...@@ -13,12 +13,20 @@ o = context.portal_catalog.getObject(object_uid) ...@@ -13,12 +13,20 @@ o = context.portal_catalog.getObject(object_uid)
if o is None: if o is None:
return "Sorrry, Error, the calling object was not catalogued. Do not know how to do ?" return "Sorrry, Error, the calling object was not catalogued. Do not know how to do ?"
selected_uids = context.portal_selections.updateSelectionCheckedUidList(selection_name,listbox_uid,uids)
uids = context.portal_selections.getSelectionCheckedUidsFor(selection_name)
if request.has_key('previous_form_id'):
previous_form_id = request.get('previous_form_id')
if previous_form_id != '':
form_id = previous_form_id
form = getattr(context, form_id) form = getattr(context, form_id)
field = form.get_field(field_id) field = form.get_field(field_id)
base_category = field.get_value('base_category') base_category = field.get_value('base_category')
portal_type = map(lambda x:x[0],field.get_value('portal_type')) portal_type = map(lambda x:x[0],field.get_value('portal_type'))
if uids: if uids != []:
# Clear the relation # Clear the relation
o.setValueUids(base_category, (), portal_type=portal_type) o.setValueUids(base_category, (), portal_type=portal_type)
# Warning, portal type is at strange value because of form # Warning, portal type is at strange value because of form
......
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