Changeset 828
- Timestamp:
- 10 Nov 2006, 15:26:31 (18 years ago)
- Location:
- WAeUP_SRP/trunk
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
WAeUP_SRP/trunk/WAeUPTool.py
r282 r828 19 19 # $Id$ 20 20 """The WAeUPTool. 21 22 $Id$ 21 23 """ 22 24 23 #from zLOG import LOG, DEBUG24 from Globals import InitializeClass, HTMLFile25 25 from AccessControl import ClassSecurityInfo 26 from OFS.Folder import Folder 26 from Acquisition import aq_inner 27 from Acquisition import aq_parent 28 from Globals import DTMLFile 29 from Globals import InitializeClass 30 from OFS.SimpleItem import SimpleItem 27 31 28 from Products.CPSInstaller.CPSInstaller import CPSInstaller 29 from Products.CMFCore.PortalFolder import PortalFolder 30 from Products.CMFCore.permissions import View, ManagePortal 32 from Products.CMFCore.ActionProviderBase import ActionProviderBase 33 from Products.CMFCore.permissions import View 34 from Products.ZCatalog.ZCatalog import ZCatalog 35 from Products.CMFCore.permissions import ModifyPortalContent 31 36 from Products.CMFCore.utils import UniqueObject 32 37 33 class WAeUPTool(UniqueObject, PortalFolder):38 class WAeUPTool(UniqueObject, SimpleItem, ActionProviderBase): 34 39 """WAeUP tool""" 35 40 36 id = ' portal_WAeUP'41 id = 'waeup_tool' 37 42 meta_type = 'WAeUP Tool' 43 _actions = () 38 44 39 45 security = ClassSecurityInfo() 40 manage_options = (#ActionProviderBase.manage_options + 41 PortalFolder.manage_options[:1] + 42 PortalFolder.manage_options[2:]) 46 security.declareObjectProtected(View) 43 47 44 ## _actions = () 45 ## 46 ## 47 ## # 48 ## # ZMI 49 ## # 50 ## _properties = ( 51 ## {'id': 'title', 'type': 'string', 'mode': 'w', 52 ## 'label': 'Title'}, 53 ## {'id': 'uni_id', 'type': 'string', 'mode': 'w', 54 ## 'label': 'University ID'}, 55 ## {'id': 'uni_name', 'type': 'string', 'mode': 'w', 56 ## 'label': 'University Name'}, 57 ## ) 58 ## title = '' 59 ## def __init__(self,uni_id,uni_name): 60 ## self.manage_changeProperties(uni_id = uni_id, 61 ## uni_name = uni_name, 62 ## ) 63 ## PortalFolder.__init__(self, self.id) 64 ## 65 ## 66 ## def verifyFaculties(self, academics): ###( 67 ## """install Universityspecific Faculies with Departments""" 68 ## faculties = [ 69 #### {'id': 'agri', ###( 70 #### 'Title': 'Agriculture', 71 #### 'departments': [ 72 #### { 'id': 'dep1', ###( 73 #### 'Title': 'One', 74 #### }, 75 #### ], 76 #### },###) 77 ## { 'id': 'science', 78 ## 'Title': 'Science', 79 ## 'departments': [ 80 ## { 'id': 'bio', ###( 81 ## 'Title': 'Biochemistry', 82 ## }, 83 ## { 'id': 'bot', 84 ## 'Title': 'Botany', 85 ## }, 86 ## { 'id': 'che', 87 ## 'Title': 'Chemistry', 88 ## }, 89 ## { 'id': 'com', 90 ## 'Title': 'Computer Science', 91 ## }, 92 ## { 'id': 'geo', 93 ## 'Title': 'Geologie', 94 ## }, 95 ## { 'id': 'mat', 96 ## 'Title': 'Mathematics', 97 ## }, 98 ## { 'id': 'mic', 99 ## 'Title': 'Microbiology', 100 ## }, 101 ## { 'id': 'opt', 102 ## 'Title': 'Optometry', 103 ## }, 104 ## { 'id': 'phy', 105 ## 'Title': 'Physics', 106 ## }, 107 ## { 'id': 'zoo', 108 ## 'Title': 'Zoology', 109 ## }, 110 ## ], 111 ## },###) 112 ## ]###) 113 ## #self.log('Verifying Faculties in %s' % academics.absolute_url(relative=1)) 114 ## for faculty in faculties: 115 ## fid = faculty['id'] 116 ## f = getattr(academics,fid,None) 117 ## #self.log('Checking Faculty %(id)s = %(Title)s' % faculty) 118 ## if f is None: 119 ## #self.log('Creating Faculty %(id)s = %(Title)s' % faculty) 120 ## academics.invokeFactory('Faculty', fid) 121 ## f = getattr(academics,fid) 122 ## f.getContent().edit(mapping=faculty) 123 ## for department in faculty['departments']: 124 ## #self.log('Checking Department %(id)s = %(Title)s' % department) 125 ## did = department['id'] 126 ## d = getattr(f,did,None) 127 ## if d is None: 128 ## #self.log('Creating Department %(id)s = %(Title)s' % department) 129 ## f.invokeFactory('Department', did) 130 ## d = getattr(f,did) 131 ## d.getContent().edit(mapping=department) 132 ## ###) 133 ## 134 ##InitializeClass(WAeUPTool) 135 ## 136 ##def verifyPortlets(portal, portlets=(), object=None): ###( 137 ## """Verify the existence of given portet in the object's portlet 138 ## container. If not found, a portlet is instantiated. 139 ## Existing portlets are not affected. 140 ## 'portlets' is a tuple with the dictionaries given by the export tab 141 ## as entries. 142 ## The default object is the portal itself. 143 ## return the list a new portlet ids. 144 ## """ 145 ## #self.log('Verifying portlets on %s' % object.absolute_url(relative=1)) 146 ## #portlet_container = CPSInstaller.getPortletContainer(object, create=1) 147 ## idpc = portal.portal_cpsportlets.getPortletContainerId() 148 ## if not hasattr(object, idpc): 149 #### self.log(" Creating %s/%s" % 150 #### (object.absolute_url(relative=1), idpc)) 151 ## object.manage_addProduct['CPSPortlets'].addPortletsContainer() 152 ## portlet_container = getattr(object, idpc, None) 153 ## ttool = portal.portal_types 154 ## returned = [] 155 ## for new_portlet in portlets: 156 ## existing_portlets = portlet_container.listPortlets() 157 ## updated = 0 158 ## # Check if the portlet needs an update 159 ## identifier = new_portlet.get('identifier') 160 ## if identifier: 161 ## for portlet in existing_portlets: 162 ## if identifier == portlet.identifier: 163 ## #portal.log(" Update of portlet: %s" % portlet) 164 ## portlet.edit(**new_portlet) 165 ## portlet_id = portlet.getId() 166 ## updated = 1 167 ## continue 168 ## slot = new_portlet.get('slot') 169 ## if slot: 170 ## for portlet in existing_portlets: 171 ## if slot == portlet.slot: 172 ## #portal.log(" Update of portlet: %s" % portlet) 173 ## portlet.edit(**new_portlet) 174 ## portlet_id = portlet.getId() 175 ## updated = 1 176 ## continue 177 ## 178 ## if not updated: 179 ## #portal.log(" Creation of portlet: %s" % new_portlet) 180 ## portlet_id = portal.portal_cpsportlets.createPortlet( 181 ## ptype_id=new_portlet['type'], 182 ## context=object, 183 ## **new_portlet) 184 ## if portlet_id not in returned: 185 ## returned.append(portlet_id) 186 ## return returned 187 ## ###) 188 ## 189 ##addWAeUPToolForm = HTMLFile('zmi/manage_addWAeUPUniversity', 190 ## globals()) 191 ## 192 ##def addWAeUPTool(container, id, 193 ## title='WAeUP University', 194 ## description='', 195 ## langs_list=None, 196 ## manager_id='manager', 197 ## manager_sn='CPS', 198 ## manager_givenName='Manager', 199 ## manager_email='', 200 ## manager_password='', 201 ## manager_password_confirmation='', 202 ## REQUEST=None): 203 ## """Add WAeUPTool""" 204 ## 205 ## _log = [] 206 ## def pr(bla, zlog=1, _log=_log): 207 ## if bla == 'flush': 208 ## return '<br/>\n'.join(_log) 209 ## _log.append(bla) 210 ## if (bla and zlog): 211 ## LOG('addWAeUPUniversity:', INFO, bla) 212 ## 213 ## uni_id = id.strip() 214 ## uni_name = title.strip() 215 ## description = description.strip() 216 ## manager_id = manager_id.strip() 217 ## 218 #### if not id: 219 #### raise ValueError, "You have to provide an id for the portal!" 220 #### if not manager_id: 221 #### raise ValueError, "You have to provide an id for the CPS Administrator!" 222 #### if not manager_email: 223 #### raise ValueError, "You have to provide an email address for the CPS Administrator!" 224 #### if not manager_password: 225 #### raise ValueError, "You have to provide CPS Administrator password!" 226 #### if manager_password != manager_password_confirmation: 227 #### raise ValueError, "Password confirmation does not match password!" 228 ## 229 ## email_from_name = ('%s %s' % (manager_givenName, manager_sn)).strip() 230 ## wt = WAeUPTool(uni_id,uni_name) 231 ## id = wt.getId() 232 ## container._setObject(id, wt) 233 ## sections = getattr(container,'sections') 234 ## workspaces = getattr(container,'workspaces') 235 ## sections.invokeFactory('University',uni_id) 236 ## uni = getattr(sections,uni_id) 237 ## uni.getContent().edit(title=uni_name) 238 ## uni.invokeFactory('StudentsFolder','students') 239 ## students = getattr(uni,'students').getContent() 240 ## students.edit(mapping={'Title':'Students'}) 241 #### uni.folder_localrole_add(member_ids=('group:Students',), 242 #### member_role='SectionReviewer', 243 #### ) 244 #### uni.content_create(type_name='AcademicsFolder',title='academics') 245 #### sections.uni.folder_localrole_add(member_ids=('group:StudentManager',), 246 #### member_role='SectionManager', 247 #### ) 248 #### uni.students.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',)) 249 ## uni.invokeFactory('AcademicsFolder','academics', title='Academics') 250 ## academics = getattr(uni,'academics').getContent() 251 ## academics.edit(mapping={'Title':'Academics'}) 252 ## uni.invokeFactory('AccoFolder','accommodation', title='Accommodation') 253 ## accommodation = getattr(uni,'accommodation').getContent() 254 ## accommodation.edit(mapping={'Title':'Accommodation'}) 255 ## academics = getattr(uni,'academics',None) 256 ## if academics is None: 257 ## uni.invokeFactory('AcademicsFolder','academics') 258 ## academics = getattr(uni,'academics') 259 ## academics.getContent().edit(mapping={'Title':'Academics'}) 260 ## wt.verifyFaculties(academics) 261 ## if not hasattr(uni,'accommodation'): 262 ## uni.invokeFactory('AccoFolder','accommodation') 263 ## accommodation = getattr(uni,'accommodation').getContent() 264 ## accommodation.edit(mapping={'Title':'Accommodation'}) 265 ## #uni.manage_setLocalGroupRoles(groupid = 'role:Anonymous',roles=('SectionReader',)) 266 ## # portlets ###( 267 ## # 268 ## portlets = ( 269 ## {#'identifier': 'waeup_breadcrumbs', 270 ## 'type': 'Breadcrumbs Portlet', 271 ## 'slot': 'waeup_breadcrumbs', 272 ## 'first_item': 0, 273 ## 'display_site_root': 0, 274 ## 'Title': 'waeup_breadcrumbs', 275 ## 'display': 'horizontal_trail', 276 ## 'display_hidden_folders': 0, 277 ## 'order': 0, 278 ## }, 279 ## {#'identifier': 'waeup_main_tab_actions', 280 ## 'type': 'Actions Portlet', 281 ## 'slot': 'main_tabs', 282 ## 'order': 0, 283 ## 'categories': ['main_tabs',], 284 ## 'Title': 'waep_main_tab_actions', 285 ## }, 286 ## {#'identifier': 'waeup_object_actions', 287 ## 'type': 'Actions Portlet', 288 ## 'slot': 'waeup_object_actions', 289 ## 'order': 0, 290 ## 'categories': ['object',], 291 ## 'Title': 'waep_manager_actions', 292 ## }, 293 ## {#'identifier': 'waeup_left_top', 294 ## 'type': 'Custom Portlet', 295 ## 'slot': 'left_top', 296 ## 'order': 0, 297 ## 'render_method': 'portlet_session_info', 298 ## 'Title': 'Session Info', 299 ## }, 300 ## ) 301 ## #verifyPortletContainer(uni) 302 ## verifyPortlets(container,portlets,uni) 303 ## 304 ## ###) 305 ## if REQUEST is not None: 306 ## url = container.absolute_url() 307 ## REQUEST.RESPONSE.redirect('%s/manage_main' % url) 308 ## 48 manage_options = ( ActionProviderBase.manage_options 49 + SimpleItem.manage_options 50 ) 51 52 ## security.declarePublic('getHallTitle') 53 ## def getHallTitle(self,hall): 54 ## """get the Hall Title""" 55 ## res = ZCatalog.searchResults(self.portal_catalog,portal_type="AccoHall",id=hall) 56 ## if res and len(res) == 1: 57 ## return res[0].Title 58 ## return hall 59 60 security.declarePublic('getAccommodationInfo') 61 def getAccommodationInfo(self,bed): 62 """return Accommodation Info""" 63 info = {} 64 hall,block,room,letter = bed.split('_') 65 res = ZCatalog.searchResults(self.portal_catalog,portal_type="AccoHall",id=hall) 66 if res and len(res) == 1: 67 hall_brain = res[0] 68 hall_doc = hall_brain.getObject().getContent() 69 else: 70 return info 71 info['hall_title'] = hall_brain.Title 72 info['maintenance_code'] = hall_doc.maintenance_code 73 res = ZCatalog.searchResults(self.portal_catalog,portal_type="ScratchCardBatch") 74 batch_doc = None 75 for brain in res: 76 if brain.id.startswith(info['maintenance_code']): 77 batch_doc = brain.getObject().getContent() 78 break 79 if batch_doc is None: 80 info['maintenance_fee'] = None 81 else: 82 info['maintenance_fee'] = batch_doc.cost 83 return info 84 85 InitializeClass(WAeUPTool) -
WAeUP_SRP/trunk/__init__.py
r765 r828 16 16 # Only for CPS 3.4.1. In 3.4.2 and later this should be fixed. 17 17 import PatchCPSDefaultImportExport 18 19 18 import Products.WAeUP_SRP.WAeUPPermissions 19 import WAeUPTool 20 20 21 21 import Widgets 22 tools = (WAeUPTool.WAeUPTool,) 22 23 23 24 waeup_types = ( … … 82 83 83 84 def initialize(registrar): 85 ToolInit('WAeUP Tool', 86 tools=tools, 87 icon='tool.gif', 88 ).initialize(registrar) 84 89 ContentInit('WAeUP Types', 85 90 content_types = contentClasses, -
WAeUP_SRP/trunk/profiles/default/layouts/student_accommodation.xml
r805 r828 20 20 <property name="hidden_readonly_layout_modes"/> 21 21 <property name="view_format">iso8601_medium_easy</property> 22 <property name="hidden_empty"></property> 23 </widget> 24 <widget name="acco_maint_code" meta_type="String Widget"> 25 <property name="title">Maintenance Payment Code</property> 26 <property name="fields"> 27 <element value="acco_maint_code"/> 28 </property> 29 <property name="label">Maintenance Payment Code</property> 30 <property name="label_edit">Maintenance Payment Code</property> 31 <property name="readonly_layout_modes"/> 32 <property name="hidden_layout_modes"> 33 <element value="create"/> 34 </property> 35 <property name="hidden_readonly_layout_modes"/> 36 <property name="hidden_empty"></property> 37 </widget> 38 <widget name="acco_maint_fee" meta_type="String Widget"> 39 <property name="title">Maintenance Payment Fee</property> 40 <property name="fields"> 41 <element value="acco_maint_fee"/> 42 </property> 43 <property name="label">Maintenance Payment Fee</property> 44 <property name="label_edit">Maintenance Payment Fee</property> 45 <property name="readonly_layout_modes"/> 46 <property name="hidden_layout_modes"> 47 <element value="create"/> 48 </property> 49 <property name="hidden_readonly_layout_modes"/> 22 50 <property name="hidden_empty"></property> 23 51 </widget> … … 123 151 </row> 124 152 <row> 153 <cell name="acco_maint_code"/> 154 </row> 155 <row> 156 <cell name="acco_maint_fee"/> 157 </row> 158 <row> 125 159 <cell name="acco_maint_sc_pin"/> 126 160 </row> -
WAeUP_SRP/trunk/profiles/default/schemas/student_accommodation.xml
r680 r828 2 2 <object name="student_accommodation" meta_type="CPS Schema"> 3 3 <field name="acco_maint_date" meta_type="CPS DateTime Field"/> 4 <field name="acco_maint_code" meta_type="CPS String Field"/> 5 <field name="acco_maint_fee" meta_type="CPS String Field"/> 4 6 <field name="acco_maint_sc_pin" meta_type="CPS String Field"/> 5 7 <field name="acco_res_date" meta_type="CPS DateTime Field"/> -
WAeUP_SRP/trunk/profiles/default/toolset.xml
r486 r828 5 5 <required tool_id="portal_pins" 6 6 class="Products.WAeUP_SRP.WAeUPTables.PinTable"/> 7 <required tool_id="waeup_tool" 8 class="Products.WAeUP_SRP.WAeUPTool.WAeUPTool"/> 7 9 </tool-setup> -
WAeUP_SRP/trunk/skins/waeup_accommodation/formatBed.py
r821 r828 17 17 return '' 18 18 hall,block,room,letter = bed.split('_') 19 hall_title = context.restrictedTraverse("%s/campus/getHallTitle" % 20 (context.portal_url.getPortalPath()))(hall) 19 info = context.waeup_tool.getAccommodationInfo(bed) 20 if info: 21 hall_title = info['hall_title'] 22 else: 23 hall_title = "" 21 24 return " %s / Block %s / Room %s / Bed %s" % (hall_title,block,room,letter) -
WAeUP_SRP/trunk/skins/waeup_custom/logged_in.py
r805 r828 51 51 info = context.getStudentInfo() 52 52 student = info['student'] 53 if info['review_state'] in ("student_created","admitted"): 53 if info['review_state'] in ("student_created","admitted") and\ 54 wftool.getInfoFor(info['app'],'review_state',None) == 'created' : 54 55 #student.content_status_modify(workflow_action="enter_clearance_pin") 55 56 wftool.doActionFor(info['app'],'open') -
WAeUP_SRP/trunk/skins/waeup_student/accommodation_pin_form.pt
r821 r828 24 24 <li>Print the Hostel Allocation Slip.</li> 25 25 </ul> 26 <ul tal:condition="python: mode == 'edit'"> 27 <li>Buy a Hostel Maintainance Scratch Card.</li> 26 <ul tal:condition="python: mode == 'edit'" 27 tal:define="info python: context.getStudentInfo()"> 28 <li>Buy a Hostel Maintainance Scratch Card 29 (Code: <span tal:replace="python: info['acco_doc'].acco_maint_code" />) for 30 <span tal:replace="python: info['acco_doc'].acco_maint_fee" /></li> 28 31 <li>Enter the PIN above.</li> 29 32 <li>Print the Hostel Allocation Slip.</li> -
WAeUP_SRP/trunk/skins/waeup_student/getMaintenancePrefix.py
r805 r828 12 12 return the Prefix for hostel maintenance scratchcards 13 13 """ 14 info = context.getStudentInfo() 15 prefix = "" 16 if not info['acco']: 17 return prefix 18 bed = info['acco_doc'].bed 19 hall,block,room,letter = bed.split('_') 20 res = context.portal_catalog(portal_type="AccoHall",id=hall) 21 if res and len(res) == 1: 22 prefix = res[0].getObject().getContent().maintenance_code 23 return prefix 14 s_info = context.getStudentInfo() 15 if s_info.has_key('acco_doc'): 16 info = context.waeup_tool.getAccommodationInfo(s_info['acco_doc'].bed) 17 if info: 18 return info['maintenance_code'] 19 return "" -
WAeUP_SRP/trunk/skins/waeup_student/reserve_accommodation.py
r821 r828 73 73 student.invokeFactory('StudentAccommodation',acco_id) 74 74 acco = getattr(student,acco_id) 75 acco_info = context.waeup_tool.getAccommodationInfo(bed) 76 ds.set('acco_maint_code', acco_info.get('maintenance_code')) 77 ds.set('acco_maint_fee', acco_info.get('maintenance_fee')) 75 78 ds.set('acco_res_date', current) 76 79 ds.set('bed', bed) … … 86 89 wftool.doActionFor(acco,'pay_maintenance_fee',dest_container=acco) 87 90 return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % student.absolute_url()) 88 89
Note: See TracChangeset for help on using the changeset viewer.