[1901] | 1 | ##parameters=mode |
---|
| 2 | #$Id: getMembersDirectoryActions.py 1906 2007-06-16 13:22:51Z joachim $ |
---|
| 3 | """ |
---|
| 4 | Get the actions to provide on members directory view |
---|
| 5 | |
---|
| 6 | Return the updated actions |
---|
| 7 | """ |
---|
| 8 | try: |
---|
| 9 | from Products.zdb import set_trace |
---|
| 10 | except: |
---|
| 11 | def set_trace(): |
---|
| 12 | pass |
---|
| 13 | |
---|
| 14 | from Products.CMFCore.utils import getToolByName |
---|
| 15 | request = context.REQUEST |
---|
| 16 | qstring = request.get('QUERY_STRING','') |
---|
[1906] | 17 | if qstring: |
---|
| 18 | id = '' |
---|
| 19 | for par in qstring.split('&'): |
---|
| 20 | if par.startswith('id='): |
---|
| 21 | id = par[3:] |
---|
| 22 | else: |
---|
| 23 | id = request.form.get('id','') |
---|
[1901] | 24 | utool = getToolByName(context, 'portal_url') |
---|
| 25 | dtool = getToolByName(context, 'portal_directories') |
---|
| 26 | base_url = utool.getBaseUrl() |
---|
| 27 | renderActionIcon = context.portal_cpsportlets.renderActionIcon |
---|
| 28 | dirname = 'members' |
---|
| 29 | dir = getattr(dtool,'members') |
---|
| 30 | actions_list = (('create_action', |
---|
| 31 | 'new_entry', |
---|
| 32 | 'Create New Member', |
---|
| 33 | base_url+'member_create_form?dirname=members', |
---|
| 34 | ), |
---|
| 35 | ('search_action', |
---|
| 36 | 'search_entry', |
---|
| 37 | 'Search Member', |
---|
| 38 | base_url+'search_members_form?dirname=members', |
---|
| 39 | ), |
---|
| 40 | ('view_action', |
---|
| 41 | 'view_entry', |
---|
| 42 | 'View', |
---|
| 43 | base_url+'member_view?dirname=members'+'&id='+id, |
---|
| 44 | ), |
---|
| 45 | ('edit_action', |
---|
| 46 | 'edit_entry', |
---|
| 47 | 'Edit', |
---|
| 48 | base_url+'member_edit_form?dirname=members'+'&id='+id, |
---|
| 49 | ), |
---|
| 50 | ) |
---|
| 51 | ad = {} |
---|
| 52 | for action_id,name,desc,url in actions_list: |
---|
| 53 | ad[action_id] = { |
---|
| 54 | 'id': name, |
---|
| 55 | 'title': desc, |
---|
| 56 | 'icon_tag': renderActionIcon(action_id= name, |
---|
| 57 | category='object', |
---|
| 58 | base_url=base_url, |
---|
| 59 | alt= name), |
---|
| 60 | 'url': url, |
---|
| 61 | 'name': desc, |
---|
| 62 | 'category': 'object', |
---|
| 63 | } |
---|
| 64 | if mode in ['view', 'edit']: |
---|
| 65 | return [ad['view_action'], |
---|
| 66 | ad['edit_action'], |
---|
| 67 | ad['create_action'], |
---|
| 68 | ad['search_action'] |
---|
| 69 | ] |
---|
| 70 | elif mode in ['create']: |
---|
| 71 | return [ad['search_action'],] |
---|
| 72 | return [ad['create_action'],] |
---|