Index: main/waeup.kofa/trunk/CHANGES.txt
===================================================================
--- main/waeup.kofa/trunk/CHANGES.txt	(revision 13101)
+++ main/waeup.kofa/trunk/CHANGES.txt	(revision 13103)
@@ -4,4 +4,7 @@
 1.3.2.dev0 (unreleased)
 =======================
+
+* Remove manual clearance lock. Replace `clearance_locked` field by
+  property attribute.
 
 * Make student email field required.
Index: main/waeup.kofa/trunk/docs/source/userdocs/students/browser.rst
===================================================================
--- main/waeup.kofa/trunk/docs/source/userdocs/students/browser.rst	(revision 13101)
+++ main/waeup.kofa/trunk/docs/source/userdocs/students/browser.rst	(revision 13103)
@@ -72,14 +72,4 @@
 
 
-.. _clearance_form_locking:
-
-Clearance Form Locking
-======================
-
-
-
-
-
-
 .. _transferring_students:
 
Index: main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_browser.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_browser.py	(revision 13101)
+++ main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_browser.py	(revision 13103)
@@ -334,5 +334,5 @@
         # No students yet
         self.assertEqual(self.browser.contents,
-            'adm_code,clearance_locked,clr_code,date_of_birth,email,'
+            'adm_code,clr_code,date_of_birth,email,'
             'employer,firstname,lastname,matric_number,middlename,'
             'nationality,officer_comment,perm_address,personal_updated,'
Index: main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py	(revision 13101)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py	(revision 13103)
@@ -638,9 +638,7 @@
     def form_fields(self):
         if self.context.is_postgrad:
-            form_fields = grok.AutoFields(
-                IPGStudentClearance).omit('clearance_locked')
-        else:
-            form_fields = grok.AutoFields(
-                IUGStudentClearance).omit('clearance_locked')
+            form_fields = grok.AutoFields(IPGStudentClearance)
+        else:
+            form_fields = grok.AutoFields(IUGStudentClearance)
         if not getattr(self.context, 'officer_comment'):
             form_fields = form_fields.omit('officer_comment')
@@ -669,9 +667,7 @@
     def form_fields(self):
         if self.context.is_postgrad:
-            form_fields = grok.AutoFields(
-                IPGStudentClearance).omit('clearance_locked')
-        else:
-            form_fields = grok.AutoFields(
-                IUGStudentClearance).omit('clearance_locked')
+            form_fields = grok.AutoFields(IPGStudentClearance)
+        else:
+            form_fields = grok.AutoFields(IUGStudentClearance)
         if not getattr(self.context, 'officer_comment'):
             form_fields = form_fields.omit('officer_comment')
@@ -2413,8 +2409,8 @@
         if self.context.is_postgrad:
             form_fields = grok.AutoFields(IPGStudentClearance).omit(
-                'clearance_locked', 'clr_code', 'officer_comment')
+                'clr_code', 'officer_comment')
         else:
             form_fields = grok.AutoFields(IUGStudentClearance).omit(
-                'clearance_locked', 'clr_code', 'officer_comment')
+                'clr_code', 'officer_comment')
         return form_fields
 
Index: main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py	(revision 13101)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/interfaces.py	(revision 13103)
@@ -209,4 +209,5 @@
     personal_data_expired = Attribute('True if personal data expired')
     transcript_enabled = Attribute('True if transcript processing is enabled')
+    clearance_locked = Attribute('True if clearance form is locked')
 
     password = Attribute('Encrypted password')
@@ -309,10 +310,4 @@
     officer_comment = schema.Text(
         title = _(u"Officer's Comment"),
-        required = False,
-        )
-
-    clearance_locked = schema.Bool(
-        title = _(u'Clearance form locked'),
-        default = False,
         required = False,
         )
Index: main/waeup.kofa/trunk/src/waeup/kofa/students/student.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/student.py	(revision 13101)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/student.py	(revision 13103)
@@ -239,4 +239,8 @@
         return True
 
+    @property
+    def clearance_locked(self):
+        return self.state != CLEARANCE
+
     def transfer(self, certificate, current_session=None,
         current_level=None, current_verdict=None, previous_verdict=None):
@@ -324,8 +328,4 @@
     message.
     """
-    if student.state == CLEARANCE:
-        student.clearance_locked = False
-    else:
-        student.clearance_locked = True
     studycourse = createObject(u'waeup.StudentStudyCourse')
     student['studycourse'] = studycourse
Index: main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py	(revision 13101)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_batching.py	(revision 13103)
@@ -224,5 +224,4 @@
         student.matric_number = u'234'
         student.adm_code = u'my adm code'
-        student.clearance_locked = False
         student.clr_code = u'my clr code'
         student.perm_address = u'Studentroad 21\nLagos 123456\n'
Index: main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 13101)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 13103)
@@ -1876,5 +1876,4 @@
         self.browser.open(self.manage_clearance_path)
         self.assertFalse('Employer' in self.browser.contents)
-        self.student.clearance_locked = False
         self.browser.open(self.edit_clearance_path)
         self.assertFalse('Employer' in self.browser.contents)
@@ -1888,4 +1887,5 @@
         self.browser.open(self.manage_clearance_path)
         self.assertTrue('Employer' in self.browser.contents)
+        IWorkflowState(self.student).setState('clearance started')
         self.browser.open(self.edit_clearance_path)
         self.assertTrue('Employer' in self.browser.contents)
@@ -2619,5 +2619,4 @@
         self.browser.getControl(name="form.password").value = 'spwd'
         self.browser.getControl("Login").click()
-        self.student.clearance_locked = False
         self.browser.open(self.edit_clearance_path)
         self.browser.getControl(name="form.date_of_birth").value = '09/10/1961'
@@ -3416,5 +3415,5 @@
             self.browser.headers['content-disposition'])
         self.assertTrue(
-            'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,'
+            'adm_code,clr_code,date_of_birth,email,employer,'
             'firstname,lastname,matric_number,middlename,nationality,'
             'officer_comment,perm_address,personal_updated,phone,reg_number,'
@@ -3422,5 +3421,5 @@
             'password,state,history,certcode,is_postgrad,current_level,'
             'current_session\r\n'
-            ',1,,1981-02-04#,aa@aa.ng,,Anna,Tester,234,,,,,,'
+            ',,1981-02-04#,aa@aa.ng,,Anna,Tester,234,,,,,,'
             '1234#,123,m,K1000000,0,,,{SSHA}' in self.browser.contents)
 
@@ -3516,5 +3515,5 @@
             self.browser.headers['content-disposition'])
         self.assertTrue(
-            'adm_code,clearance_locked,clr_code,date_of_birth,email,employer,'
+            'adm_code,clr_code,date_of_birth,email,employer,'
             'firstname,lastname,matric_number,middlename,nationality,'
             'officer_comment,perm_address,personal_updated,phone,reg_number,'
@@ -3522,5 +3521,5 @@
             'password,state,history,certcode,is_postgrad,current_level,'
             'current_session\r\n'
-            ',1,,1981-02-04#,aa@aa.ng,,Anna,Tester,234,,,,,,'
+            ',,1981-02-04#,aa@aa.ng,,Anna,Tester,234,,,,,,'
             '1234#,123,m,K1000000,0,,,{SSHA}' in self.browser.contents)
         self.assertEqual(len(self.app['datacenter'].running_exports), 1)
Index: main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py	(revision 13101)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_export.py	(revision 13103)
@@ -125,5 +125,5 @@
 
     std_csv_entry = (
-        'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,'
+        'my adm code,my clr code,1981-02-04#,anna@sample.com,,'
         'Anna,Tester,234,M.,NG,,"Studentroad 21\nLagos 123456\n",,'
         '+234-123-12345#,123,f,A111111,0,,,,created'
@@ -156,5 +156,5 @@
         result = open(self.outfile, 'rb').read()
         self.assertTrue(
-            'adm_code,clearance_locked,clr_code,date_of_birth,email,'
+            'adm_code,clr_code,date_of_birth,email,'
             'employer,firstname,lastname,matric_number,middlename,'
             'nationality,officer_comment,perm_address,personal_updated,'
@@ -162,5 +162,5 @@
             'transcript_comment,password,state,history,certcode,is_postgrad,'
             'current_level,current_session\r\n'
-            'my adm code,0,my clr code,'
+            'my adm code,my clr code,'
             '1981-02-04#,anna@sample.com,,Anna,Tester,234,M.,NG,,'
             '"Studentroad 21\nLagos 123456\n",,+234-123-12345#,123,f,'
@@ -178,5 +178,5 @@
         result = open(self.outfile, 'rb').read()
         self.assertTrue(
-            'adm_code,clearance_locked,clr_code,date_of_birth,email,'
+            'adm_code,clr_code,date_of_birth,email,'
             'employer,firstname,lastname,matric_number,middlename,'
             'nationality,officer_comment,perm_address,personal_updated,'
@@ -184,5 +184,5 @@
             'transcript_comment,password,state,history,certcode,'
             'is_postgrad,current_level,current_session\r\n'
-            'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,'
+            'my adm code,my clr code,1981-02-04#,anna@sample.com,,'
             'Anna,Tester,234,M.,NG,,"Studentroad 21\nLagos 123456\n"'
             ',,+234-123-12345#,123,f,A111111,0,,,,created'
@@ -198,5 +198,5 @@
         result = open(self.outfile, 'rb').read()
         self.assertTrue(
-            'adm_code,clearance_locked,clr_code,date_of_birth,email,'
+            'adm_code,clr_code,date_of_birth,email,'
             'employer,firstname,lastname,matric_number,middlename,'
             'nationality,officer_comment,perm_address,personal_updated,'
@@ -204,5 +204,5 @@
             'transcript_comment,password,state,history,certcode,'
             'is_postgrad,current_level,current_session\r\n'
-            'my adm code,0,my clr code,1981-02-04#,anna@sample.com,,'
+            'my adm code,my clr code,1981-02-04#,anna@sample.com,,'
             'Anna,Tester,234,M.,NG,,"Studentroad 21\nLagos 123456\n"'
             ',,+234-123-12345#,123,f,A111111,0,,,,created'
Index: main/waeup.kofa/trunk/src/waeup/kofa/students/workflow.py
===================================================================
--- main/waeup.kofa/trunk/src/waeup/kofa/students/workflow.py	(revision 13101)
+++ main/waeup.kofa/trunk/src/waeup/kofa/students/workflow.py	(revision 13103)
@@ -212,6 +212,4 @@
 
 FORBIDDEN_POSTGRAD_TRANS = ['reset6', 'register_courses']
-LOCK_CLEARANCE_TRANS = ('reset2', 'request_clearance')
-UNLOCK_CLEARANCE_TRANS = ('reset3', 'reset4', 'start_clearance')
 
 registration_workflow = KofaWorkflow(REGISTRATION_TRANSITIONS)
@@ -247,8 +245,4 @@
     history = IObjectHistory(obj)
     history.addMessage(msg)
-    if event.transition.transition_id in LOCK_CLEARANCE_TRANS:
-        obj.clearance_locked = True
-    if event.transition.transition_id in UNLOCK_CLEARANCE_TRANS:
-        obj.clearance_locked = False
     # School fee payment of returning students triggers the change of
     # current session, current level, and current verdict
