Index: WAeUP_SRP/base/Widgets.py
===================================================================
--- WAeUP_SRP/base/Widgets.py	(revision 2306)
+++ WAeUP_SRP/base/Widgets.py	(revision 2307)
@@ -1333,4 +1333,5 @@
     meta_type = "Pume Pin Widget"
     catalog = "applicants_catalog"
+    reference = ''
 
     def validate(self, datastructure, **kw): ###(
@@ -1341,5 +1342,5 @@
         err = 0
         mapping = {}
-
+        #import pdb;pdb.set_trace()
         prefix= self.prefix
         if prefix.startswith('@'):
@@ -1350,6 +1351,6 @@
         pin = "%(prefix)s%(b)s%(n)s" % vars()
         pin_str = "%(prefix)s-%(b)s-%(n)s" % vars()
+        member_id = str(self.portal_membership.getAuthenticatedMember())
         do = 1
-        s_id = str(self.portal_membership.getAuthenticatedMember())
         if self.isStaff():
             do = 0
@@ -1359,15 +1360,15 @@
             do = 0
             err = 'PIN must not contain "-"'
-            s_logger.info('%s entered invalid PIN  containing "-"' % (s_id))
+            s_logger.info('%s entered invalid PIN  containing "-"' % (member_id))
         elif n.find('-') > -1:
             do = 0
             err = 'PIN must not contain "-"'
-            s_logger.info('%s entered invalid PIN  containing "-"' % (s_id))
+            s_logger.info('%s entered invalid PIN  containing "-"' % (member_id))
         elif len(n) != 10:
             do = 0
             err = 'Invalid PIN length'
-            s_logger.info('%s entered invalid PIN with length %d' % (s_id,len(n)))
+            s_logger.info('%s entered invalid PIN with length %d' % (member_id,len(n)))
         elif self.reference == "":
-            ref = s_id
+            ref = n
         else:
             ref = datastructure[self.reference]
@@ -1375,29 +1376,29 @@
                 do = 0
                 datastructure.setError(widget_id, 'PIN neither checked nor used.')
-                s_logger.info('%s/%s entered wrong data together with PIN %s' % (s_id,ref,pin_str))
+                s_logger.info('%s/%s entered wrong data together with PIN %s' % (member_id,ref,pin_str))
         while do:
             ok = pins.searchAndSetRecord(pin,ref,prefix)
             if ok < -2 or ok > 2:
                 err = 'Unknown error, please report!'
-                s_logger.info('%s/%s caused unknown error with PIN %s' % (s_id,ref,pin_str))
+                s_logger.info('%s/%s caused unknown error with PIN %s' % (member_id,ref,pin_str))
                 break
             elif ok == -2:
                 err = 'Service already is activated but with a different PIN.'
-                s_logger.info('%s/%s repeatedly activated service but with different PIN %s' % (s_id,ref,pin_str))
+                s_logger.info('%s/%s repeatedly activated service but with different PIN %s' % (member_id,ref,pin_str))
                 break
             elif ok == -1:
                 err = 'Invalid PIN'
-                s_logger.info('%s/%s entered invalid PIN %s' % (s_id,ref,pin_str))
+                s_logger.info('%s/%s entered invalid PIN %s' % (member_id,ref,pin_str))
                 break
             if ok == 0:
                 err = 'PIN already used'
-                s_logger.info('%s/%s entered used PIN %s' % (s_id,ref,pin_str))
+                s_logger.info('%s/%s entered used PIN %s' % (member_id,ref,pin_str))
                 break
             if ok >= 1:
                 if self.isStudent():
                     err = "This is only for Pume application."
-                    s_logger.info('%s/%s applied for screening test with PIN %s' % (s_id,ref,pin_str))
+                    s_logger.info('%s/%s applied for screening test with PIN %s' % (member_id,ref,pin_str))
                     break
-                else:
+                elif datastructure.has_key('record'):
                     applicant = datastructure['record']
                     if not applicant.pin:
@@ -1409,7 +1410,19 @@
                         getattr(self,self.catalog).modifyRecord(**d)
                     elif applicant.pin != pin_str:
-                        s_logger.info('%s/%s tried to enter application record with different PIN %s' % (s_id,ref,pin_str))
+                        s_logger.info('%s/%s tried to enter application record with different PIN %s' % (member_id,ref,pin_str))
                     elif applicant.pin == pin_str:
-                        s_logger.info('%s/%s repeatedly entered application record with PIN %s' % (s_id,ref,pin_str))
+                        s_logger.info('%s/%s repeatedly entered application record with PIN %s' % (member_id,ref,pin_str))
+                else:
+                    datastructure['reg_no'] = ref 
+                    res = self.applicants_catalog(reg_no = ref)
+                    if not res:
+                        s_logger.info('%s successfully used PIN %s' % (ref,pin_str))
+                        d = {}
+                        d['reg_no'] = ref
+                        d['pin'] = pin_str
+                        d['status'] = 'entered'
+                        self.applicants_catalog.addRecord(**d)
+                    else:
+                        s_logger.info('%s/%s repeatedly entered application record with PIN %s' % (ref,ref,pin_str))
             break
         if err:
@@ -1422,5 +1435,4 @@
             datastructure[widget_id+'_b'] = b
             datastructure[widget_id+'_n'] = n
-            datastructure['s_id'] = s_id
         return not err
     ###)
Index: WAeUP_SRP/base/skins/waeup_student/apply_pume.py
===================================================================
--- WAeUP_SRP/base/skins/waeup_student/apply_pume.py	(revision 2306)
+++ WAeUP_SRP/base/skins/waeup_student/apply_pume.py	(revision 2307)
@@ -48,5 +48,11 @@
 if manage:
     validate = False
-
+layout = "application"
+prence = ""
+without_reg_no = False
+if traverse_subpath and traverse_subpath[0] == "prence":
+    layout = "application_prence"
+    prence = "prence"
+    without_reg_no = True
 lt = context.portal_layouts
 reg_no = request.get('widget__reg_no','').upper()
@@ -81,5 +87,5 @@
     logger.info('%s/%s views application slip' % (member,reg_no))
 
-res,psm,ds = lt.renderLayout(layout_id= 'application',
+res,psm,ds = lt.renderLayout(layout_id= layout,
                              schema_id= 'application',
                              layout_mode = mode,
@@ -96,4 +102,5 @@
                                    mode = mode,
                                    ds = ds,
+                                   prence = prence,
                                   )
 
@@ -104,4 +111,5 @@
                                    mode = mode,
                                    ds = ds,
+                                   prence = prence,
                                   )
 elif psm == '' and not manage:
@@ -110,7 +118,10 @@
                                    ds = ds,
                                    mode = mode,
+                                   prence = prence,
                                   )
 elif psm == 'valid' or (psm == '' and manage):
     pass
+if without_reg_no:
+    reg_no = ds.get('reg_no')
 data = {}
 dm = ds.getDataModel()
@@ -120,6 +131,4 @@
 data['reg_no'] = reg_no
 
-
-
 if apply_pume:
     if submitted:
@@ -127,5 +136,5 @@
         psm = "The form has already been submitted and you are not allowed to resubmit the data!"
         logger.info('%s/%s tried to resubmit application record' % (member,reg_no))
-        res,psm_dummy,ds_dummy = lt.renderLayout(layout_id= 'application',
+        res,psm_dummy,ds_dummy = lt.renderLayout(layout_id= layout,
                                 schema_id= 'application',
                                 layout_mode = mode,
@@ -152,5 +161,5 @@
         context.applicants_catalog.modifyRecord(**data)
 
-        res,psm_dummy,ds = lt.renderLayout(layout_id= 'application',
+        res,psm_dummy,ds = lt.renderLayout(layout_id= layout,
                                 schema_id= 'application',
                                 layout_mode = mode,
@@ -169,6 +178,8 @@
     psm = ""
     #set_trace()
+    if without_reg_no:
+        object['reg_no'] = reg_no
     object['pin'] = str(ds.get('pin'))
-    res,psm,ds_dummy = lt.renderLayout(layout_id= 'application',
+    res,psm,ds_dummy = lt.renderLayout(layout_id= layout,
                                 schema_id= 'application',
                                 layout_mode = mode,
@@ -183,5 +194,5 @@
         psm = "The form has already been submitted and you are not allowed to modify the data!"
         logger.info('%s/%s tried to edit submitted application record' % (member,reg_no))
-        res,psm_dummy,ds_dummy = lt.renderLayout(layout_id= 'application',
+        res,psm_dummy,ds_dummy = lt.renderLayout(layout_id= layout,
                                 schema_id= 'application',
                                 layout_mode = mode,
@@ -203,5 +214,5 @@
         psm = "You are now assuming the applicant's role!"
         logger.info('%s/%s entered application record' % (member,reg_no))
-        res,psm_dummy,ds_dummy = lt.renderLayout(layout_id= 'application',
+        res,psm_dummy,ds_dummy = lt.renderLayout(layout_id= layout,
                                 schema_id= 'application',
                                 layout_mode = mode,
@@ -223,10 +234,11 @@
 
 return context.apply_pume_form(rendered = res,
-                            psm = psm,
-                            #psm = "%s, %s" % (psm,ds),
-                            mode = mode,
-                            show_submit = passport_uploaded,
-                            ds = ds,
-                            )
-
-
+                               psm = psm,
+                               #psm = "%s, %s" % (psm,ds),
+                               mode = mode,
+                               show_submit = passport_uploaded,
+                               ds = ds,
+                               prence = prence,
+                              )
+
+
Index: WAeUP_SRP/base/skins/waeup_student/apply_pume_form.pt
===================================================================
--- WAeUP_SRP/base/skins/waeup_student/apply_pume_form.pt	(revision 2306)
+++ WAeUP_SRP/base/skins/waeup_student/apply_pume_form.pt	(revision 2307)
@@ -15,5 +15,5 @@
         <form action="" id="editForm" method="post" 
               enctype="multipart/form-data" class="workflow"
-              tal:attributes="action string:${context/absolute_url}/apply_pume"
+              tal:attributes="action string:${context/absolute_url}/apply_pume/${options/prence}"
               >
           <input type="hidden" name="reg_no"
