Index: /WAeUP_SRP/trunk/Students.py
===================================================================
--- /WAeUP_SRP/trunk/Students.py	(revision 709)
+++ /WAeUP_SRP/trunk/Students.py	(revision 710)
@@ -28,5 +28,9 @@
     if letter not in ('ABCDEFGIHKLMNOPQRSTUVWXY'):
         letter= r.choice('ABCDEFGHKLMNPQRSTUVWXY')
-    return "%c%d" % (letter,r.randint(99999,1000000))
+    students = context.portal_catalog(meta_type = "StudentsFolder")[-1]
+    sid = "%c%d" % (letter,r.randint(99999,1000000))
+    while hasattr(students, sid):
+        sid = "%c%d" % (letter,r.randint(99999,1000000))
+    return sid 
     #return "%c%d" % (r.choice('ABCDEFGHKLMNPQRSTUVWXY'),r.randint(99999,1000000))
 
Index: /WAeUP_SRP/trunk/WAeUPTables.py
===================================================================
--- /WAeUP_SRP/trunk/WAeUPTables.py	(revision 709)
+++ /WAeUP_SRP/trunk/WAeUPTables.py	(revision 710)
@@ -104,6 +104,11 @@
 
 
-    def searchAndSetRecord(self, uid, student_id):
+    def searchAndSetRecord(self, uid, student_id,prefix):
         #records = self.searchResults(uid=uid)
+        records = self.searchResults(student = student_id)
+        if len(records) > 0:
+            for r in records:
+                if r.pin != uid and r.prefix_batch.startswith(prefix): 
+                    return -2
         records = self.searchResults({"%s" % self.key : uid})
         if len(records) > 1:
Index: /WAeUP_SRP/trunk/Widgets.py
===================================================================
--- /WAeUP_SRP/trunk/Widgets.py	(revision 709)
+++ /WAeUP_SRP/trunk/Widgets.py	(revision 710)
@@ -214,36 +214,36 @@
 ###)
 
-class StudentIdWidget(CPSStringWidget): ###(
-    """ StudentId Widget"""
-    meta_type = "StudentId Widget"
-    digits = 8
-    digits_str = "N"*digits
-    letters = 2
-    letters_str = "L"*letters
-
-    def validate(self, datastructure, **kw):
-        """Validate datastructure and update datamodel."""
-
-        valid = CPSStringWidget.validate(self, datastructure, **kw)
-        if not valid:
-            return 0
-        else:
-            widget_id = self.getWidgetId()
-            value = datastructure[widget_id]
-            err = 0
-            if not (len(value) == self.digits + self.letters and value[:self.digits].isdigit() and value[self.digits:].isalpha()):
-                err = 'Invalid Registration Number in the format: %s%s with N = Number, L = Letter' % (self.digits_str,self.letters_str)
-            if err:
-                datastructure.setError(widget_id, err)
-            else:
-                datamodel = datastructure.getDataModel()
-                datamodel[self.fields[0]] = value
-
-            return not err
-
-InitializeClass(StudentIdWidget)
-widgetRegistry.register(StudentIdWidget)
-
-###)
+##class StudentIdWidget(CPSStringWidget): ###(
+##    """ StudentId Widget"""
+##    meta_type = "StudentId Widget"
+##    digits = 8
+##    digits_str = "N"*digits
+##    letters = 2
+##    letters_str = "L"*letters
+##
+##    def validate(self, datastructure, **kw):
+##        """Validate datastructure and update datamodel."""
+##
+##        valid = CPSStringWidget.validate(self, datastructure, **kw)
+##        if not valid:
+##            return 0
+##        else:
+##            widget_id = self.getWidgetId()
+##            value = datastructure[widget_id]
+##            err = 0
+##            if not (len(value) == self.digits + self.letters and value[:self.digits].isdigit() and value[self.digits:].isalpha()):
+##                err = 'Invalid Registration Number in the format: %s%s with N = Number, L = Letter' % (self.digits_str,self.letters_str)
+##            if err:
+##                datastructure.setError(widget_id, err)
+##            else:
+##                datamodel = datastructure.getDataModel()
+##                datamodel[self.fields[0]] = value
+##
+##            return not err
+##
+##InitializeClass(StudentIdWidget)
+##widgetRegistry.register(StudentIdWidget)
+##
+#####)
 
 class JambRegNoWidget(CPSStringWidget): ###(
@@ -270,5 +270,5 @@
                 s = getStudentByRegNo(self,value)
                 if s is None:
-                    err = 'No JAMB data for %s' % (value)
+                    err = 'No Student with JAMB-Reg-No %s' % (value)
             if err:
                 datastructure.setError(widget_id, err)
@@ -342,7 +342,10 @@
             ref = datastructure[self.reference]
         #import pdb;pdb.set_trace()
-        ok = pins.searchAndSetRecord(pin,ref)
+        ok = pins.searchAndSetRecord(pin,ref,self.prefix)
         while 1:
-            if ok == -1:
+            if ok == -2:
+                err = 'You have already applied with a different Pin, please login'
+                break
+            elif ok == -1:
                 err = 'invalid Pin'
                 break
@@ -351,4 +354,5 @@
                 break
             if ok >= 1:
+                #import pdb;pdb.set_trace()
                 if self.isStudent():
                     student = self.getStudentInfo()['student']
Index: /WAeUP_SRP/trunk/profiles/default/layouts/student_application.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/layouts/student_application.xml	(revision 709)
+++ /WAeUP_SRP/trunk/profiles/default/layouts/student_application.xml	(revision 710)
@@ -50,4 +50,5 @@
  </widget>
  <widget name="appl_email" meta_type="Email Widget">
+  <property name="is_required">True</property>
   <property name="title">Email Address</property>
   <property name="fields">
@@ -158,5 +159,5 @@
   <property name="hidden_readonly_layout_modes"/>
  </widget>
- <widget name="jamb_reg_no" meta_type="StudentId Widget">
+ <widget name="jamb_reg_no" meta_type="JambRegNo Widget">
   <property name="title">JAMB Registration Number</property>
   <property name="fields">
Index: /WAeUP_SRP/trunk/profiles/default/layouts/student_application_fe.xml
===================================================================
--- /WAeUP_SRP/trunk/profiles/default/layouts/student_application_fe.xml	(revision 709)
+++ /WAeUP_SRP/trunk/profiles/default/layouts/student_application_fe.xml	(revision 710)
@@ -61,8 +61,8 @@
   <property name="label">Email Address</property>
   <property name="label_edit">Email Address</property>
-  <property name="readonly_layout_modes">
-  </property>
-  <property name="hidden_layout_modes">
-  </property>
+  <property name="is_required">False</property>
+  <property name="readonly_layout_modes">
+  </property>
+  <property name="hidden_layout_modes">create</property>
   <property name="hidden_readonly_layout_modes"/>
  </widget>
@@ -73,9 +73,9 @@
   </property>
   <property name="label">Mobile Phone No</property>
+  <property name="is_required">False</property>
   <property name="label_edit">Mobile Phone No</property>
   <property name="readonly_layout_modes">
   </property>
-  <property name="hidden_layout_modes">
-  </property>
+  <property name="hidden_layout_modes">create</property>
   <property name="hidden_readonly_layout_modes"/>
  </widget>
@@ -142,5 +142,5 @@
   <property name="hidden_readonly_layout_modes"/>
  </widget>
- <widget name="jamb_reg_no" meta_type="StudentId Widget">
+ <widget name="jamb_reg_no" meta_type="JambRegNo Widget">
   <property name="title">JAMB Registration Number</property>
   <property name="fields">
Index: /WAeUP_SRP/trunk/skins/waeup_pins/getBatchInfo.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_pins/getBatchInfo.py	(revision 709)
+++ /WAeUP_SRP/trunk/skins/waeup_pins/getBatchInfo.py	(revision 710)
@@ -32,5 +32,5 @@
         jno = item['student']
         res = context.portal_catalog(SearchableText=jno,portal_type='StudentApplication')
-        if len(res) > 1:
+        if len(res) > 0:
             item['student_url'] = "%s/%s" % (context.portal_url(),res[0].relative_path)
         else:
Index: /WAeUP_SRP/trunk/skins/waeup_student/layout_application_edit.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/layout_application_edit.pt	(revision 709)
+++ /WAeUP_SRP/trunk/skins/waeup_student/layout_application_edit.pt	(revision 710)
@@ -27,5 +27,5 @@
               err python:ds.getError(wid);
               err_mapping python:ds.getErrorMapping(wid);
-              is_required python: widget.is_required and creation and ('create' not in widget.readonly_layout_modes);
+              is_required python: widget.is_required;
               tooltip_id python:wid + '_help';
               widget_css_class cell/widget_css_class|nothing;
Index: /WAeUP_SRP/trunk/skins/waeup_student/passport_entry_view.pt
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/passport_entry_view.pt	(revision 709)
+++ /WAeUP_SRP/trunk/skins/waeup_student/passport_entry_view.pt	(revision 710)
@@ -1,3 +1,10 @@
-<metal:html tal:define="info context/getStudentInfo">
+<metal:html tal:define="info context/getStudentInfo;
+            rendered_main python:info['app_doc'].renderEdit(
+                                                        layout_mode='edit',
+                                                        proxy=info['app'],
+                                                        no_form = True,
+                                                        schema_id = 'student_application',
+                                                        layout_id='student_application_fe',
+            )">
   <metal:body use-macro="here/main_template/macros/master">
     <metal:main fill-slot="main">
@@ -12,10 +19,5 @@
         <h3>Upload your Passport Picture!</h3>
         <br />
-        <span tal:omit-tag=""
-              tal:content="structure python: info['app_doc'].render(proxy=info['app_doc'],
-              layout_mode='edit', 
-              layout_id='student_application_fe',
-              )" 
-              />
+        <span tal:omit-tag="" tal:replace="structure rendered_main"/>
       </span>
     </metal:main>
Index: /WAeUP_SRP/trunk/skins/waeup_student/student_edit.py
===================================================================
--- /WAeUP_SRP/trunk/skins/waeup_student/student_edit.py	(revision 709)
+++ /WAeUP_SRP/trunk/skins/waeup_student/student_edit.py	(revision 710)
@@ -48,10 +48,14 @@
                                     use_session=True)
         action = "/passport_entry_view"
-        if app_doc.passport is not None:
-            psm = 'You successfully uploaded your passport image.'
-            args = {'apply_button': 'Apply',}
+        if is_valid:
+            if app_doc.passport is not None:
+                psm = 'You successfully uploaded your passport image.'
+                args = {'apply_button': 'Apply',}
+            else:
+                psm = "You didn't upload a passport image."
+                args = {}
         else:
-            psm = "You didn't upload a passport image."
-            args = {}
+            psm = 'psm_content_error'
+            args = getFormUidUrlArg(REQUEST)
     elif 'apply_admission' not in REQUEST.form:
         is_valid, ds = app_doc.validate(request=REQUEST,
