Index: WAeUP_SRP/trunk/Accommodation.py
===================================================================
--- WAeUP_SRP/trunk/Accommodation.py	(revision 501)
+++ WAeUP_SRP/trunk/Accommodation.py	(revision 502)
@@ -91,7 +91,4 @@
 
 ###)
-
-        
-                            
                 
 InitializeClass(Accommodation)
Index: WAeUP_SRP/trunk/PatchCatalogToolXMLAdapter.py
===================================================================
--- WAeUP_SRP/trunk/PatchCatalogToolXMLAdapter.py	(revision 501)
+++ WAeUP_SRP/trunk/PatchCatalogToolXMLAdapter.py	(revision 502)
@@ -7,4 +7,5 @@
     """Import the object from the DOM node.
     """
+    #import pdb;pdb.set_trace()
     if self.environ.shouldPurge():
         self._purgeProperties()
@@ -12,8 +13,4 @@
         self._purgeIndexes()
         self._purgeColumns()
-##    self._initProperties(node)
-##    self._initObjects(node)
-##    self._initIndexes(node)
-##    self._initColumns(node)
     columns = []
     for col in self._extractColumns()._get_childNodes():
@@ -27,7 +24,7 @@
     na = node.attributes.items()
     not_found = True
-    if na[1][1] == "portal_catalog":
+    if na[0][1] == "CMF Catalog":
         not_found = False
-        print na[1][1]
+        #print na[1][1]
         for ch in node._get_childNodes():
             if ch.nodeName in ('index',):
Index: WAeUP_SRP/trunk/ScratchCards.py
===================================================================
--- WAeUP_SRP/trunk/ScratchCards.py	(revision 501)
+++ WAeUP_SRP/trunk/ScratchCards.py	(revision 502)
@@ -11,4 +11,8 @@
 #from Products.CPSCore.CPSBase import CPSBaseDocument as BaseDocument
 from Products.CPSDocument.CPSDocument import CPSDocument
+import DateTime
+import Globals
+p_home = Globals.package_home(globals())
+i_home = Globals.INSTANCE_HOME
 
 class ScratchCardBatchesFolder(CPSDocument): ###(
@@ -45,8 +49,4 @@
     security = ClassSecurityInfo()
 
-    def __init__(self,id,**kw):
-        CPSDocument.__init__(self,id,**kw)
-        self.table = PinTable()
-        
     security.declareProtected(View,"Title")
     def Title(self):
@@ -60,15 +60,26 @@
         batch = self.getContent()
         nr = batch.no_of_pins
+        prefix = batch.prefix
+        sold = batch.sold_by
+        cost = batch.cost
         import random
         r = random
         b_no = batch.batch_no
+        #import pdb;pdb.set_trace()
+        generated = []
+        generated.append('"Serial","Pin","Sold","Cost"' % vars())
+        generated.append('"%(prefix)s","%(b_no)d","%(sold)s","%(cost)f"' % vars())
+        pins = self.portal_pins
         for i in range(nr):
-            pin = "%d%d" % (b_no,r.randint(999999999,1000000000))
-            import pdp;pdb.set_trace()
-            while len(res) > 0: 
-                pin = "%d%d" % (b_no,r.randint(9999,1000000000))
-                res = self.table.searchResults(uid=pin)
-            self.table.addRecord(pin=pin,serial=i,student="")
-            print i,pin
+            ri = r.randint(1000000000,9999999999)
+            pin = "%s%d%d" % (prefix,b_no,ri)
+            while len(pins.searchResults({'pin': pin})) > 0:
+                ri = r.randint(1000000000,9999999999)
+                pin = "%s%d%d" % (prefix,b_no,ri)
+            pins.addRecord(pin=pin,serial=i,student="")
+            generated.append('"%(i)d","%(prefix)s-%(b_no)d-%(ri)d"' % vars())
+        print '\n'.join(generated)
+        current = DateTime.DateTime().strftime("%d-%m-%y_%H_%M_%S")
+        open("%s/import/%s-%s-%s" % (i_home,prefix,b_no,current),"w+").write('\n'.join(generated))
 
 
Index: WAeUP_SRP/trunk/Students.py
===================================================================
--- WAeUP_SRP/trunk/Students.py	(revision 501)
+++ WAeUP_SRP/trunk/Students.py	(revision 502)
@@ -5,4 +5,5 @@
 from AccessControl.SecurityManagement import newSecurityManager
 from zExceptions import BadRequest
+from Products.ZCatalog.ZCatalog import ZCatalog
 from Products.CMFCore.utils import UniqueObject, getToolByName
 from Products.CMFCore.permissions import View
@@ -25,4 +26,13 @@
     r = random
     return "%c%d" % (r.choice('ABCDEFGHKLMNPQRSTUVWXY'),r.randint(99999,1000000))
+
+def getStudentByRegNo(self,reg_no):
+    """search student by JAMB Reg No and return StudentFolder"""
+    search = ZCatalog.searchResults(self.portal_catalog,{'meta_type': 'StudentApplication',
+                                  'jamb_reg_no': reg_no,
+                                  })
+    if len(search) < 1:
+        return None
+    return search[0].getObject().aq_parent
 
 class StudentsFolder(CPSDocument): ###(
@@ -102,4 +112,8 @@
                 logger.info('%(tr_count)s: Creating Student with ID %(sid)s Matric_no %(matric_no)s ' % vars())
                 s = getattr(self,sid)
+                self.portal_registration.addMember(sid, 
+                                                   'uNsEt' ,
+                                                   roles=('Member',
+                                                          'Student',))
                 s.invokeFactory('StudentApplication','application')
                 da = {'Title': 'Application Data'}
@@ -314,4 +328,8 @@
             logger.info('%(tr_count)s: Creating Student with ID %(sid)s REG-NO %(jamb_reg_no)s ' % vars())
             s = getattr(self,sid)
+            self.portal_registration.addMember(sid, 
+                                               'uNsEt' ,
+                                               roles=('Member',
+                                                      'Student',))
             s.invokeFactory('StudentApplication','application')
             da = {'Title': 'Application Data'}
@@ -335,16 +353,9 @@
 ##            s.personal.getContent().edit(mapping=d)
             s.application.getContent().edit(mapping=da)
+            s.application.getContent().content_status_modify(workflow_action="open")
+            s.application.manage_setLocalRoles(s_id, ['Owner',])
         return self.REQUEST.RESPONSE.redirect("%s" % self.REQUEST.get('URL1'))
     ###)
 
-    security.declareProtected(View,"getStudentByRegNo")
-    def getStudentByRegNo(self,reg_no):
-        """search student by JAMB Reg No and return StudentFolder"""
-        search = self.portal_catalog({'meta_type': 'StudentApplication',
-                                      'jamb_reg_no': reg_no,
-                                      })
-        if len(search) < 1:
-            return None
-        return search[0].getObject().aq_parent
 
     security.declareProtected(View,"Title")
Index: WAeUP_SRP/trunk/WAeUPTables.py
===================================================================
--- WAeUP_SRP/trunk/WAeUPTables.py	(revision 501)
+++ WAeUP_SRP/trunk/WAeUPTables.py	(revision 502)
@@ -31,5 +31,4 @@
     for key, value in dict.items():
         setattr(ob, key, value)
-        
     return ob
         
@@ -40,11 +39,22 @@
         
     def addRecord(self, **data):
-        raise NotImplementedError
+        # The uid is the same as "bed".
+        uid = data[self.key]
+        res = self.searchResults({"%s" % self.key : uid})
+        if len(res) > 0:
+            raise ValueError("More than one record with uid %s" % uid)
+        self.catalog_object(dict2ob(data), uid=uid)
+        return uid
     
     def deleteRecord(self, uid):
         self.uncatalog_object(uid)
     
-    def modifyRecord(self, uid, **data):
-        records = self.searchResults(uid=uid)
+    def searchAndSetRecord(self, **data):
+        raise NotImplemented
+
+    def modifyRecord(self, **data):
+        #records = self.searchResults(uid=uid)
+        uid = data[self.key]
+        records = self.searchResults({"%s" % self.key : uid})
         if len(records) > 1:
             # Can not happen, but anyway...
@@ -52,5 +62,4 @@
         if len(records) == 0:
             raise KeyError("No record for uid %s" % uid)
-        
         record = records[0]
         record_data = {}
@@ -64,13 +73,8 @@
     
     meta_type = 'WAeUP Accommodation Tool'
-    
+    name = "accommodation"
+    key = "bed"
     def __init__(self):
         WAeUPTable.__init__(self, 'portal_accommodation')
-
-    def addRecord(self, **data):
-        # The uid is the same as "bed".
-        uid = data['bed']
-        self.catalog_object(dict2ob(data), uid=uid)
-        return uid
 
 
@@ -80,14 +84,31 @@
     
     meta_type = 'WAeUP Pin Tool'
-    
+    name = "pins"
+    key = 'pin'
     def __init__(self):
         WAeUPTable.__init__(self, 'portal_pins')
 
-    def addRecord(self, **data):
-        # The uid is the same as "bed".
-        uid = data['pin']
-        self.catalog_object(dict2ob(data), uid=uid)
-        return uid
 
+    def searchAndSetRecord(self, uid, jamb_reg_no):
+        #records = self.searchResults(uid=uid)
+        records = self.searchResults({"%s" % self.key : uid})
+        if len(records) > 1:
+            # Can not happen, but anyway...
+            raise ValueError("More than one record with uid %s" % uid)
+        if len(records) == 0:
+            return -1
+        record = records[0]
+        if record.student == "":
+            record_data = {}
+            for field in self.schema() + self.indexes():
+                record_data[field] = getattr(record, field)
+            # Add the updated data:
+            record_data['student'] = jamb_reg_no
+            self.catalog_object(dict2ob(record_data), uid)
+            return 1
+        if record.student != jamb_reg_no:
+            return 0
+        if record.student == jamb_reg_no:
+            return 2
 
 InitializeClass(PinTable)
Index: WAeUP_SRP/trunk/Widgets.py
===================================================================
--- WAeUP_SRP/trunk/Widgets.py	(revision 501)
+++ WAeUP_SRP/trunk/Widgets.py	(revision 502)
@@ -2,5 +2,5 @@
 
 from cgi import escape
-
+from types import *
 from Globals import InitializeClass
 ##from Products.CPSSchemas.Widget import CPSWidgetType
@@ -13,5 +13,5 @@
 from DateTime.DateTime import DateTime
 from AccessControl import getSecurityManager
-
+from Products.WAeUP_SRP.Students import getStudentByRegNo
 from re import compile
 
@@ -211,4 +211,12 @@
 ###)
 
+##def getStudentByRegNo(self,reg_no):
+##    search = self.portal_catalog({'meta_type': 'StudentApplication',
+##                                  'jamb_reg_no': reg_no,
+##                                  })
+##    if len(search) < 1:
+##        return None
+##    return search[0].getObject().
+                    
 class JambRegNoWidget(CPSStringWidget): ###(
     """ JambRegNo Widget"""
@@ -232,8 +240,6 @@
                 err = 'Invalid Registration Number in the format: %s%s with N = Number, L = Letter' % (self.digits_str,self.letters_str)
             else:
-                search = self.portal_catalog({'meta_type': 'StudentApplication',
-                                              'jamb_reg_no': value,
-                                              })
-                if len(search) < 1:
+                s = getStudentByRegNo(self,value)
+                if s is None:
                     err = 'No JAMB data for %s' % (value)
             if err:
@@ -279,9 +285,12 @@
     reference = ''
     
-    def prepare(self, datastructure, **kw):
+    def prepare(self, datastructure, **kw): ###(
         """Prepare datastructure from datamodel."""
         datamodel = datastructure.getDataModel()
         v = datamodel[self.fields[0]]
         widget_id = self.getWidgetId()
+        if v and type(v) is StringType:
+            p,b,n = v.split('-')
+            v = ScratchCardPin(v,b,n)
         if v:
             b = '%s' % v.b
@@ -293,4 +302,6 @@
         datastructure[widget_id+'_n'] = n
         
+###)
+
     def validate(self, datastructure, **kw):
         """Validate datastructure and update datamodel."""
@@ -298,9 +309,29 @@
         v = datastructure[widget_id]
         err = 0
+        p = self.prefix
         b = datastructure[widget_id+'_b'].strip()
         n = datastructure[widget_id+'_n'].strip()
         #import pdb; pdb.set_trace()
-        if not n in self.valid_pins:
-            err = 'invalid Pin'
+        pins = self.portal_pins
+        pin = "%(p)s%(b)s%(n)s" % vars()
+        ref = datastructure[self.reference]
+        import pdb;pdb.set_trace()
+        ok = pins.searchAndSetRecord(pin,ref)
+        while 1:
+            if ok == -1:
+                err = 'invalid Pin'
+                break
+            if ok == 0:
+                err = 'Pin already used'
+                break
+            if ok >= 1:
+                student = getStudentByRegNo(self,ref)
+                if student is None:
+                    err = "Student not Found in validate SC"
+                    break
+                s_id = student.getId()
+                if ok == 2:
+                    break
+            break
         if err:
             datastructure.setError(widget_id, err)
@@ -311,8 +342,9 @@
             datastructure[widget_id+'_b'] = b
             datastructure[widget_id+'_n'] = n
+            datastructure['s_id'] = s_id
         #import pdb;pdb.set_trace()
         return not err
 
-    def render(self, mode, datastructure, **kw):
+    def render(self, mode, datastructure, **kw): ###(
         """Render in mode from datastructure."""
         render_method = 'widget_scratch_card_pin_render'
@@ -327,4 +359,7 @@
         datamodel = datastructure.getDataModel()
         v = datamodel[self.fields[0]]
+        if v and type(v) is StringType:
+            p,b,n = v.split('-')
+            v = ScratchCardPin(v,b,n)
         if v:
             b = '%s' % v.b
@@ -338,4 +373,6 @@
             datastructure[widget_id+'_n'] = n
             
+###)
+
 
         return meth(mode=mode, 
Index: WAeUP_SRP/trunk/exportimport.py
===================================================================
--- WAeUP_SRP/trunk/exportimport.py	(revision 501)
+++ WAeUP_SRP/trunk/exportimport.py	(revision 502)
@@ -15,4 +15,5 @@
 
 # Zope3 component architecture
+from zope.app import zapi
 from zope.component import adapts
 from zope.interface import implements
@@ -38,4 +39,23 @@
 NAME = 'waeup'
 
+def importWAeUPTable(obj, parent_path, context, name):
+    """ Import subobjects recursively.
+    """
+    importer = zapi.queryMultiAdapter((obj, context), IBody)
+    
+    path = '%s%s' % (parent_path, obj.getId().replace(' ', '_'))
+    __traceback_info__ = path
+    if importer:
+        path = '%s%s' % (parent_path, name)
+        filename = '%s%s' % (path, importer.suffix)
+        body = context.readDataFile(filename)
+        if body is not None:
+            importer.filename = filename # for error reporting
+            importer.body = body
+
+    if getattr(obj, 'objectValues', False):
+        for sub in obj.objectValues():
+            importObjects(sub, path+'/', context)
+
 def exportWAeUP(context):
     """Export our WAeUP tool configuration
@@ -56,18 +76,27 @@
     pm.setLocalGroupRoles(site,['role:Authenticated',],'SectionReader')
 
-    importObjects(site.portal_accommodation, '', context)
+    importWAeUPTable(site.portal_accommodation, '', context,'accommodation')
+    importWAeUPTable(site.portal_pins, '', context,'pins')
     
-from Products.GenericSetup.ZCatalog.exportimport import ZCatalogXMLAdapter
+from Products.CPSCore.exportimport.catalog import CatalogToolXMLAdapter
+#from Products.GenericSetup.ZCatalog.exportimport import ZCatalogXMLAdapter
 
 from interfaces import IWAeUPTable
 
-class WAeUPTableXMLAdapter(ZCatalogXMLAdapter):
-    
+class WAeUPTableXMLAdapter(CatalogToolXMLAdapter):
+#class WAeUPTableXMLAdapter(ZCatalogXMLAdapter):
     __used_for__ = IWAeUPTable
-
     _LOGGER_ID = 'waeup_table'
 
-    name = 'accommodation'
-
+##    def _importNode(self, node):
+##        """Import the object from the DOM node.
+##        """
+##        if self.environ.shouldPurge():
+##            self._purgeProperties()
+##            self._purgeObjects()
+##            self._purgeIndexes()
+##            self._purgeColumns()
+##
+##        self._logger.info('Catalog imported.')
 # This the XMLAdapter itself. It encodes the im- / export logic that is specific
 # to our tool. `im- / exportObjects` functions will find it thanks to the zope
Index: WAeUP_SRP/trunk/interfaces.py
===================================================================
--- WAeUP_SRP/trunk/interfaces.py	(revision 501)
+++ WAeUP_SRP/trunk/interfaces.py	(revision 502)
@@ -20,5 +20,5 @@
     """Tables to store object relational data
     """
-
+        
     def addRecord(**data):
         """Adds a record, with the data expressed in the data mapping.
@@ -30,4 +30,15 @@
         """Deletes the record specified by the uid"""
     
+    def searchAndSetRecord(self, **data):
+        """
+        searches a record and set a specific value if this is unset
+        raises an error when not found.
+        returns 
+        -1 if not found
+        0 if already set by other
+        1 if found and not set
+        2 if found and set
+        """
+        
     def modifyRecord(uid, **data):
         """Modifies a record, with the data expressed in the data mapping.
Index: WAeUP_SRP/trunk/profiles/default/accommodation.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/accommodation.xml	(revision 501)
+++ WAeUP_SRP/trunk/profiles/default/accommodation.xml	(revision 502)
@@ -1,4 +1,4 @@
 <?xml version="1.0"?>
-<object name="portal_catalog" meta_type="CMF Catalog">
+<object name="portal_accommodation" meta_type="CMF Catalog">
  <column value="bed"/>
  <column value="student"/>
Index: WAeUP_SRP/trunk/profiles/default/layouts.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/layouts.xml	(revision 501)
+++ WAeUP_SRP/trunk/profiles/default/layouts.xml	(revision 502)
@@ -3,5 +3,4 @@
  <property name="title"></property>
  <object name="accommodation" meta_type="CPS Layout"/>
- <object name="accopay" meta_type="CPS Layout"/>
  <object name="certificate" meta_type="CPS Layout"/>
  <object name="certificate_course" meta_type="CPS Layout"/>
Index: WAeUP_SRP/trunk/profiles/default/layouts/scratch_card_batch.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/layouts/scratch_card_batch.xml	(revision 501)
+++ WAeUP_SRP/trunk/profiles/default/layouts/scratch_card_batch.xml	(revision 502)
@@ -33,19 +33,16 @@
   <property name="max_value">100000</property>
  </widget>
- <widget name="prefix" meta_type="String Widget">
-  <property name="title">Prefix</property>
-  <property name="fields">
-   <element value="prefix"/>
-  </property>
-  <property name="is_required">True</property>
-  <property name="label">Prefix</property>
-  <property name="label_edit">Prefix</property>
-  <property name="readonly_layout_modes"/>
-  <property name="hidden_layout_modes"/>
-  <property name="hidden_readonly_layout_modes"/>
-  <property name="display_width">3</property>
-  <property name="size_max">3</property>
- </widget>
- <widget name="sold_by" meta_type="String Widget">
+<widget name="prefix" meta_type="Select Widget">
+ <property name="title">Prefix</property>
+ <property name="fields">
+  <element value="prefix"/>
+ </property>
+ <property name="label">Prefix</property>
+ <property name="label_edit">Prefix</property>
+ <property name="readonly_layout_modes"/>
+ <property name="hidden_layout_modes"/>
+ <property name="hidden_readonly_layout_modes"/>
+ <property name="vocabulary">pin_prefixes</property>
+</widget> <widget name="sold_by" meta_type="String Widget">
   <property name="title">Sold by</property>
   <property name="fields">
Index: WAeUP_SRP/trunk/profiles/default/pins.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/pins.xml	(revision 501)
+++ WAeUP_SRP/trunk/profiles/default/pins.xml	(revision 502)
@@ -1,4 +1,4 @@
 <?xml version="1.0"?>
-<object name="portal_catalog" meta_type="CMF Catalog">
+<object name="portal_pins" meta_type="CMF Catalog">
  <column value="pin"/>
  <column value="student"/>
Index: WAeUP_SRP/trunk/profiles/default/rolemap.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/rolemap.xml	(revision 501)
+++ WAeUP_SRP/trunk/profiles/default/rolemap.xml	(revision 502)
@@ -2,4 +2,5 @@
 <rolemap>
   <roles>
+    <role name="Student"/>
     <role name="SectionReader"/>
     <role name="SectionManager"/>
@@ -7,4 +8,5 @@
   <permissions>
     <permission name="List folder contents" acquire="True">
+      <role name="Owner"/>
       <role name="SectionManager"/>
       <role name="SectionReader"/>
@@ -26,8 +28,8 @@
     </permission>
     <permission name="List portal members" acquire="True">
-      <role name="Member"/>
       <role name="SectionManager"/>
     </permission>
     <permission name="Review portal content" acquire="True">
+      <role name="Owner"/>
       <role name="Reviewer"/>
       <role name="SectionManager"/>
Index: WAeUP_SRP/trunk/profiles/default/schemas/student_application.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/schemas/student_application.xml	(revision 501)
+++ WAeUP_SRP/trunk/profiles/default/schemas/student_application.xml	(revision 502)
@@ -1,10 +1,8 @@
 <?xml version="1.0"?>
 <object name="student_application" meta_type="CPS Schema">
- <field name="app_ac_batch_no" meta_type="CPS String Field"/>
  <field name="app_ac_date" meta_type="CPS DateTime Field"/>
  <field name="app_ac_pin" meta_type="CPS String Field">
-  <property name="is_searchabletext">True</property>
+  <property name="is_searchabletext">False</property>
  </field>
- <field name="app_ac_prefix" meta_type="CPS String Field"/>
  <field name="entry_mode" meta_type="CPS String Field"/>
  <field name="jamb_age" meta_type="CPS Int Field"/>
Index: WAeUP_SRP/trunk/profiles/default/skins.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/skins.xml	(revision 501)
+++ WAeUP_SRP/trunk/profiles/default/skins.xml	(revision 502)
@@ -9,4 +9,6 @@
  <object name="waeup_academics" meta_type="Filesystem Directory View"
     directory="WAeUP_SRP/skins/waeup_academics"/>
+ <object name="waeup_pins" meta_type="Filesystem Directory View"
+    directory="WAeUP_SRP/skins/waeup_pins"/>
  <object name="waeup_student" meta_type="Filesystem Directory View"
     directory="WAeUP_SRP/skins/waeup_student"/>
@@ -14,4 +16,5 @@
   <layer name="waeup_custom" insert-after="custom"/>
   <layer name="waeup_default" insert-after="waeup_custom"/>
+  <layer name="waeup_pins" insert-after="waeup_custom"/>
   <layer name="waeup_student" insert-after="waeup_custom"/>
   <layer name="waeup_academics" insert-after="waeup_custom"/>
@@ -20,4 +23,5 @@
   <layer name="waeup_custom" insert-after="custom"/>
   <layer name="waeup_default" insert-after="waeup_custom"/>
+  <layer name="waeup_pins" insert-after="waeup_custom"/>
   <layer name="waeup_student" insert-after="waeup_custom"/>
   <layer name="waeup_academics" insert-after="waeup_custom"/>
Index: WAeUP_SRP/trunk/profiles/default/skins/waeup_pins.xml
===================================================================
--- WAeUP_SRP/trunk/profiles/default/skins/waeup_pins.xml	(revision 502)
+++ WAeUP_SRP/trunk/profiles/default/skins/waeup_pins.xml	(revision 502)
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<object name="waeup_pins" meta_type="Folder">
+ <property name="title"></property>
+</object>
Index: WAeUP_SRP/trunk/skins/waeup_academics/academics_contents.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_academics/academics_contents.pt	(revision 501)
+++ WAeUP_SRP/trunk/skins/waeup_academics/academics_contents.pt	(revision 502)
@@ -43,5 +43,5 @@
   </div>
     <span tal:omit-tag="" tal:condition="python:display_buttons or context.display_content()" 
-          tal:content="structure doc/render" />
+          tal:content="structure python: doc.render(proxy=here,layout_mode='view')" />
 
   <form action="" method="post" class="group"
Index: WAeUP_SRP/trunk/skins/waeup_custom/logged_in.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_custom/logged_in.pt	(revision 501)
+++ WAeUP_SRP/trunk/skins/waeup_custom/logged_in.pt	(revision 502)
@@ -38,5 +38,5 @@
                    dum_home mtool/createMemberArea"
                    >
-          <span tal:condition="nothing" 
+          <span tal:condition="python:1" 
               tal:define="dummy python: context.process_waeup_login(member=member,sc_pin=request.get('sc_pin',None))" />
           <tal:block condition="first_time">
Index: WAeUP_SRP/trunk/skins/waeup_default/process_waeup_login.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_default/process_waeup_login.py	(revision 501)
+++ WAeUP_SRP/trunk/skins/waeup_default/process_waeup_login.py	(revision 502)
@@ -7,13 +7,38 @@
 request = context.REQUEST
 response=request.response
-return
-##
-##if request.form.get('submit') == 'Login':
-##    #waeup = context.portal_catalog(id = 'demouni')[0]
-##    #waeup = context.portal_catalog(portal_type = 'University')[0]
-##    if 1 or "Manager" in member.getRoles():
-##        return
-###return
-##member_id = str(member)
+import DateTime
+current = DateTime.DateTime()
+#
+if request.form.get('submit') == 'Login':
+    if "Manager" in member.getRoles():
+        return
+member_id = str(member)
+student = getattr(context.students,member_id)
+application = student.application
+#student.invokeFactory('StudentPersonal','personal')
+apdoc = application.getContent()
+names = apdoc.jamb_lastname.split()
+dp = {}
+if len(names) == 3:
+    dp['firstname'] = names[0].capitalize()
+    dp['middlename'] = names[1].capitalize()
+    dp['lastname'] = names[2].capitalize()
+elif len(names) == 2:
+    dp['firstname'] = names[0].capitalize()
+    dp['lastname'] = names[1].capitalize()
+else:
+    dp['lastname'] = apdoc.jamb_lastname
+    dp['sex'] = apdoc.jamb_sex == 'F'
+    dp['lga'] = "%s/%s" % (apdoc.jamb_state,apdoc.jamb_lga )
+student.personal.getContent().edit(mapping = dp)
+##student.content_status_modify(workflow_action="enter_application_pin")
+
+da = {}
+da['app_ac_pin'] = request.get('pin')
+da['app_ac_date'] = current
+apdoc.edit(mapping = da)
+
+return response.redirect("%s/application_form" % student.application.absolute_url())
+
 ##ma = getattr(context,member_id)
 ##jkw = {'application_sc_pin': sc_pin}
@@ -53,5 +78,4 @@
 ##context.notifyCPSDocumentCreation(ob=pd)
 ##
-##return response.redirect("%s" % ma.absolute_url())
 ###return ma.personal_addon(REQUEST=context.REQUEST)
 
Index: WAeUP_SRP/trunk/skins/waeup_pins/scratch_card_batch_create_do.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_pins/scratch_card_batch_create_do.py	(revision 502)
+++ WAeUP_SRP/trunk/skins/waeup_pins/scratch_card_batch_create_do.py	(revision 502)
@@ -0,0 +1,37 @@
+##parameters=type_name, datamodel
+# $Id$
+"""
+Create an empty object in the context according to the datamodel.
+
+Datamodel may be examined to create a suitable id.
+"""
+from Products.CMFCore.utils import getToolByName
+
+prefix = datamodel.get('prefix').upper()
+datamodel.set('prefix',prefix)
+bl = context.portal_catalog({'meta_type': "ScratchCardBatch",})
+b_ids = []
+for b in bl:
+    b_ids.append(b.getId)
+next = 1
+while b_ids and "%s_%d" % (prefix,next) in b_ids:
+    next += 1
+id = "%s_%d" % (prefix,next)
+datamodel.set('batch_no',next)
+##language = datamodel.get('Language')
+##if not language:
+##    ts = getToolByName(context, 'translation_service')
+##    language = ts.getSelectedLanguage()
+
+# Datamodel is passed so that flexti can initialize the object.
+new_id = context.invokeFactory(type_name, id, datamodel=datamodel,
+                               )
+if new_id is not None:
+    id = new_id
+
+ob = getattr(context, id)
+ob.getContent().edit(mapping=datamodel)
+
+#context.notifyCPSDocumentCreation(ob=ob) # BBB obsolete in CPS 3.5.0
+
+return ob
Index: WAeUP_SRP/trunk/skins/waeup_pins/scratch_card_batch_created.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_pins/scratch_card_batch_created.py	(revision 502)
+++ WAeUP_SRP/trunk/skins/waeup_pins/scratch_card_batch_created.py	(revision 502)
@@ -0,0 +1,14 @@
+## Script (Python) "cpsdocument_created"
+##bind container=container
+##bind context=context
+##bind namespace=
+##bind script=script
+##bind subpath=traverse_subpath
+##parameters=object=None
+##title=
+##
+# $Id$
+if object is not None:
+    batch = object
+batch.getContent().makePins()
+return
Index: WAeUP_SRP/trunk/skins/waeup_student/apply_admission.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/apply_admission.py	(revision 501)
+++ WAeUP_SRP/trunk/skins/waeup_student/apply_admission.py	(revision 502)
@@ -7,4 +7,5 @@
 import DateTime
 current = DateTime.DateTime()
+pr = context.portal_registration
 
 
@@ -25,5 +26,5 @@
                       layout_mode='create',
                       formaction = "apply_admission",
-                      submit = "check",
+                      button = "Open JAMB Record",
                       )
 if psm == 'invalid':
@@ -43,39 +44,26 @@
                                  )
 elif psm == 'valid':
-    jamb_id = ds.get('jamb_reg_no')
-    student = context.getContent().getStudentByRegNo(jamb_id)
-    if student is None:
-        psm = "JAMB record %s not accessible." % (jamb_id)
-        return context.application_pin_form(rendered = res,
-                                 psm = psm,
-                                 #psm = "%s, %s" % (psm,ds),
-                                 ds = ds,
-                                 )
-application = student.application
-if context.portal_workflow.getInfoFor(student,'review_state',None) == "created":
-    #student.invokeFactory('StudentClearance','clearance')
-    student.invokeFactory('StudentPersonal','personal')
-    student.content_status_modify(workflow_action="enter_application_pin")
+    s_id = ds.get('s_id')
+    return context.REQUEST.RESPONSE.redirect("%s/logged_in?__ac_name=%s&__ac_password=%s&pin=%s"
+          % (context.absolute_url(),s_id,'uNsEt',ds.get('app_ac_pin')))
+    
+##    jamb_id = ds.get('jamb_reg_no')
+##    student = context.getContent().getStudentByRegNo(jamb_id)
+##    if student is None:
+##        psm = "JAMB record %s not accessible." % (jamb_id)
+##        return context.application_pin_form(rendered = res,
+##                                 psm = psm,
+##                                 #psm = "%s, %s" % (psm,ds),
+##                                 ds = ds,
+##                                 )
+##if context.portal_workflow.getInfoFor(student,'review_state',None) == "created":
+##    #student.invokeFactory('StudentClearance','clearance')
+##da = {}
+##pin = str(ds.get('app_ac_pin'))
+##da['app_ac_pin'] = pin
+##da['app_ac_date'] = current
+##apdoc.edit(mapping = da)
 
 
-apdoc = application.getContent()
-names = apdoc.jamb_lastname.split()
-dp = {}
-if len(names) == 3:
-    dp['firstname'] = names[0].capitalize()
-    dp['middlename'] = names[1].capitalize()
-    dp['lastname'] = names[2].capitalize()
-elif len(names) == 2:
-    dp['firstname'] = names[0].capitalize()
-    dp['lastname'] = names[1].capitalize()
-else:
-    dp['lastname'] = apdoc.jamb_lastname
-dp['sex'] = apdoc.jamb_sex == 'F'
-dp['lga'] = "%s/%s" % (apdoc.jamb_state,apdoc.jamb_lga )
-student.personal.getContent().edit(mapping = dp)
-da = {}
-da['app_ac_pin'] = ds.get('app_ac_pin')
-da['app_ac_date'] = current
-apdoc.edit(mapping = da)
 # now display the passport form with jamb-data readonly
 return context.REQUEST.RESPONSE.redirect("%s/application_form" % (student.application.absolute_url()))
Index: WAeUP_SRP/trunk/skins/waeup_student/layout_application_edit.pt
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/layout_application_edit.pt	(revision 501)
+++ WAeUP_SRP/trunk/skins/waeup_student/layout_application_edit.pt	(revision 502)
@@ -81,10 +81,9 @@
          class="standalone" 
          name="cpsdocument_create_button"
-         value="apply" 
-         i18n:attributes="value" tal:condition="creation" />
+         value="apply"
+         tal:attributes="value options/button"
+         tal:condition="creation" />
 
 </form>
-
-                         
 </metal:block>
 
Index: WAeUP_SRP/trunk/skins/waeup_student/scratch_card_batch_create_do.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/scratch_card_batch_create_do.py	(revision 501)
+++ 	(revision )
@@ -1,37 +1,0 @@
-##parameters=type_name, datamodel
-# $Id$
-"""
-Create an empty object in the context according to the datamodel.
-
-Datamodel may be examined to create a suitable id.
-"""
-from Products.CMFCore.utils import getToolByName
-
-prefix = datamodel.get('prefix').upper()
-datamodel.set('prefix',prefix)
-bl = context.portal_catalog({'meta_type': "ScratchCardBatch",})
-b_ids = []
-for b in bl:
-    b_ids.append(b.getId)
-next = 1
-while b_ids and "%s_%d" % (prefix,next) in b_ids:
-    next += 1
-id = "%s_%d" % (prefix,next)
-datamodel.set('batch_no',next)
-##language = datamodel.get('Language')
-##if not language:
-##    ts = getToolByName(context, 'translation_service')
-##    language = ts.getSelectedLanguage()
-
-# Datamodel is passed so that flexti can initialize the object.
-new_id = context.invokeFactory(type_name, id, datamodel=datamodel,
-                               )
-if new_id is not None:
-    id = new_id
-
-ob = getattr(context, id)
-ob.getContent().edit(mapping=datamodel)
-
-context.notifyCPSDocumentCreation(ob=ob) # BBB obsolete in CPS 3.5.0
-
-return ob
Index: WAeUP_SRP/trunk/skins/waeup_student/scratch_card_batch_created.py
===================================================================
--- WAeUP_SRP/trunk/skins/waeup_student/scratch_card_batch_created.py	(revision 501)
+++ 	(revision )
@@ -1,14 +1,0 @@
-## Script (Python) "cpsdocument_created"
-##bind container=container
-##bind context=context
-##bind namespace=
-##bind script=script
-##bind subpath=traverse_subpath
-##parameters=object=None
-##title=
-##
-# $Id$
-if object is not None:
-    batch = object
-batch.getContent().makePins()
-return
