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

Last change on this file since 85 was 84, checked in by joachim, 20 years ago

=Roles and Facultymanagement, new themes used

  • Property svn:keywords set to Id
File size: 17.4 KB
RevLine 
[60]1#-*- mode: python; mode: fold -*-
[72]2# $Id: install.py 84 2005-10-25 16:18:40Z joachim $
[19]3from Products.CPSInstaller.CPSInstaller import CPSInstaller
[20]4from Products.CMFCore.CMFCorePermissions import View, ModifyPortalContent
[84]5from Products.WAeUP.WAeUPPermissions import UniversityManage, StudentManage,FacultyManage,\
6                                            DepartmentManage,CourseManage
[19]7try:
[23]8  from Products.CPSSubscriptions.permissions import CanNotifyContent
[19]9  CPSSubscriptions = True
10except ImportError:
11  CPSSubscriptions = False
12try:
[23]13  from Products.CPSForum.CPSForumPermissions import ForumManageComments
[19]14  CPSForum = True
15except ImportError:
16  CPSForum = False
17
[60]18from Products.WAeUP.Students import addStudentsFolder
19
[19]20class WAeUPInstaller(CPSInstaller):
21    """
22    WAeUP Installer
23    """
24    product_name = "WAeUP"
25
26    def install(self,portal):
27        "install"
28
29        product_name = self.product_name
30        self.log("Starting %(product_name)s install" % vars() )
31   
[84]32        # Roles and Permissions
33        #
34        self.verifyRoles((
35            # A role that can manage the University.
36            'UniversityManager',
37            # A role that can manage the StudentsRecords.
38            'StudentManager',
39            # A role that can manage a Faculty.
40            'FacultyManager',
41            # A role that can manage a department.
42            'DepartmentManager',
43            # A role that can manage a Course.
44            'CourseManager',
45        ))
46        waeup_perms = {
47            UniversityManage:
48                ('Manager', 'SectionManager','UniversityManager',
49                 ),
50            StudentManage:
51                ('Manager', 'SectionManager','UniversityManager', 'StudentManager'
52                 ),
53            FacultyManage:
54                ('Manager', 'SectionManager','UniversityManager', 'FacultyManager'
55                 ),
56            DepartmentManage:
57                ('Manager', 'SectionManager','UniversityManager', 'DepartmentManager'
58                 ),
59            CourseManage:
60                ('Manager', 'SectionManager','UniversityManager', 'CourseManager'
61                 ),
62        }
63        self.setupPortalPermissions(waeup_perms)
64
[19]65        ##########################################
[84]66        # Actions
[19]67        ##########################################
[84]68        if CPSSubscriptions: ###(
[19]69            ptypes = "('Portal', 'CPSMailAccess Message', 'CPSMailAccess Box', 'CPSMailAccess Folder',"\
[45]70                     +  "'University', 'StudentsFolder', 'Student', 'Jamb')"
[19]71            condition = "object.portal_type not in %s" % ptypes
72   
73            action = {'id' : 'notify_content',
74                      'name' : 'action_notify_content',
75                      'action' : 'string:${object_url}/content_notify_email_form',
76                      'condition' : 'python:%s' % condition,
77                      'permission' :  (CanNotifyContent,),
78                      'category' : 'object',
79                      }
80            self.deleteActions({'portal_subscriptions': ['notify_content',]})
81            self.verifyAction('portal_subscriptions', **action)
82        if CPSForum:
[45]83            ptypes = "('University', 'StudentsFolder', 'Student', 'Jamb')"
[19]84            condition = "object.portal_type not in %s" % ptypes
85   
86            action = {'id' : 'activate_comments',
87                      'name': 'action_activate_comments',
88                      'action': 'string:${object/absolute_url}/set_comment_mode?mode=1',
89                      'condition' : 'python:%s' % condition,
90                      'permission': (ForumManageComments,),
91                      'category' : 'object',
92                      }
[57]93            self.deleteActions({'portal_subscriptions': ['activate_comments',]})
[19]94            self.verifyAction('portal_subscriptions', **action)
[57]95            # now portal_discussion
96            self.deleteActions({'portal_discussion': ['comment',
97                                                      'activate_comments',
98                                                      'deactivate_comments',
99                                                      'manage_comments']})
100            action = {'id' : 'comment',
101                      'name': 'action_comment',
102                      'action': "string:${object/absolute_url}/post_comment",
103                      'condition' : "python:getattr(object.getContent(), 'allow_discussion' , None) and object.hasCommentAction()",
104                      'permission': (View,),
105                      'category' : 'object',
106                      }
107            self.verifyAction('portal_discussion', **action)
108            action = {'id' : 'activate_comments',
109                      'name': 'action_activate_comments',
110                      'action': "string:${object/absolute_url}/set_comment_mode?mode=1",
111                      'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1",
112                      'permission': (ForumManageComments,),
113                      'category' : 'object',
114                      }
115            self.verifyAction('portal_discussion', **action)
116            action = {'id' : 'deactivate_comments',
117                      'name': 'action_deactivate_comments',
118                      'action': "string:${object/absolute_url}/set_comment_mode?mode=0",
119                      'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1",
120                      'permission': (ForumManageComments,),
121                      'category' : 'object',
122                      }
123            self.verifyAction('portal_discussion', **action)
124            action = {'id' : 'manage_comments',
125                      'name': 'action_manage_comments',
126                      'action': "string:${object/absolute_url}/manage_comment",
127                      'condition' : "python:getattr(object.getTypeInfo(),'cps_proxy_type','') in ('document', 'folderishdocument') and getattr(object.getContent(), 'allow_discussion' , None) == 1",
128                      'permission': (ForumManageComments,),
129                      'category' : 'object',
130                      }
131            self.verifyAction('portal_discussion', **action)
[19]132       
[84]133###)
134
135        # portlets ###(
136        #
137        portlets = (
138                  {'identifier': 'waeup_main_tabs',
139                  'type': 'Custom Portlet',
140                  'slot': 'main_tabs',
141                  'order': 0,
142                  'render_method': 'portlet_main_navigation',
143                  'Title': 'main tabs',
144                  },
145                  {'identifier': 'waeup_breadcrumbs',
146                  'type': 'Breadcrumbs Portlet',
147                  'slot': 'waeup_breadcrumbs',
148                  'first_item': 2,
149                  'display_site_root': 0,
150                  'Title': 'waeup_breadcrumbs',
151                  'display': 'horizontal_trail',
152                  'display_hidden_folders': 0,
153                  'order': 0,
154                  },
155                  {'identifier': 'waeup_object_actions',
156                  'type': 'Actions Portlet',
157                  'slot': 'waeup_object_actions',
158                  'order': 0,
159                  'categories': ['object'],
160                  'Title': 'waep_manager_actions',
161                  },
162                  {'identifier': 'waeup_left_top',
163                  'type': 'Custom Portlet',
164                  'slot': 'left_top',
165                  'order': 0,
166                  'render_method': 'portlet_session_info',
167                  'Title': 'Session Info',
168                  },
169                )
170        self.verifyPortletContainer(self.portal.sections.waeup)
171        self.verifyPortlets(portlets, self.portal.sections.waeup)
172
173###)
174
[19]175        ##########################################
[84]176        # student actions ###(
[19]177        ##########################################
[20]178        actions = ( { 'tool'      : 'portal_actions',
179                        'id'        : 'checkadmission',
180                        'name'      : 'Check Admission',
[47]181                        'action'    : 'string:${object/absolute_url}/check_admission',
[20]182                        'permission': (View, ),
[49]183                        'condition' : 'python: not member',
[23]184                        'category'  : 'student',
[20]185                        'visible'   : 1,
186                      },
[49]187##                      { 'tool'      : 'portal_actions',
188##                        'id'        : 'new_student',
189##                        'name'      : 'Add Student',
190##                        'action'    : 'string:${object/absolute_url}/create_student_form',
191##                        'permission': (View),
192##                        'condition' : 'python: 0 and member and here.portal_type == "StudentsFolder"',
193##                        'category'  : 'student',
194##                        'visible'   : 1,
195##                      },
[20]196                      { 'tool'      : 'portal_actions',
197                        'id'        : 'edit_student',
198                        'name'      : 'Edit Student',
199                        'action'    : 'cpsdocument_edit_form',
[26]200                        'permission': ( ),
[49]201                        'condition' : 'python: 0 and member and  here.portal_type == "Student"',
[20]202                        'category'  : 'student',
203                        'visible'   : 1,
204                      },
205                      { 'tool'      : 'portal_actions',
[28]206                        'id'        : 'add_jamb',
[49]207                        'name'      : 'Add Student JAMB',
208                        'action'    : 'string:${object/absolute_url}/create_jamb',
[28]209                        'permission': (),
[49]210                        'condition' : 'python: member and here.portal_type in ("StudentsFolder",) and "StudentManager" in member.getGroups()',
[28]211                        'category'  : 'student',
212                        'visible'   : 1,
213                      },
214                      { 'tool'      : 'portal_actions',
[84]215                        'id'        : 'add_faculty',
216                        'name'      : 'Add New Faculty',
217                        'action'    : 'string:${object/absolute_url}/addFaculty',
218                        'permission': (),
219                        'condition' : 'python: member and here.portal_type in ("University",) and "StudentManager" in member.getGroups()',
220                        'category'  : 'student',
221                        'visible'   : 1,
222                      },
223                      { 'tool'      : 'portal_actions',
224                        'id'        : 'add_department',
225                        'name'      : 'Add New Department',
226                        'action'    : 'string:${object/absolute_url}/addDepartment',
227                        'permission': (),
228                        'condition' : 'python: member and here.portal_type in ("Faculty",) and "StudentManager" in member.getGroups()',
229                        'category'  : 'student',
230                        'visible'   : 1,
231                      },
232                      { 'tool'      : 'portal_actions',
233                        'id'        : 'add_course',
234                        'name'      : 'Add New Course',
235                        'action'    : 'string:${object/absolute_url}/addCourse',
236                        'permission': (),
237                        'condition' : 'python: member and here.portal_type in ("Department",) and "StudentManager" in member.getGroups()',
238                        'category'  : 'student',
239                        'visible'   : 1,
240                      },
241                      { 'tool'      : 'portal_actions',
[47]242                        'id'        : 'add_personal',
243                        'name'      : 'Add personal Data',
244                        'action'    : 'string:${object/absolute_url}/create_personal_form',
245                        'permission': (),
[49]246                        'condition' : 'python: 0 and member and not here.portal_type in ("Jamb","StudentsFolder") and not "StudentManager" in member.getGroups()',
[47]247                        'category'  : 'student',
248                        'visible'   : 1,
249                      },
250                      { 'tool'      : 'portal_actions',
[28]251                        'id'        : 'edit_jamb',
252                        'name'      : 'Edit Jamb Data',
253                        'action'    : 'cpsdocument_edit_form',
[26]254                        'permission': ( ),
[49]255                        'condition' : 'python: member and here.portal_type in ("Student",) and "StudentManager" in member.getGroups()',
[20]256                        'category'  : 'student',
257                        'visible'   : 1,
258                      },
259                    )
260        self.verifyActions(actions)
261        ##########################################
[60]262###)
263
264        # skins
[20]265        ##########################################
[19]266        self.log("Verifying %(product_name)s skinss" % vars())
267        wskins = { 'waeup_default' : 'Products/WAeUP/skins/waeup_default',
[84]268                   'waeup_faculty' : 'Products/WAeUP/skins/waeup_faculty',
[19]269                   'waeup_student' : 'Products/WAeUP/skins/waeup_student',
270                 }
271        self.verifySkins(wskins)
272        self.resetSkinCache()
[84]273       
[19]274        ##########################################
[20]275        # portal types
[19]276        ##########################################
277        dtypes = portal.getWAeUPTypes()
278        self.verifyFlexibleTypes(dtypes)
[45]279        self.allowContentTypes('University', ('Workspace','Section',))
[19]280        ##########################################
[20]281        # Schemas
[19]282        ##########################################
283        self.log("Verifying %(product_name)s schemas" % vars())
284        self.verifySchemas(portal.getWAeUPSchemas())
285        ##########################################
[20]286        # widgets
[19]287        ##########################################
[20]288        self.log("Verifying %(product_name)s widgets" % vars())
289        self.verifyWidgets(portal.getWAeUPWidgets())
290        ##########################################
291        # layouts
292        ##########################################
[19]293        self.log("Verifying %(product_name)s layouts" % vars())
294        self.verifyLayouts(portal.getWAeUPLayouts())
295        ##########################################
[20]296        # Vocabularies
[19]297        ##########################################
298        self.log("Verifying %(product_name)s vocabularies" % vars())
299        self.verifyVocabularies(portal.getWAeUPVocabularies())
[60]300        ##########################################
301        # Groups
302        ##########################################
303           
[19]304        self.installCustomWorkflows()
305        self.verifyWorkflowAssociation()
306       
307        self.log("End of specific %(product_name)s install" % vars())
308        self.finalize()
309       
310
311    def installCustomWorkflows(self):
312        """Installs custom workflows
313        """
314        from Products.WAeUP.Workflows.WAeUPWorkflow import \
315             waeupWorkflowsInstall
316
317        waeupWorkflowsInstall(self.context)
318
319
320    def verifyWorkflowAssociation(self):
321        """Verify workflow association
322        """
323        ws_chains = {
324                      'Student': 'waeup_workspace_wf',
325                      'Jamb': 'waeup_workspace_wf',
326                      }
327
[45]328        se_chains = { 'University': 'waeup_section_wf',
329                      'StudentsFolder': 'waeup_section_wf',
[19]330                      'Student': 'waeup_section_wf',
[47]331                      'StudentPersonal': 'waeup_section_wf',
[19]332                      'Jamb': 'waeup_section_wf',
[25]333                      'ScratchCard': 'waeup_section_wf',
[68]334                      'Faculty': 'waeup_section_wf',
335                      'Department': 'waeup_section_wf',
336                      'Course': 'waeup_section_wf',
[19]337                      }
338
339        self.verifyLocalWorkflowChains(self.portal['workspaces'],
340                                       ws_chains,
341                                       destructive=1)
342        self.verifyLocalWorkflowChains(self.portal['sections'],
343                                       se_chains,
344                                       destructive=1)
345
346
347def install(self):
348    installer = WAeUPInstaller(self)
349    installer.install(self)
[60]350    dirtool = getattr(self,'portal_directories')
351    groups = dirtool.groups
352    for newEntry in ('Students','StudentManager'):
353        if newEntry not in groups.listEntryIds():
354            groups.createEntry({'group': newEntry,
355                                'members': []}) 
356    groups.manage_setLocalGroupRoles(groupid = 'StudentManager',roles=('Manager',))
357    #groups.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',))
358    sections = getattr(self,'sections')
359    waeup = getattr(sections,'waeup',None)
360    if not waeup:
361        sections.content_create(type_name='University',title='waeup')
362        sections.waeup.folder_localrole_add(member_ids=('group:Students',),
363                                            member_role='SectionReviewer',
364                                            )
365        sections.waeup.content_create(type_name='StudentsFolder',title='students')
366        sections.waeup.folder_localrole_add(member_ids=('group:Students',),
367                                            member_role='SectionReviewer',
368                                            )
369        sections.waeup.folder_localrole_add(member_ids=('group:StudentManager',),
370                                            member_role='SectionManager',
371                                            )
372        sections.waeup.students.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',))
[72]373    sections.waeup.manage_setLocalGroupRoles(groupid = 'role:Anonymous',roles=('SectionReader',))
[19]374    return installer.logResult()
Note: See TracBrowser for help on using the repository browser.