source: WAeUP_SRP/trunk/skins/waeup_directory/getWAeUPDirectoryActions.py @ 1813

Last change on this file since 1813 was 1796, checked in by Henrik Bettermann, 18 years ago

some fixes to display the correct object actions
also one fix regarding ticket #214

File size: 2.1 KB
Line 
1##parameters=actions, dirname, dir, mode, id=''
2#$Id: getDirectoryActions.py 25260 2005-07-26 00:41:23Z atchertchian $
3"""
4Get the actions to provide on a directory view
5
6Parameters are:
7- the current actions
8- the directory id
9- the directory itself
10- the mode (create, edit, view or search)
11- the entry id (eventually)
12
13Return the updated actions
14"""
15
16from Products.CMFCore.utils import getToolByName
17
18utool = getToolByName(context, 'portal_url')
19base_url = utool.getBaseUrl()
20
21create_action = {
22    'id': 'new_entry',
23    'url': base_url+'member_create_form?dirname='+dirname,
24    'name': 'cpsdir_label_create_entry',
25    'category': 'object',
26    }
27
28search_action = {
29    'id': 'search_entry',
30    'url': base_url+'search_members_form?dirname='+dirname,
31    'name': 'cpsdir_label_search_entry',
32    'category': 'object'
33    }
34
35view_action = {
36    'id': 'view_entry',
37    'url': base_url+'member_view?dirname='+dirname+'&id='+id,
38    'name': 'cpsdir_label_view_entry',
39    'category': 'object',
40    }
41
42edit_action = {
43    'id': 'edit_entry',
44    'url': base_url+'member_edit_form?dirname='+dirname+'&id='+id,
45    'name': 'cpsdir_label_edit_entry',
46    'category': 'object',
47    'available': True,
48    'visible': True,
49    'allowed': True,
50    'permissions': ('View',),
51    }
52
53confirm_text = context.translation_service('description_confirm_delete')
54confirm_text.encode('ISO-8859-15', 'ignore')
55delete_action = {
56    'id': 'delete_entry',
57    'url': base_url+'member_delete?dirname='+dirname+'&id='+id,
58    'onclick': 'return window.confirm(\''+ confirm_text +'\')' ,
59    'name': 'cpsdir_label_delete_entry',
60    'category': 'object',
61    }
62
63
64# only actions with category 'object' have to be changed
65
66if dir.isSearchEntriesAllowed():
67    actions.update({'object': [search_action]})
68
69if dir.isCreateEntryAllowed():
70    actions['object'].append(create_action)
71
72if mode in ['view', 'edit']:
73    if dir.isViewEntryAllowed(id):
74        actions['object'].append(view_action)
75    if dir.isEditEntryAllowed(id):
76        actions['object'].append(edit_action)
77    if dir.isDeleteEntryAllowed(id):
78        actions['object'].append(delete_action)
79
80return actions
Note: See TracBrowser for help on using the repository browser.