source: WAeUP_SRP/base/skins/waeup_directory/getMembersDirectoryActions.py @ 2471

Last change on this file since 2471 was 2348, checked in by Henrik Bettermann, 17 years ago

show 'Search Mewmbers' and 'Create New Member' for MemberAdmins? only

  • Property svn:keywords set to Id
File size: 2.4 KB
Line 
1##parameters=mode
2#$Id: getMembersDirectoryActions.py 2348 2007-10-11 10:28:55Z henrik $
3"""
4Get the actions to provide on members directory view
5
6Return the updated actions
7"""
8try:
9    from Products.zdb import set_trace
10except:
11    def set_trace():
12        pass
13
14from Products.CMFCore.utils import getToolByName
15request = context.REQUEST
16qstring = request.get('QUERY_STRING','')
17if qstring:
18    id = ''
19    for par in qstring.split('&'):
20        if par.startswith('id='):
21            id = par[3:]
22else:
23    id = request.form.get('id','')
24utool = getToolByName(context, 'portal_url')
25dtool = getToolByName(context, 'portal_directories')
26base_url = utool.getBaseUrl()
27renderActionIcon = context.portal_cpsportlets.renderActionIcon
28dirname  = 'members'
29dir = getattr(dtool,'members')
30actions_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                )
51ad = {}
52for 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                    }
64if not dtool.members.isSectionOfficer():                   
65    return [ad['view_action'],
66            ad['edit_action']
67           ]
68                   
69if mode in ['view', 'edit']:
70    return [ad['view_action'],
71            ad['edit_action'],
72            ad['create_action'],
73            ad['search_action']
74           ]
75elif mode in ['create']:
76    return [ad['search_action'],]
77return [ad['create_action'],]
Note: See TracBrowser for help on using the repository browser.