Index: /main/waeup.kofa/trunk/CHANGES.txt
===================================================================
--- /main/waeup.kofa/trunk/CHANGES.txt	(revision 17916)
+++ /main/waeup.kofa/trunk/CHANGES.txt	(revision 17917)
@@ -4,4 +4,6 @@
 1.8.2.dev0 (unreleased)
 =======================
+
+* Implement `ExportPDFFinalClearanceSlip`.
 
 * Add an id to download filenames if necessary. Enable this feature for
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py	(revision 17916)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py	(revision 17917)
@@ -3016,4 +3016,56 @@
         return
 
+class ExportPDFFinalClearanceSlip(UtilityView, grok.View):
+    """Deliver a PDF document.
+    """
+    grok.context(IStudent)
+    grok.name('final_clearance_slip.pdf')
+    grok.require('waeup.viewStudent')
+    prefix = 'form'
+    form_fields = None
+
+    omit_fields = (
+        'suspended',
+        'adm_code',
+        'suspended_comment',
+        'current_level',
+        'flash_notice',
+        'entry_session',
+        'parents_email',
+        'email',
+        'phone',
+        'date_of_birth',
+        'sex',)
+
+    @property
+    def label(self):
+        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
+        return translate(_('Final Clearance Document'), 'waeup.kofa',
+            target_language=portal_language)
+
+    def render(self):
+        final_slip = getUtility(IExtFileStore).getFileByContext(
+            self.context.student, attr='routingslip.pdf')
+        if not final_slip:
+            emit_lock_message(self,
+                _('The requested form is locked.'))
+            return
+        studentview = StudentBasePDFFormPage(self.context.student,
+            self.request, self.omit_fields)
+        students_utils = getUtility(IStudentsUtils)
+        note = _('''
+The final clearance routing slip has been successfully uploaded onto the Kofa portal.
+
+Take this slip to the Exams and Records Division for the collection of Statement of Results.
+''')
+        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
+        note = translate(
+            note, 'waeup.kofa', target_language=portal_language)
+        return students_utils.renderPDF(
+            self, 'final_clearance_slip.pdf',
+            self.context.student, studentview,
+            omit_fields=self.omit_fields,
+            note=note)
+
 class StartClearancePage(KofaPage):
     grok.context(IStudent)
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 17916)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py	(revision 17917)
@@ -3058,4 +3058,32 @@
         print "Sample png file written to %s" % path
 
+    def test_student_final_clearance(self):
+        self.student.browsertest = True
+        self.browser.open(self.login_path)
+        self.browser.getControl(name="form.login").value = self.student_id
+        self.browser.getControl(name="form.password").value = 'spwd'
+        self.browser.getControl("Login").click()
+        self.browser.open(self.student_path)
+        self.browser.getLink("Upload final clearance routing slip").click()
+        ctrl = self.browser.getControl(name='finalclearanceuploadedit')
+        file_obj = open(SAMPLE_PDF, 'rb')
+        file_ctrl = ctrl.mech_control
+        file_ctrl.add_file(file_obj, filename='routing_slip.pdf')
+        self.browser.getControl(
+            name='upload_finalclearanceuploadedit').click()
+        self.assertTrue(
+            'href="http://localhost/app/students/K1000000/routingslip.pdf"'
+            in self.browser.contents)
+        self.assertTrue(
+            'File routingslip.pdf uploaded' in self.browser.contents)
+        self.browser.getLink("Download Final Clearance Document").click()
+        self.assertEqual(self.browser.headers['Status'], '200 Ok')
+        self.assertEqual(self.browser.headers['Content-Type'],
+                         'application/pdf')
+        path = os.path.join(samples_dir(), 'final_clearance_slip.pdf')
+        open(path, 'wb').write(self.browser.contents)
+        print "Sample PDF final_clearance_slip.pdf written to %s" % path
+        return
+
     def test_student_course_registration(self):
         # Student cant login if their password is not set
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py	(revision 17916)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/utils.py	(revision 17917)
@@ -1268,5 +1268,7 @@
 
     def final_clearance_enabled(self, student):
-        # disabled in base package
+        # disabled in base package but can be enabled in tests
+        if getattr(student,'browsertest', None) == True:
+            return True
         return False
 
Index: /main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py
===================================================================
--- /main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py	(revision 17916)
+++ /main/waeup.kofa/trunk/src/waeup/kofa/students/viewlets.py	(revision 17917)
@@ -32,5 +32,6 @@
     OnlinePaymentDisplayFormPage, BedTicketDisplayFormPage,
     StudentClearanceEditFormPage, StudentPersonalEditFormPage,
-    PaymentsManageFormPage, StudyCourseTranscriptPage)
+    PaymentsManageFormPage, StudyCourseTranscriptPage,
+    StudentFinalClearanceUploadPage)
 from waeup.kofa.students.interfaces import (
     IStudentsContainer, IStudent, IStudentStudyCourse, IStudentStudyLevel,
@@ -897,4 +898,21 @@
             "The electronic signature replaces your handwritten signature.\\n\\n"
             "You really want to sign the transcript?'")
+
+class FinalClearanceSlipActionButton(ManageActionButton):
+    grok.order(1)
+    grok.context(IStudent)
+    grok.view(StudentFinalClearanceUploadPage)
+    grok.require('waeup.viewStudent')
+    icon = 'actionicon_pdf.png'
+    text = _('Download Final Clearance Document')
+    target = 'final_clearance_slip.pdf'
+
+    @property
+    def target_url(self):
+        final_slip = getUtility(IExtFileStore).getFileByContext(
+            self.context.student, attr='routingslip.pdf')
+        if final_slip:
+            return self.view.url(self.view.context, self.target)
+        return False
 
 
