source: WAeUP_SRP/trunk/skins/waeup_directory/getMembersDirectoryActions.py @ 6411

Last change on this file since 6411 was 2564, checked in by joachim, 17 years ago

make only visible for staff

  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
1## Script (Python) "getMembersDirectoryActions"
2##bind container=container
3##bind context=context
4##bind namespace=
5##bind script=script
6##bind subpath=traverse_subpath
7##parameters=mode
8#$Id: getMembersDirectoryActions.py 2564 2007-11-07 10:50:54Z joachim $
9"""
10Get the actions to provide on members directory view
11
12Return the updated actions
13"""
14try:
15    from Products.zdb import set_trace
16except:
17    def set_trace():
18        pass
19if context.isStudent():
20    return context.REQUEST.RESPONSE.redirect("%s/srp_anonymous_view" % context.portal_url())
21
22from Products.CMFCore.utils import getToolByName
23request = context.REQUEST
24qstring = request.get('QUERY_STRING','')
25if qstring:
26    id = ''
27    for par in qstring.split('&'):
28        if par.startswith('id='):
29            id = par[3:]
30else:
31    id = request.form.get('id','')
32utool = getToolByName(context, 'portal_url')
33dtool = getToolByName(context, 'portal_directories')
34base_url = utool.getBaseUrl()
35renderActionIcon = context.portal_cpsportlets.renderActionIcon
36dirname  = 'members'
37dir = getattr(dtool,'members')
38actions_list = (('create_action',
39                 'new_entry',
40                 'Create New Member',
41                 base_url+'member_create_form?dirname=members',
42                ),
43                ('search_action',
44                'search_entry',
45                'Search Member',
46                 base_url+'search_members_form?dirname=members',
47                ),
48                ('view_action',
49                'view_entry',
50                'View',
51                base_url+'member_view?dirname=members'+'&id='+id,
52                ),
53                ('edit_action',
54                'edit_entry',
55                'Edit',
56                base_url+'member_edit_form?dirname=members'+'&id='+id,
57                ),
58                )
59ad = {}
60for action_id,name,desc,url in actions_list:
61    ad[action_id] = {
62                     'id': name,
63                     'title': desc,
64                     'icon_tag': renderActionIcon(action_id= name,
65                                                  category='object',
66                                                  base_url=base_url,
67                                                  alt= name),
68                     'url': url,
69                     'name': desc,
70                     'category': 'object',
71                    }
72if not dtool.members.isSectionOfficer():                   
73    return [ad['view_action'],
74            ad['edit_action']
75           ]
76                   
77if mode in ['view', 'edit']:
78    return [ad['view_action'],
79            ad['edit_action'],
80            ad['create_action'],
81            ad['search_action']
82           ]
83elif mode in ['create']:
84    return [ad['search_action'],]
85return [ad['create_action'],]
Note: See TracBrowser for help on using the repository browser.