source: waeup_product/trunk/Extensions/install.py @ 63

Last change on this file since 63 was 60, checked in by joachim, 19 years ago

=install set everything up

  • Property svn:keywords set to Id
File size: 12.7 KB
Line 
1#-*- mode: python; mode: fold -*-
2from Products.CPSInstaller.CPSInstaller import CPSInstaller
3from Products.CMFCore.CMFCorePermissions import View, ModifyPortalContent
4try:
5  from Products.CPSSubscriptions.permissions import CanNotifyContent
6  CPSSubscriptions = True
7except ImportError:
8  CPSSubscriptions = False
9try:
10  from Products.CPSForum.CPSForumPermissions import ForumManageComments
11  CPSForum = True
12except ImportError:
13  CPSForum = False
14
15from Products.WAeUP.Students import addStudentsFolder
16
17class WAeUPInstaller(CPSInstaller):
18    """
19    WAeUP Installer
20    """
21    product_name = "WAeUP"
22
23    def install(self,portal):
24        "install"
25
26        product_name = self.product_name
27        self.log("Starting %(product_name)s install" % vars() )
28   
29        ##########################################
30        # Actions ###(
31        ##########################################
32        if CPSSubscriptions:
33            ptypes = "('Portal', 'CPSMailAccess Message', 'CPSMailAccess Box', 'CPSMailAccess Folder',"\
34                     +  "'University', 'StudentsFolder', 'Student', 'Jamb')"
35            condition = "object.portal_type not in %s" % ptypes
36   
37            action = {'id' : 'notify_content',
38                      'name' : 'action_notify_content',
39                      'action' : 'string:${object_url}/content_notify_email_form',
40                      'condition' : 'python:%s' % condition,
41                      'permission' :  (CanNotifyContent,),
42                      'category' : 'object',
43                      }
44            self.deleteActions({'portal_subscriptions': ['notify_content',]})
45            self.verifyAction('portal_subscriptions', **action)
46        if CPSForum:
47            ptypes = "('University', 'StudentsFolder', 'Student', 'Jamb')"
48            condition = "object.portal_type not in %s" % ptypes
49   
50            action = {'id' : 'activate_comments',
51                      'name': 'action_activate_comments',
52                      'action': 'string:${object/absolute_url}/set_comment_mode?mode=1',
53                      'condition' : 'python:%s' % condition,
54                      'permission': (ForumManageComments,),
55                      'category' : 'object',
56                      }
57            self.deleteActions({'portal_subscriptions': ['activate_comments',]})
58            self.verifyAction('portal_subscriptions', **action)
59            # now portal_discussion
60            self.deleteActions({'portal_discussion': ['comment',
61                                                      'activate_comments',
62                                                      'deactivate_comments',
63                                                      'manage_comments']})
64            action = {'id' : 'comment',
65                      'name': 'action_comment',
66                      'action': "string:${object/absolute_url}/post_comment",
67                      'condition' : "python:getattr(object.getContent(), 'allow_discussion' , None) and object.hasCommentAction()",
68                      'permission': (View,),
69                      'category' : 'object',
70                      }
71            self.verifyAction('portal_discussion', **action)
72            action = {'id' : 'activate_comments',
73                      'name': 'action_activate_comments',
74                      'action': "string:${object/absolute_url}/set_comment_mode?mode=1",
75                      'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1",
76                      'permission': (ForumManageComments,),
77                      'category' : 'object',
78                      }
79            self.verifyAction('portal_discussion', **action)
80            action = {'id' : 'deactivate_comments',
81                      'name': 'action_deactivate_comments',
82                      'action': "string:${object/absolute_url}/set_comment_mode?mode=0",
83                      'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1",
84                      'permission': (ForumManageComments,),
85                      'category' : 'object',
86                      }
87            self.verifyAction('portal_discussion', **action)
88            action = {'id' : 'manage_comments',
89                      'name': 'action_manage_comments',
90                      'action': "string:${object/absolute_url}/manage_comment",
91                      'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1",
92                      'permission': (ForumManageComments,),
93                      'category' : 'object',
94                      }
95            self.verifyAction('portal_discussion', **action)
96       
97        ##########################################
98        # actions
99        ##########################################
100        actions = ( { 'tool'      : 'portal_actions',
101                        'id'        : 'checkadmission',
102                        'name'      : 'Check Admission',
103                        'action'    : 'string:${object/absolute_url}/check_admission',
104                        'permission': (View, ),
105                        'condition' : 'python: not member',
106                        'category'  : 'student',
107                        'visible'   : 1,
108                      },
109##                      { 'tool'      : 'portal_actions',
110##                        'id'        : 'new_student',
111##                        'name'      : 'Add Student',
112##                        'action'    : 'string:${object/absolute_url}/create_student_form',
113##                        'permission': (View),
114##                        'condition' : 'python: 0 and member and here.portal_type == "StudentsFolder"',
115##                        'category'  : 'student',
116##                        'visible'   : 1,
117##                      },
118                      { 'tool'      : 'portal_actions',
119                        'id'        : 'edit_student',
120                        'name'      : 'Edit Student',
121                        'action'    : 'cpsdocument_edit_form',
122                        'permission': ( ),
123                        'condition' : 'python: 0 and member and  here.portal_type == "Student"',
124                        'category'  : 'student',
125                        'visible'   : 1,
126                      },
127                      { 'tool'      : 'portal_actions',
128                        'id'        : 'add_jamb',
129                        'name'      : 'Add Student JAMB',
130                        'action'    : 'string:${object/absolute_url}/create_jamb',
131                        'permission': (),
132                        'condition' : 'python: member and here.portal_type in ("StudentsFolder",) and "StudentManager" in member.getGroups()',
133                        'category'  : 'student',
134                        'visible'   : 1,
135                      },
136                      { 'tool'      : 'portal_actions',
137                        'id'        : 'add_personal',
138                        'name'      : 'Add personal Data',
139                        'action'    : 'string:${object/absolute_url}/create_personal_form',
140                        'permission': (),
141                        'condition' : 'python: 0 and member and not here.portal_type in ("Jamb","StudentsFolder") and not "StudentManager" in member.getGroups()',
142                        'category'  : 'student',
143                        'visible'   : 1,
144                      },
145                      { 'tool'      : 'portal_actions',
146                        'id'        : 'edit_jamb',
147                        'name'      : 'Edit Jamb Data',
148                        'action'    : 'cpsdocument_edit_form',
149                        'permission': ( ),
150                        'condition' : 'python: member and here.portal_type in ("Student",) and "StudentManager" in member.getGroups()',
151                        'category'  : 'student',
152                        'visible'   : 1,
153                      },
154                    )
155        self.verifyActions(actions)
156        ##########################################
157###)
158
159        # skins
160        ##########################################
161        self.log("Verifying %(product_name)s skinss" % vars())
162        wskins = { 'waeup_default' : 'Products/WAeUP/skins/waeup_default',
163                   'waeup_student' : 'Products/WAeUP/skins/waeup_student',
164                 }
165        self.verifySkins(wskins)
166        self.resetSkinCache()
167        ##########################################
168        # portal types
169        ##########################################
170        dtypes = portal.getWAeUPTypes()
171        self.verifyFlexibleTypes(dtypes)
172        self.allowContentTypes('University', ('Workspace','Section',))
173        ##########################################
174        # Schemas
175        ##########################################
176        self.log("Verifying %(product_name)s schemas" % vars())
177        self.verifySchemas(portal.getWAeUPSchemas())
178        ##########################################
179        # widgets
180        ##########################################
181        self.log("Verifying %(product_name)s widgets" % vars())
182        self.verifyWidgets(portal.getWAeUPWidgets())
183        ##########################################
184        # layouts
185        ##########################################
186        self.log("Verifying %(product_name)s layouts" % vars())
187        self.verifyLayouts(portal.getWAeUPLayouts())
188        ##########################################
189        # Vocabularies
190        ##########################################
191        self.log("Verifying %(product_name)s vocabularies" % vars())
192        self.verifyVocabularies(portal.getWAeUPVocabularies())
193        ##########################################
194        # Groups
195        ##########################################
196           
197        self.installCustomWorkflows()
198        self.verifyWorkflowAssociation()
199       
200        self.log("End of specific %(product_name)s install" % vars())
201        self.finalize()
202       
203
204    def installCustomWorkflows(self):
205        """Installs custom workflows
206        """
207        from Products.WAeUP.Workflows.WAeUPWorkflow import \
208             waeupWorkflowsInstall
209
210        waeupWorkflowsInstall(self.context)
211
212
213    def verifyWorkflowAssociation(self):
214        """Verify workflow association
215        """
216        ws_chains = {
217                      'Student': 'waeup_workspace_wf',
218                      'Jamb': 'waeup_workspace_wf',
219                      }
220
221        se_chains = { 'University': 'waeup_section_wf',
222                      'StudentsFolder': 'waeup_section_wf',
223                      'Student': 'waeup_section_wf',
224                      'StudentPersonal': 'waeup_section_wf',
225                      'Jamb': 'waeup_section_wf',
226                      'ScratchCard': 'waeup_section_wf',
227                      }
228
229        self.verifyLocalWorkflowChains(self.portal['workspaces'],
230                                       ws_chains,
231                                       destructive=1)
232        self.verifyLocalWorkflowChains(self.portal['sections'],
233                                       se_chains,
234                                       destructive=1)
235
236
237def install(self):
238    installer = WAeUPInstaller(self)
239    installer.install(self)
240    dirtool = getattr(self,'portal_directories')
241    groups = dirtool.groups
242    for newEntry in ('Students','StudentManager'):
243        if newEntry not in groups.listEntryIds():
244            groups.createEntry({'group': newEntry,
245                                'members': []}) 
246    groups.manage_setLocalGroupRoles(groupid = 'StudentManager',roles=('Manager',))
247    #groups.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',))
248    sections = getattr(self,'sections')
249    waeup = getattr(sections,'waeup',None)
250    if not waeup:
251        sections.content_create(type_name='University',title='waeup')
252        sections.waeup.folder_localrole_add(member_ids=('group:Students',),
253                                            member_role='SectionReviewer',
254                                            )
255        sections.waeup.content_create(type_name='StudentsFolder',title='students')
256        sections.waeup.folder_localrole_add(member_ids=('group:Students',),
257                                            member_role='SectionReviewer',
258                                            )
259        sections.waeup.folder_localrole_add(member_ids=('group:StudentManager',),
260                                            member_role='SectionManager',
261                                            )
262        sections.waeup.students.manage_setLocalGroupRoles(groupid = 'role:Anonymous',roles=('SectionReader',))
263        sections.waeup.students.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',))
264    return installer.logResult()
Note: See TracBrowser for help on using the repository browser.