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

Last change on this file since 33 was 28, checked in by joachim, 19 years ago

noch mehr

  • Property svn:keywords set to Id
File size: 8.3 KB
Line 
1from Products.CPSInstaller.CPSInstaller import CPSInstaller
2from Products.CMFCore.CMFCorePermissions import View, ModifyPortalContent
3try:
4  from Products.CPSSubscriptions.permissions import CanNotifyContent
5  CPSSubscriptions = True
6except ImportError:
7  CPSSubscriptions = False
8try:
9  from Products.CPSForum.CPSForumPermissions import ForumManageComments
10  CPSForum = True
11except ImportError:
12  CPSForum = False
13
14class WAeUPInstaller(CPSInstaller):
15    """
16    WAeUP Installer
17    """
18    product_name = "WAeUP"
19
20    def install(self,portal):
21        "install"
22
23        product_name = self.product_name
24        self.log("Starting %(product_name)s install" % vars() )
25   
26        ##########################################
27        # Actions
28        ##########################################
29        if CPSSubscriptions:
30            ptypes = "('Portal', 'CPSMailAccess Message', 'CPSMailAccess Box', 'CPSMailAccess Folder',"\
31                     +  "'StudentFolder', 'Student', 'Jamb')"
32            condition = "object.portal_type not in %s" % ptypes
33   
34            action = {'id' : 'notify_content',
35                      'name' : 'action_notify_content',
36                      'action' : 'string:${object_url}/content_notify_email_form',
37                      'condition' : 'python:%s' % condition,
38                      'permission' :  (CanNotifyContent,),
39                      'category' : 'object',
40                      }
41            self.deleteActions({'portal_subscriptions': ['notify_content',]})
42            self.verifyAction('portal_subscriptions', **action)
43        if CPSForum:
44            ptypes = "('StudentFolder', 'Student', 'Jamb')"
45            condition = "object.portal_type not in %s" % ptypes
46   
47            action = {'id' : 'activate_comments',
48                      'name': 'action_activate_comments',
49                      'action': 'string:${object/absolute_url}/set_comment_mode?mode=1',
50                      'condition' : 'python:%s' % condition,
51                      'permission': (ForumManageComments,),
52                      'category' : 'object',
53                      }
54            self.deleteActions({'portal_discussion': ['activate_comments',]})
55            self.verifyAction('portal_subscriptions', **action)
56       
57        ##########################################
58        # actions
59        ##########################################
60        actions = ( { 'tool'      : 'portal_actions',
61                        'id'        : 'checkadmission',
62                        'name'      : 'Check Admission',
63                        'action'    : 'string:${object/absolute_url}/check_admission_form',
64                        'permission': (View, ),
65                        'condition' : 'not:member',
66                        'category'  : 'student',
67                        'visible'   : 1,
68                      },
69                      { 'tool'      : 'portal_actions',
70                        'id'        : 'new_student',
71                        'name'      : 'Add Student',
72                        'action'    : 'string:${object/absolute_url}/create_student',
73                        'permission': (View),
74                        'condition' : 'python: member and here.portal_type == "StudentFolder"',
75                        'category'  : 'student',
76                        'visible'   : 1,
77                      },
78                      { 'tool'      : 'portal_actions',
79                        'id'        : 'edit_student',
80                        'name'      : 'Edit Student',
81                        'action'    : 'cpsdocument_edit_form',
82                        'permission': ( ),
83                        'condition' : 'python: here.portal_type == "Student"',
84                        'category'  : 'student',
85                        'visible'   : 1,
86                      },
87                      { 'tool'      : 'portal_actions',
88                        'id'        : 'add_jamb',
89                        'name'      : 'Add Jamb Data',
90                        'action'    : 'string:${object/absolute_url}/create_jamb',
91                        'permission': (),
92                        'condition' : 'python:here.portal_type != "Jamb" and len(object.contentItems()) == 0',
93                        'category'  : 'student',
94                        'visible'   : 1,
95                      },
96                      { 'tool'      : 'portal_actions',
97                        'id'        : 'edit_jamb',
98                        'name'      : 'Edit Jamb Data',
99                        'action'    : 'cpsdocument_edit_form',
100                        'permission': ( ),
101                        'condition' : 'python: here.portal_type == "Jamb"',
102                        'category'  : 'student',
103                        'visible'   : 1,
104                      },
105                    )
106        self.verifyActions(actions)
107        ##########################################
108        # skins
109        ##########################################
110        self.log("Verifying %(product_name)s skinss" % vars())
111        wskins = { 'waeup_default' : 'Products/WAeUP/skins/waeup_default',
112                   'waeup_student' : 'Products/WAeUP/skins/waeup_student',
113                 }
114        self.verifySkins(wskins)
115        self.resetSkinCache()
116        ##########################################
117        # portal types
118        ##########################################
119        dtypes = portal.getWAeUPTypes()
120        self.verifyFlexibleTypes(dtypes)
121        self.allowContentTypes('StudentFolder', ('Workspace','Section',))
122        #self.allowContentTypes('Student', ('Workspace', 'Section'))
123        ptypes = {
124                  'StudentFolder' : {
125                  'allowed_content_types': ('Student',),
126                  'typeinfo_name': 'WAeUP: StudentFolder',
127                  'add_meta_type': 'Factory-based Type Information',
128                  },
129                  'Student' : {
130                  'allowed_content_types': ('Jamb',),
131                  'typeinfo_name': 'WAeUP: Student',
132                  'add_meta_type': 'Factory-based Type Information',
133                  },
134                 }
135        self.verifyContentTypes(ptypes)
136        ##########################################
137        # Schemas
138        ##########################################
139        self.log("Verifying %(product_name)s schemas" % vars())
140        self.verifySchemas(portal.getWAeUPSchemas())
141        ##########################################
142        # widgets
143        ##########################################
144        self.log("Verifying %(product_name)s widgets" % vars())
145        self.verifyWidgets(portal.getWAeUPWidgets())
146        ##########################################
147        # layouts
148        ##########################################
149        self.log("Verifying %(product_name)s layouts" % vars())
150        self.verifyLayouts(portal.getWAeUPLayouts())
151        ##########################################
152        # Vocabularies
153        ##########################################
154        self.log("Verifying %(product_name)s vocabularies" % vars())
155        self.verifyVocabularies(portal.getWAeUPVocabularies())
156   
157        self.installCustomWorkflows()
158        self.verifyWorkflowAssociation()
159       
160        self.log("End of specific %(product_name)s install" % vars())
161        self.finalize()
162       
163
164    def installCustomWorkflows(self):
165        """Installs custom workflows
166        """
167        from Products.WAeUP.Workflows.WAeUPWorkflow import \
168             waeupWorkflowsInstall
169
170        waeupWorkflowsInstall(self.context)
171
172
173    def verifyWorkflowAssociation(self):
174        """Verify workflow association
175        """
176        ws_chains = {
177                      'Student': 'waeup_workspace_wf',
178                      'Jamb': 'waeup_workspace_wf',
179                      }
180
181        se_chains = { 'StudentFolder': 'waeup_section_wf',
182                      'Student': 'waeup_section_wf',
183                      'Jamb': 'waeup_section_wf',
184                      'ScratchCard': 'waeup_section_wf',
185                      }
186
187        self.verifyLocalWorkflowChains(self.portal['workspaces'],
188                                       ws_chains,
189                                       destructive=1)
190        self.verifyLocalWorkflowChains(self.portal['sections'],
191                                       se_chains,
192                                       destructive=1)
193
194
195def install(self):
196    installer = WAeUPInstaller(self)
197    installer.install(self)
198    return installer.logResult()
Note: See TracBrowser for help on using the repository browser.