Index: /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/browser/pdf.py
===================================================================
--- /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/browser/pdf.py	(revision 11886)
+++ /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/browser/pdf.py	(revision 11887)
@@ -21,4 +21,5 @@
 
 import os
+from string import Template
 from waeup.kofa.browser.pdf import PDFCreator
 
@@ -34,2 +35,47 @@
     #watermark_pos = [-25, 100]
     logo_pos = [507, 740, 70]
+
+    signature_img_path = os.path.join(
+        os.path.dirname(__file__), 'static', 'pdf_signature.png')
+
+    def substitute_markers(self, text):
+        """If `text` contains some marker, substitute it.
+
+        Markers are standard library string template placeholders. See
+        https://docs.python.org/2/library/string.html and
+        `string.Template` for details. Roughly, placeholders look like
+        ``${some_marker}``.
+
+        Valid markers:
+           ``signature_img_path`` -- path to signature image stored in
+                                     `signature_img_path`` attribute.
+        """
+        text = Template(text)
+        return text.safe_substitute(
+            {
+                'signature_img_path': self.signature_img_path,
+                }
+            )
+
+    def create_pdf(self, *args, **kw):
+        """Create PDF from args and keywords.
+
+        Unlike the base method, we mangle any `notes` keyword and
+        substitute any valid placeholder strings in it. See
+        `substitute_markers` for a list of valid placeholders.
+
+        XXX: This is only a quick, dirty hack, that should not appear
+             in this package. Instead it should be moved to the
+             waeup.kofa basepackage.
+
+        Please note: string substitution like this can introduce nasty
+        security holes. For instance all dynamic input in `notes` must
+        be cleaned up and placeholder expressions should be removed
+        from it before using it in `note`.
+
+        Also, `note` is clearly misused in this case. We might want to
+        look for a more general approach, maybe z3c.rml?
+        """
+        if 'note' in kw.keys() and kw['note'] is not None:
+            kw['note'] = self.substitute_markers(kw['note'])
+        return super(CustomPDFCreator, self).create_pdf(*args, **kw)
Index: /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/browser.py
===================================================================
--- /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/browser.py	(revision 11886)
+++ /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/students/browser.py	(revision 11887)
@@ -56,4 +56,5 @@
     )
 
+
 class CustomStudentBaseEditFormPage(NigeriaStudentBaseEditFormPage):
     """ View to edit student base data
@@ -62,5 +63,7 @@
         'email', 'phone', 'sex')
 
-class CustomStudentPersonalDisplayFormPage(NigeriaStudentPersonalDisplayFormPage):
+
+class CustomStudentPersonalDisplayFormPage(
+    NigeriaStudentPersonalDisplayFormPage):
     """ Page to display student personal data
     """
@@ -73,4 +76,5 @@
         'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le')
 
+
 class CustomStudentPersonalEditFormPage(NigeriaStudentPersonalEditFormPage):
     """ Page to edit personal data
@@ -79,5 +83,7 @@
         'personal_updated')
 
-class CustomStudentPersonalManageFormPage(NigeriaStudentPersonalManageFormPage):
+
+class CustomStudentPersonalManageFormPage(
+    NigeriaStudentPersonalManageFormPage):
     """ Page to edit personal data
     """
@@ -86,4 +92,5 @@
     form_fields[
         'personal_updated'].custom_widget = FriendlyDatetimeDisplayWidget('le')
+
 
 class CustomOnlinePaymentDisplayFormPage(NigeriaOnlinePaymentDisplayFormPage):
@@ -98,4 +105,5 @@
         'payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
 
+
 class CustomOnlinePaymentAddFormPage(NigeriaOnlinePaymentAddFormPage):
     """ Page to add an online payment ticket
@@ -103,4 +111,5 @@
     form_fields = grok.AutoFields(ICustomStudentOnlinePayment).select(
         'p_category')
+
 
 class CustomExportPDFPaymentSlipPage(NigeriaExportPDFPaymentSlipPage):
@@ -110,6 +119,9 @@
     form_fields = grok.AutoFields(ICustomStudentOnlinePayment).omit(
         'provider_amt', 'gateway_amt', 'thirdparty_amt', 'p_item')
-    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
-    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget('le')
+    form_fields['creation_date'].custom_widget = FriendlyDatetimeDisplayWidget(
+        'le')
+    form_fields['payment_date'].custom_widget = FriendlyDatetimeDisplayWidget(
+        'le')
+
 
 class CustomStartClearancePage(StartClearancePage):
@@ -118,5 +130,6 @@
 
 
-class CustomStudentClearanceDisplayFormPage(NigeriaStudentClearanceDisplayFormPage):
+class CustomStudentClearanceDisplayFormPage(
+    NigeriaStudentClearanceDisplayFormPage):
     """ Page to display student clearance data
     """
@@ -135,4 +148,5 @@
             form_fields['officer_comment'].custom_widget = BytesDisplayWidget
         return form_fields
+
 
 class CustomExportPDFClearanceSlipPage(NigeriaExportPDFClearanceSlipPage):
@@ -152,5 +166,7 @@
         return form_fields
 
-class CustomStudentClearanceManageFormPage(NigeriaStudentClearanceManageFormPage):
+
+class CustomStudentClearanceManageFormPage(
+    NigeriaStudentClearanceManageFormPage):
     """ Page to edit student clearance data
     """
@@ -165,4 +181,5 @@
                 ICustomUGStudentClearance).omit('clr_code')
         return form_fields
+
 
 class CustomStudentClearanceEditFormPage(NigeriaStudentClearanceEditFormPage):
@@ -183,4 +200,5 @@
         return form_fields
 
+
 class BedTicketAddPage(BedTicketAddPage):
     """ Page to add an online payment ticket
@@ -190,4 +208,5 @@
     with_ac = False
 
+
 class CustomExportPDFAdmissionSlipPage(ExportPDFAdmissionSlipPage):
     """Deliver a PDF Admission slip.
@@ -197,5 +216,6 @@
     omit_fields = ('date_of_birth', 'current_level')
 
-    form_fields = grok.AutoFields(ICustomStudent).select('student_id', 'reg_number')
+    form_fields = grok.AutoFields(ICustomStudent).select(
+        'student_id', 'reg_number')
 
     def render(self):
@@ -208,4 +228,5 @@
         return students_utils.renderPDFAdmissionLetter(self,
             self.context.student, omit_fields=self.omit_fields)
+
 
 class ExportPDFAdmissionNotificationPage(UtilityView, grok.View):
@@ -235,4 +256,5 @@
             pre_text=pre_text, post_text=post_text)
 
+
 # copied from waeup.aaue
 class CustomExportPDFCourseRegistrationSlipPage(
@@ -262,5 +284,5 @@
              'I recommend to approve the course registration. <br>',
              _('Head of Department\'s Signature'), '<br>')],
-            [('' , _('Principal Assistant Registrar\'s Signature'), '<br>')],
+            [('', _('Principal Assistant Registrar\'s Signature'), '<br>')],
             [('', _('Director\'s Signature'))]
             )
@@ -270,8 +292,12 @@
         Sem = translate('Sem.', 'waeup.kofa', target_language=portal_language)
         Code = translate('Code', 'waeup.kofa', target_language=portal_language)
-        Title = translate('Title', 'waeup.kofa', target_language=portal_language)
-        Cred = translate('Cred.', 'waeup.kofa', target_language=portal_language)
-        Score = translate('Score', 'waeup.kofa', target_language=portal_language)
-        Grade = translate('Grade', 'waeup.kofa', target_language=portal_language)
+        Title = translate('Title', 'waeup.kofa',
+                          target_language=portal_language)
+        Cred = translate(
+            'Cred.', 'waeup.kofa', target_language=portal_language)
+        Score = translate('Score', 'waeup.kofa',
+                          target_language=portal_language)
+        Grade = translate('Grade', 'waeup.kofa',
+                          target_language=portal_language)
         Signature = translate(_('HOD\'s Signature'), 'waeup.kwarapoly',
             target_language=portal_language)
@@ -283,10 +309,11 @@
         tableheader = []
         contenttitle = []
-        for i in range(1,7):
+        for i in range(1, 7):
             tabledata.append(sorted(
-                [value for value in self.context.values() if value.semester == i],
+                [value for value in self.context.values()
+                 if value.semester == i],
                 key=lambda value: str(value.semester) + value.code))
-            tableheader.append([(Code,'code', 2.0),
-                               (Title,'title', 7),
+            tableheader.append([(Code, 'code', 2.0),
+                               (Title, 'title', 7),
                                (Cred, 'credits', 1.5),
                                (Score, 'score', 1.4),
@@ -310,4 +337,5 @@
             )
 
+
 class ExportPDFRegistrationSlipPage(grok.View):
     """Deliver a PDF slip of the context.
@@ -343,12 +371,30 @@
 <strong>IMPORTANT NOTICE</strong>
 <br /><br />
-This registration slip must be supplied before attendance of lectures. Note that:<br /><br />
-1. All fees due must be paid in full.<br /><br />
-2. All information required must be available on the Registration Form.<br /><br />
-3. The Signature of all appropriate Polytechnic Authority must be obtained.<br /><br />
-4. The endorsed Registration Form should be returned to the respective Institutes and Administrative Offices.<br /><br />
-5. No student may change his subject or course of study as shown in the signed Registration Form without clearance from the Admissions Office and the Director of the appropriate Institute.<br /><br />
-6. All candidates admitted into the HND I programmes should submit the photocopies of their original certificates of ND and SSCE with scratch card online for clearance latest a week after the admission is offered. Failure to comply with this directive may lead to the forfeiture of the admission.<br /><br />
-
+This registration slip must be supplied before attendance of lectures.
+Note that:
+<br /><br />
+1. All fees due must be paid in full.
+<br /><br />
+2. All information required must be available on the Registration Form.
+<br /><br />
+3. The Signature of all appropriate Polytechnic Authority must be obtained.
+<br /><br />
+4. The endorsed Registration Form should be returned to the respective
+   Institutes and Administrative Offices.
+<br /><br />
+5. No student may change his subject or course of study as shown in the
+   signed Registration Form without clearance from the Admissions Office
+   and the Director of the appropriate Institute.
+<br /><br />
+6. All candidates admitted into the HND I programmes should submit the
+   photocopies of their original certificates of ND and SSCE with scratch
+   card online for clearance latest a week after the admission is offered.
+   Failure to comply with this directive may lead to the forfeiture of
+   the admission.
+<br /><br />
+<!-- image size: 229x100 pixels; ratio (2.29:1) must be kept -->
+<img src="${signature_img_path}" valign="-30"
+     height="75" width="172" />
+<br />
 M.O. Adebayo<br />
 Admission Officer<br />
@@ -359,23 +405,62 @@
 <strong>INSTRUCTIONS TO FRESHERS</strong>
 <br /><br />
-You are hereby offered a provisional admission for the 2014/2015 session subject to the conditions that:
-<br /><br />
-1. The information given in your Application Form is correct.<br /><br />
-2. The original of your Credentials are presented for scrutiny.<br /><br />
-3. If at any time the Credentials submitted are found to be false/fake or incorrect, your admission shall be withdrawn.<br /><br />
-4. The name by which you are admitted and registered shall remain same throughout the duration of your programme.<br /><br />
-5. You are to fill and submit the Undertaking Form at the point of registration failure which your admission will be forfeited.<br /><br />
-6. You will dress decently covering your nakedness at all times.<br /><br />
-7. Payment of school fees will be once and in full and should be by Interswitch to the designated Banks. Failure to pay fees by the mode mentioned above by the closing date means you have declined the offer and your place will be given to another eligible candidate immediately.<br /><br />
-8. You present a Certificate of medical fitness from the Polytechnic Clinic.<br /><br />
-9. All indigenes of Kwara State are required to present Certificate of Citizenship.<br /><br />
-10. The Polytechnic reserves the right to withdraw your admission at any stage, if you are found to be a cultist or an expelled individual from any tertiary institution.<br /><br />
-11. You are prepared to take up accommodation provided on the campuses by the authority.<br /><br />
-12. There will be no refund of school fees once paid.<br /><br />
-13. If you accept this offer with the above stated conditions, please make a photocopy of this document and return it to the Admission Office immediately.<br /><br />
-14. You possess the entry requirement for the programme you are admitted.<br /><br />
-
+You are hereby offered a provisional admission for the 2014/2015 session
+subject to the conditions that:
+<br /><br />
+1. The information given in your Application Form is correct.
+<br /><br />
+2. The original of your Credentials are presented for scrutiny.
+<br /><br />
+3. If at any time the Credentials submitted are found to be false/fake
+   or incorrect, your admission shall be withdrawn.
+<br /><br />
+4. The name by which you are admitted and registered shall remain same
+   throughout the duration of your programme.
+<br /><br />
+5. You are to fill and submit the Undertaking Form at the point of
+   registration failure which your admission will be forfeited.
+<br /><br />
+6. You will dress decently covering your nakedness at all times.
+<br /><br />
+7. Payment of school fees will be once and in full and should be by
+   Interswitch to the designated Banks. Failure to pay fees by the
+   mode mentioned above by the closing date means you have declined
+   the offer and your place will be given to another eligible
+   candidate immediately.
+<br /><br />
+8. You present a Certificate of medical fitness from the Polytechnic
+   Clinic.
+<br /><br />
+9. All indigenes of Kwara State are required to present Certificate of
+   Citizenship.
+<br /><br />
+10. The Polytechnic reserves the right to withdraw your admission at
+    any stage, if you are found to be a cultist or an expelled
+    individual from any tertiary institution.
+<br /><br />
+11. You are prepared to take up accommodation provided on the campuses
+    by the authority.
+<br /><br />
+12. There will be no refund of school fees once paid.
+<br /><br />
+13. If you accept this offer with the above stated conditions, please
+    make a photocopy of this document and return it to the Admission
+    Office immediately.
+<br /><br />
+14. You possess the entry requirement for the programme you are admitted.
+<br /><br />
+
+<!-- image size: 229x100 pixels; ratio (2.29:1) must be kept -->
+<img src="${signature_img_path}" valign="-30"
+     height="75" width="172" />
+<br />
 M.O. Adebayo<br />
 Admission Officer<br />
 For: Registrar
 """
+# XXX: a note for <img /> tag used here (from reportlab docs):
+#   The valign attribute may be set to a css like value from "baseline", "sub",
+#   "super", "top", "text-top", "middle", "bottom", "text-bottom";
+#   the value may also be a numeric percentage or an absolute value.
+#
+# Burn this remark after reading.
