Index: WAeUP_SRP/trunk/WAeUPTool.py
===================================================================
--- WAeUP_SRP/trunk/WAeUPTool.py	(revision 827)
+++ WAeUP_SRP/trunk/WAeUPTool.py	(revision 828)
@@ -19,290 +19,67 @@
 # $Id$
 """The WAeUPTool.
+
+$Id$
 """
 
-#from zLOG import LOG, DEBUG
-from Globals import InitializeClass, HTMLFile
 from AccessControl import ClassSecurityInfo
-from OFS.Folder import Folder
+from Acquisition import aq_inner
+from Acquisition import aq_parent
+from Globals import DTMLFile
+from Globals import InitializeClass
+from OFS.SimpleItem import SimpleItem
 
-from Products.CPSInstaller.CPSInstaller import CPSInstaller
-from Products.CMFCore.PortalFolder import PortalFolder
-from Products.CMFCore.permissions import View, ManagePortal
+from Products.CMFCore.ActionProviderBase import ActionProviderBase
+from Products.CMFCore.permissions import View
+from Products.ZCatalog.ZCatalog import ZCatalog
+from Products.CMFCore.permissions import ModifyPortalContent
 from Products.CMFCore.utils import UniqueObject
 
-class WAeUPTool(UniqueObject,PortalFolder):
+class WAeUPTool(UniqueObject, SimpleItem, ActionProviderBase):
     """WAeUP tool"""
 
-    id = 'portal_WAeUP'
+    id = 'waeup_tool'
     meta_type = 'WAeUP Tool'
+    _actions = ()
 
     security = ClassSecurityInfo()
-    manage_options = (#ActionProviderBase.manage_options +
-                      PortalFolder.manage_options[:1] +
-                      PortalFolder.manage_options[2:])
+    security.declareObjectProtected(View)
 
-##    _actions = ()
-##
-##
-##    #
-##    # ZMI
-##    #
-##    _properties = (
-##        {'id': 'title', 'type': 'string', 'mode': 'w', 
-##         'label': 'Title'},
-##        {'id': 'uni_id', 'type': 'string', 'mode': 'w', 
-##         'label': 'University ID'},
-##        {'id': 'uni_name', 'type': 'string', 'mode': 'w', 
-##         'label': 'University Name'},
-##    )
-##    title = ''
-##    def __init__(self,uni_id,uni_name):
-##        self.manage_changeProperties(uni_id = uni_id,
-##                                     uni_name = uni_name,
-##                                     )
-##        PortalFolder.__init__(self, self.id)
-##
-##
-##    def verifyFaculties(self, academics): ###(
-##        """install Universityspecific Faculies with Departments"""
-##        faculties = [
-####                     {'id': 'agri', ###(
-####                      'Title': 'Agriculture',
-####                      'departments': [
-####                                     { 'id': 'dep1', ###(
-####                                       'Title': 'One',
-####                                     },
-####                                     ],
-####                      },###)
-##                      { 'id': 'science',
-##                      'Title': 'Science',
-##                      'departments': [
-##                                     { 'id': 'bio', ###(
-##                                       'Title': 'Biochemistry',
-##                                     },
-##                                     { 'id': 'bot',
-##                                       'Title': 'Botany',
-##                                     },
-##                                     { 'id': 'che',
-##                                       'Title': 'Chemistry',
-##                                     },
-##                                     { 'id': 'com',
-##                                       'Title': 'Computer Science',
-##                                     },
-##                                     { 'id': 'geo',
-##                                       'Title': 'Geologie',
-##                                     },
-##                                     { 'id': 'mat',
-##                                       'Title': 'Mathematics',
-##                                     },
-##                                     { 'id': 'mic',
-##                                       'Title': 'Microbiology',
-##                                     },
-##                                     { 'id': 'opt',
-##                                       'Title': 'Optometry',
-##                                     },
-##                                     { 'id': 'phy',
-##                                       'Title': 'Physics',
-##                                     },
-##                                     { 'id': 'zoo',
-##                                       'Title': 'Zoology',
-##                                     },
-##                                     ],
-##                      },###)
-##                     ]###)
-##        #self.log('Verifying Faculties in %s' % academics.absolute_url(relative=1))
-##        for faculty in faculties:
-##            fid = faculty['id']
-##            f = getattr(academics,fid,None)
-##            #self.log('Checking Faculty %(id)s = %(Title)s' % faculty)
-##            if f is None:
-##                #self.log('Creating Faculty %(id)s = %(Title)s' % faculty)
-##                academics.invokeFactory('Faculty', fid)
-##                f = getattr(academics,fid)
-##                f.getContent().edit(mapping=faculty)
-##            for department in faculty['departments']:
-##                #self.log('Checking Department %(id)s = %(Title)s' % department)
-##                did = department['id']
-##                d = getattr(f,did,None)
-##                if d is None:
-##                    #self.log('Creating Department %(id)s = %(Title)s' % department)
-##                    f.invokeFactory('Department', did)
-##                    d = getattr(f,did)
-##                    d.getContent().edit(mapping=department)
-##    ###)
-##
-##InitializeClass(WAeUPTool)
-##
-##def verifyPortlets(portal, portlets=(), object=None): ###(
-##    """Verify the existence of given portet in the object's portlet
-##    container. If not found, a portlet is instantiated.
-##    Existing portlets are not affected.
-##    'portlets' is a tuple with the dictionaries given by the export tab
-##    as entries.
-##    The default object is the portal itself.
-##    return the list a new portlet ids.
-##    """
-##    #self.log('Verifying portlets on %s' % object.absolute_url(relative=1))
-##    #portlet_container = CPSInstaller.getPortletContainer(object, create=1)
-##    idpc = portal.portal_cpsportlets.getPortletContainerId()
-##    if not hasattr(object, idpc):
-####            self.log("   Creating %s/%s" %
-####                (object.absolute_url(relative=1), idpc))
-##        object.manage_addProduct['CPSPortlets'].addPortletsContainer()
-##    portlet_container = getattr(object, idpc, None)
-##    ttool = portal.portal_types
-##    returned = []
-##    for new_portlet in portlets:
-##        existing_portlets = portlet_container.listPortlets()
-##        updated = 0
-##        # Check if the portlet needs an update
-##        identifier = new_portlet.get('identifier')
-##        if identifier:
-##            for portlet in existing_portlets:
-##                if identifier == portlet.identifier:
-##                    #portal.log(" Update of portlet: %s" % portlet)
-##                    portlet.edit(**new_portlet)
-##                    portlet_id = portlet.getId()
-##                    updated = 1
-##                    continue
-##        slot = new_portlet.get('slot')
-##        if slot:
-##            for portlet in existing_portlets:
-##                if slot == portlet.slot:
-##                    #portal.log(" Update of portlet: %s" % portlet)
-##                    portlet.edit(**new_portlet)
-##                    portlet_id = portlet.getId()
-##                    updated = 1
-##                    continue
-##                
-##        if not updated:
-##            #portal.log("   Creation of portlet: %s" % new_portlet)
-##            portlet_id = portal.portal_cpsportlets.createPortlet(
-##            ptype_id=new_portlet['type'],
-##            context=object,
-##            **new_portlet)
-##        if portlet_id not in returned:
-##            returned.append(portlet_id)
-##    return returned
-##    ###)
-##
-##addWAeUPToolForm = HTMLFile('zmi/manage_addWAeUPUniversity',
-##                                                globals())
-##
-##def addWAeUPTool(container, id,
-##                             title='WAeUP University',
-##                             description='',
-##                             langs_list=None,
-##                             manager_id='manager',
-##                             manager_sn='CPS',
-##                             manager_givenName='Manager',
-##                             manager_email='',
-##                             manager_password='',
-##                             manager_password_confirmation='',
-##                             REQUEST=None):
-##    """Add WAeUPTool"""
-##
-##    _log = []
-##    def pr(bla, zlog=1, _log=_log):
-##        if bla == 'flush':
-##            return '<br/>\n'.join(_log)
-##        _log.append(bla)
-##        if (bla and zlog):
-##            LOG('addWAeUPUniversity:', INFO, bla)
-##
-##    uni_id = id.strip()
-##    uni_name = title.strip()
-##    description = description.strip()
-##    manager_id = manager_id.strip()
-##
-####    if not id:
-####        raise ValueError, "You have to provide an id for the portal!"
-####    if not manager_id:
-####        raise ValueError, "You have to provide an id for the CPS Administrator!"
-####    if not manager_email:
-####        raise ValueError, "You have to provide an email address for the CPS Administrator!"
-####    if not manager_password:
-####        raise ValueError, "You have to provide CPS Administrator password!"
-####    if manager_password != manager_password_confirmation:
-####        raise ValueError, "Password confirmation does not match password!"
-##
-##    email_from_name = ('%s %s' % (manager_givenName, manager_sn)).strip()
-##    wt = WAeUPTool(uni_id,uni_name)
-##    id = wt.getId()
-##    container._setObject(id, wt)
-##    sections = getattr(container,'sections')
-##    workspaces = getattr(container,'workspaces') 
-##    sections.invokeFactory('University',uni_id)
-##    uni = getattr(sections,uni_id)
-##    uni.getContent().edit(title=uni_name)
-##    uni.invokeFactory('StudentsFolder','students')
-##    students = getattr(uni,'students').getContent()
-##    students.edit(mapping={'Title':'Students'})
-####    uni.folder_localrole_add(member_ids=('group:Students',),
-####                                            member_role='SectionReviewer',
-####                                            )
-####        uni.content_create(type_name='AcademicsFolder',title='academics')
-####        sections.uni.folder_localrole_add(member_ids=('group:StudentManager',),
-####                                            member_role='SectionManager',
-####                                            )
-####        uni.students.manage_setLocalGroupRoles(groupid = 'Students',roles=('Contributor',))
-##    uni.invokeFactory('AcademicsFolder','academics', title='Academics')
-##    academics = getattr(uni,'academics').getContent()
-##    academics.edit(mapping={'Title':'Academics'})
-##    uni.invokeFactory('AccoFolder','accommodation', title='Accommodation')
-##    accommodation = getattr(uni,'accommodation').getContent()
-##    accommodation.edit(mapping={'Title':'Accommodation'})
-##    academics = getattr(uni,'academics',None)
-##    if academics is None:
-##        uni.invokeFactory('AcademicsFolder','academics')
-##        academics = getattr(uni,'academics')
-##        academics.getContent().edit(mapping={'Title':'Academics'})
-##    wt.verifyFaculties(academics)
-##    if not hasattr(uni,'accommodation'):
-##        uni.invokeFactory('AccoFolder','accommodation')
-##        accommodation = getattr(uni,'accommodation').getContent()
-##        accommodation.edit(mapping={'Title':'Accommodation'})
-##    #uni.manage_setLocalGroupRoles(groupid = 'role:Anonymous',roles=('SectionReader',))
-##    # portlets ###(
-##    #
-##    portlets = (
-##              {#'identifier': 'waeup_breadcrumbs',
-##              'type': 'Breadcrumbs Portlet',
-##              'slot': 'waeup_breadcrumbs',
-##              'first_item': 0,
-##              'display_site_root': 0,
-##              'Title': 'waeup_breadcrumbs',
-##              'display': 'horizontal_trail',
-##              'display_hidden_folders': 0,
-##              'order': 0,
-##              },
-##              {#'identifier': 'waeup_main_tab_actions',
-##              'type': 'Actions Portlet',
-##              'slot': 'main_tabs',
-##              'order': 0,
-##              'categories': ['main_tabs',],
-##              'Title': 'waep_main_tab_actions',
-##              },
-##              {#'identifier': 'waeup_object_actions',
-##              'type': 'Actions Portlet',
-##              'slot': 'waeup_object_actions',
-##              'order': 0,
-##              'categories': ['object',],
-##              'Title': 'waep_manager_actions',
-##              },
-##              {#'identifier': 'waeup_left_top',
-##              'type': 'Custom Portlet',
-##              'slot': 'left_top',
-##              'order': 0,
-##              'render_method': 'portlet_session_info',
-##              'Title': 'Session Info',
-##              },
-##            )
-##    #verifyPortletContainer(uni)
-##    verifyPortlets(container,portlets,uni)
-##
-##    ###)
-##    if REQUEST is not None:
-##        url = container.absolute_url()
-##        REQUEST.RESPONSE.redirect('%s/manage_main' % url)
-##
+    manage_options = ( ActionProviderBase.manage_options
+                     + SimpleItem.manage_options
+                     )
+
+##    security.declarePublic('getHallTitle')
+##    def getHallTitle(self,hall):
+##        """get the Hall Title"""
+##        res = ZCatalog.searchResults(self.portal_catalog,portal_type="AccoHall",id=hall)
+##        if res and len(res) == 1:
+##            return res[0].Title
+##        return hall
+
+    security.declarePublic('getAccommodationInfo')
+    def getAccommodationInfo(self,bed):
+        """return Accommodation Info"""
+        info = {}
+        hall,block,room,letter = bed.split('_')
+        res = ZCatalog.searchResults(self.portal_catalog,portal_type="AccoHall",id=hall)
+        if res and len(res) == 1:
+            hall_brain = res[0]
+            hall_doc = hall_brain.getObject().getContent()
+        else:
+            return info
+        info['hall_title'] = hall_brain.Title
+        info['maintenance_code'] = hall_doc.maintenance_code
+        res = ZCatalog.searchResults(self.portal_catalog,portal_type="ScratchCardBatch")
+        batch_doc = None
+        for brain in res:
+            if brain.id.startswith(info['maintenance_code']):
+                batch_doc = brain.getObject().getContent()
+                break
+        if batch_doc is None:
+            info['maintenance_fee'] = None
+        else:
+            info['maintenance_fee'] = batch_doc.cost
+        return info
+
+InitializeClass(WAeUPTool)
Index: WAeUP_SRP/trunk/__init__.py
===================================================================
--- WAeUP_SRP/trunk/__init__.py	(revision 827)
+++ WAeUP_SRP/trunk/__init__.py	(revision 828)
@@ -16,8 +16,9 @@
 # Only for CPS 3.4.1. In 3.4.2 and later this should be fixed.
 import PatchCPSDefaultImportExport
-
 import Products.WAeUP_SRP.WAeUPPermissions
+import WAeUPTool
 
 import Widgets
+tools = (WAeUPTool.WAeUPTool,)
 
 waeup_types = (
@@ -82,4 +83,8 @@
 
 def initialize(registrar):
+    ToolInit('WAeUP Tool',
+              tools=tools,
+              icon='tool.gif',
+              ).initialize(registrar)
     ContentInit('WAeUP Types',
                 content_types = contentClasses,
Index: WAeUP_SRP/trunk/profiles/default/layouts/student_accommodation.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/layouts/student_accommodation.xml	(revision 827)
+++ WAeUP_SRP/trunk/profiles/default/layouts/student_accommodation.xml	(revision 828)
@@ -20,4 +20,32 @@
   <property name="hidden_readonly_layout_modes"/>
   <property name="view_format">iso8601_medium_easy</property>
+  <property name="hidden_empty"></property>
+ </widget>
+ <widget name="acco_maint_code" meta_type="String Widget">
+  <property name="title">Maintenance Payment Code</property>
+  <property name="fields">
+   <element value="acco_maint_code"/>
+  </property>
+  <property name="label">Maintenance Payment Code</property>
+  <property name="label_edit">Maintenance Payment Code</property>
+  <property name="readonly_layout_modes"/>
+  <property name="hidden_layout_modes">
+    <element value="create"/>
+  </property>
+  <property name="hidden_readonly_layout_modes"/>
+  <property name="hidden_empty"></property>
+ </widget>
+ <widget name="acco_maint_fee" meta_type="String Widget">
+  <property name="title">Maintenance Payment Fee</property>
+  <property name="fields">
+   <element value="acco_maint_fee"/>
+  </property>
+  <property name="label">Maintenance Payment Fee</property>
+  <property name="label_edit">Maintenance Payment Fee</property>
+  <property name="readonly_layout_modes"/>
+  <property name="hidden_layout_modes">
+    <element value="create"/>
+  </property>
+  <property name="hidden_readonly_layout_modes"/>
   <property name="hidden_empty"></property>
  </widget>
@@ -123,4 +151,10 @@
   </row>
   <row>
+   <cell name="acco_maint_code"/>
+  </row>
+  <row>
+   <cell name="acco_maint_fee"/>
+  </row>
+  <row>
    <cell name="acco_maint_sc_pin"/>
   </row>
Index: WAeUP_SRP/trunk/profiles/default/schemas/student_accommodation.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/schemas/student_accommodation.xml	(revision 827)
+++ WAeUP_SRP/trunk/profiles/default/schemas/student_accommodation.xml	(revision 828)
@@ -2,4 +2,6 @@
 <object name="student_accommodation" meta_type="CPS Schema">
  <field name="acco_maint_date" meta_type="CPS DateTime Field"/>
+ <field name="acco_maint_code" meta_type="CPS String Field"/>
+ <field name="acco_maint_fee" meta_type="CPS String Field"/>
  <field name="acco_maint_sc_pin" meta_type="CPS String Field"/>
  <field name="acco_res_date" meta_type="CPS DateTime Field"/>
Index: WAeUP_SRP/trunk/profiles/default/toolset.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/toolset.xml	(revision 827)
+++ WAeUP_SRP/trunk/profiles/default/toolset.xml	(revision 828)
@@ -5,3 +5,5 @@
  <required tool_id="portal_pins"
            class="Products.WAeUP_SRP.WAeUPTables.PinTable"/>
+ <required tool_id="waeup_tool"
+           class="Products.WAeUP_SRP.WAeUPTool.WAeUPTool"/>
 </tool-setup>
Index: WAeUP_SRP/trunk/skins/waeup_accommodation/formatBed.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_accommodation/formatBed.py	(revision 827)
+++ WAeUP_SRP/trunk/skins/waeup_accommodation/formatBed.py	(revision 828)
@@ -17,5 +17,8 @@
     return ''
 hall,block,room,letter = bed.split('_')
-hall_title = context.restrictedTraverse("%s/campus/getHallTitle" % 
-                         (context.portal_url.getPortalPath()))(hall)
+info = context.waeup_tool.getAccommodationInfo(bed)
+if info:
+    hall_title = info['hall_title']
+else:
+    hall_title = ""
 return " %s / Block %s / Room %s / Bed %s" % (hall_title,block,room,letter)
Index: WAeUP_SRP/trunk/skins/waeup_custom/logged_in.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_custom/logged_in.py	(revision 827)
+++ WAeUP_SRP/trunk/skins/waeup_custom/logged_in.py	(revision 828)
@@ -51,5 +51,6 @@
             info = context.getStudentInfo()
             student = info['student']
-            if info['review_state'] in ("student_created","admitted"):
+            if info['review_state'] in ("student_created","admitted") and\
+            wftool.getInfoFor(info['app'],'review_state',None) == 'created' :
                 #student.content_status_modify(workflow_action="enter_clearance_pin")
                 wftool.doActionFor(info['app'],'open')
Index: WAeUP_SRP/trunk/skins/waeup_student/accommodation_pin_form.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/accommodation_pin_form.pt	(revision 827)
+++ WAeUP_SRP/trunk/skins/waeup_student/accommodation_pin_form.pt	(revision 828)
@@ -24,6 +24,9 @@
             <li>Print the Hostel Allocation Slip.</li>
           </ul>
-          <ul tal:condition="python: mode == 'edit'">
-            <li>Buy a Hostel Maintainance Scratch Card.</li> 
+          <ul tal:condition="python: mode == 'edit'" 
+              tal:define="info python: context.getStudentInfo()">
+            <li>Buy a Hostel Maintainance Scratch Card 
+            (Code: <span tal:replace="python: info['acco_doc'].acco_maint_code" />) for 
+            <span tal:replace="python: info['acco_doc'].acco_maint_fee" /></li> 
             <li>Enter the PIN above.</li>
             <li>Print the Hostel Allocation Slip.</li>
Index: WAeUP_SRP/trunk/skins/waeup_student/getMaintenancePrefix.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/getMaintenancePrefix.py	(revision 827)
+++ WAeUP_SRP/trunk/skins/waeup_student/getMaintenancePrefix.py	(revision 828)
@@ -12,12 +12,8 @@
 return the Prefix for hostel maintenance scratchcards
 """
-info = context.getStudentInfo()
-prefix = ""
-if not info['acco']:
-    return prefix
-bed = info['acco_doc'].bed
-hall,block,room,letter = bed.split('_')
-res = context.portal_catalog(portal_type="AccoHall",id=hall)
-if res and len(res) == 1:
-    prefix = res[0].getObject().getContent().maintenance_code
-return prefix
+s_info = context.getStudentInfo()
+if s_info.has_key('acco_doc'):
+    info = context.waeup_tool.getAccommodationInfo(s_info['acco_doc'].bed)
+    if info:
+        return info['maintenance_code']
+return ""
Index: WAeUP_SRP/trunk/skins/waeup_student/reserve_accommodation.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/reserve_accommodation.py	(revision 827)
+++ WAeUP_SRP/trunk/skins/waeup_student/reserve_accommodation.py	(revision 828)
@@ -73,4 +73,7 @@
         student.invokeFactory('StudentAccommodation',acco_id)
         acco = getattr(student,acco_id)
+        acco_info = context.waeup_tool.getAccommodationInfo(bed)
+        ds.set('acco_maint_code', acco_info.get('maintenance_code'))
+        ds.set('acco_maint_fee', acco_info.get('maintenance_fee'))
         ds.set('acco_res_date', current)
         ds.set('bed', bed)
@@ -86,4 +89,2 @@
 wftool.doActionFor(acco,'pay_maintenance_fee',dest_container=acco)
 return context.REQUEST.RESPONSE.redirect("%s/accommodation_view" % student.absolute_url())
-
-
