Index: /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/applicants/applicant.py
===================================================================
--- /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/applicants/applicant.py	(revision 10131)
+++ /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/applicants/applicant.py	(revision 10132)
@@ -31,4 +31,12 @@
     grok.provides(ICustomApplicant)
 
+    @property
+    def is_nd(self):
+        if self.applicant_id.startswith('nd') \
+            or self.applicant_id.startswith('prend'):
+            return True
+        return False
+
+
 # Set all attributes of CustomApplicant required in ICustomApplicant as field
 # properties. Doing this, we do not have to set initial attributes
Index: /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/applicants/browser.py
===================================================================
--- /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/applicants/browser.py	(revision 10132)
+++ /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/applicants/browser.py	(revision 10132)
@@ -0,0 +1,126 @@
+## $Id$
+##
+## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+"""UI components for basic applicants and related components.
+"""
+import grok
+from zope.component import getUtility
+from zope.i18n import translate
+from waeup.kofa.widgets.datewidget import FriendlyDatetimeDisplayWidget
+from zope.formlib.textwidgets import BytesDisplayWidget
+from waeup.kofa.applicants.browser import (ApplicantDisplayFormPage,
+    ApplicantManageFormPage, ApplicantEditFormPage)
+from waeup.kofa.applicants.viewlets import (
+    PaymentReceiptActionButton, PDFActionButton)
+from waeup.kofa.applicants.pdf import PDFApplicationSlip
+from kofacustom.nigeria.applicants.interfaces import (
+    UG_OMIT_DISPLAY_FIELDS,
+    UG_OMIT_PDF_FIELDS,
+    UG_OMIT_MANAGE_FIELDS,
+    UG_OMIT_EDIT_FIELDS
+    )
+from waeup.kwarapoly.applicants.interfaces import (
+    ICustomUGApplicant, ICustomUGApplicantEdit,
+    ND_OMIT_DISPLAY_FIELDS,
+    ND_OMIT_PDF_FIELDS,
+    ND_OMIT_MANAGE_FIELDS,
+    ND_OMIT_EDIT_FIELDS
+    )
+
+class CustomApplicantDisplayFormPage(ApplicantDisplayFormPage):
+    """A display view for applicant data.
+    """
+
+    @property
+    def form_fields(self):
+        form_fields = grok.AutoFields(ICustomUGApplicant)
+        if self.context.is_nd:
+            for field in ND_OMIT_DISPLAY_FIELDS:
+                form_fields = form_fields.omit(field)
+        else:
+            form_fields = grok.AutoFields(ICustomUGApplicant)
+            for field in UG_OMIT_DISPLAY_FIELDS:
+                form_fields = form_fields.omit(field)
+        form_fields['notice'].custom_widget = BytesDisplayWidget
+        if not getattr(self.context, 'student_id'):
+            form_fields = form_fields.omit('student_id')
+        if not getattr(self.context, 'screening_score'):
+            form_fields = form_fields.omit('screening_score')
+        if not getattr(self.context, 'screening_venue'):
+            form_fields = form_fields.omit('screening_venue')
+        if not getattr(self.context, 'screening_date'):
+            form_fields = form_fields.omit('screening_date')
+        return form_fields
+
+class CustomPDFApplicationSlip(PDFApplicationSlip):
+
+    def _reduced_slip(self):
+        return getattr(self.context, 'result_uploaded', False)
+
+    @property
+    def form_fields(self):
+        form_fields = grok.AutoFields(ICustomUGApplicant)
+        if self.context.is_nd:
+            for field in ND_OMIT_PDF_FIELDS:
+                form_fields = form_fields.omit(field)
+        else:
+            form_fields = grok.AutoFields(ICustomUGApplicant)
+            for field in UG_OMIT_PDF_FIELDS:
+                form_fields = form_fields.omit(field)
+        if not getattr(self.context, 'student_id'):
+            form_fields = form_fields.omit('student_id')
+        if not getattr(self.context, 'screening_score'):
+            form_fields = form_fields.omit('screening_score')
+        if not getattr(self.context, 'screening_venue'):
+            form_fields = form_fields.omit('screening_venue')
+        if not getattr(self.context, 'screening_date'):
+            form_fields = form_fields.omit('screening_date')
+        return form_fields
+
+class CustomApplicantManageFormPage(ApplicantManageFormPage):
+    """A full edit view for applicant data.
+    """
+    
+    @property
+    def form_fields(self):
+        form_fields = grok.AutoFields(ICustomUGApplicant)
+        if self.context.is_nd:
+            for field in ND_OMIT_MANAGE_FIELDS:
+                form_fields = form_fields.omit(field)
+        else:
+            for field in UG_OMIT_MANAGE_FIELDS:
+                form_fields = form_fields.omit(field)
+        form_fields['student_id'].for_display = True
+        form_fields['applicant_id'].for_display = True
+        return form_fields
+
+class CustomApplicantEditFormPage(ApplicantEditFormPage):
+    """An applicant-centered edit view for applicant data.
+    """
+
+    @property
+    def form_fields(self):
+        form_fields = grok.AutoFields(ICustomUGApplicantEdit)
+        if self.context.is_nd:
+            for field in ND_OMIT_EDIT_FIELDS:
+                form_fields = form_fields.omit(field)
+        else:
+            for field in UG_OMIT_EDIT_FIELDS:
+                form_fields = form_fields.omit(field)
+        form_fields['applicant_id'].for_display = True
+        form_fields['reg_number'].for_display = True
+        return form_fields
Index: /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/applicants/interfaces.py
===================================================================
--- /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/applicants/interfaces.py	(revision 10131)
+++ /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/applicants/interfaces.py	(revision 10132)
@@ -31,4 +31,5 @@
 from kofacustom.nigeria.applicants.interfaces import (
     LGASource, high_qual, high_grade, exam_types,
+    OMIT_DISPLAY_FIELDS,
     INigeriaUGApplicant, INigeriaPGApplicant,
     INigeriaApplicantOnlinePayment,
@@ -40,5 +41,24 @@
 from waeup.kwarapoly.payments.interfaces import ICustomOnlinePayment
 
-class ICustomUGApplicant(INigeriaUGApplicant):
+ND_OMIT_DISPLAY_FIELDS = OMIT_DISPLAY_FIELDS + (
+    'hq_type',
+    'hq_matric_no',
+    'hq_degree',
+    'hq_school',
+    'hq_session',
+    'hq_disc',
+    'hq_type')
+ND_OMIT_PDF_FIELDS = ND_OMIT_DISPLAY_FIELDS + ('phone',)
+ND_OMIT_MANAGE_FIELDS = ()
+ND_OMIT_EDIT_FIELDS = ND_OMIT_MANAGE_FIELDS + ND_OMIT_DISPLAY_FIELDS + (
+    'student_id', 'notice',
+    'screening_score',
+    'screening_venue',
+    'screening_date',
+    'jamb_subjects',
+    'jamb_score',
+    'aggregate')
+
+class ICustomUGApplicant(IApplicantBaseData):
     """An undergraduate applicant.
 
@@ -47,4 +67,141 @@
     adding them to the UG_OMIT* tuples.
     """
+
+    nationality = schema.Choice(
+        source = nats_vocab,
+        title = _(u'Nationality'),
+        required = True,
+        )
+    lga = schema.Choice(
+        source = LGASource(),
+        title = _(u'State/LGA (Nigerians only)'),
+        required = False,
+        )
+    #perm_address = schema.Text(
+    #    title = _(u'Permanent Address'),
+    #    required = False,
+    #    )
+    next_kin_address = schema.Text(
+        title = _(u'Next of Kin Address'),
+        required = False,
+        )
+    course1 = schema.Choice(
+        title = _(u'1st Choice Course of Study'),
+        source = AppCatCertificateSource(),
+        required = True,
+        )
+    course2 = schema.Choice(
+        title = _(u'2nd Choice Course of Study'),
+        source = AppCatCertificateSource(),
+        required = False,
+        )
+    olevel_type = schema.Choice(
+        title = _(u'Qualification Obtained'),
+        required = False,
+        readonly = False,
+        vocabulary = exam_types,
+        )
+    olevel_school = schema.TextLine(
+        title = _(u'Institution Attended'),
+        required = False,
+        readonly = False,
+        )
+    olevel_exam_number = schema.TextLine(
+        title = _(u'Exam Number'),
+        required = False,
+        readonly = False,
+        )
+    olevel_exam_date = FormattedDate(
+        title = _(u'Exam Date'),
+        required = False,
+        readonly = False,
+        show_year = True,
+        )
+    olevel_results = schema.List(
+        title = _(u'Exam Results'),
+        value_type = ResultEntryField(),
+        required = False,
+        readonly = False,
+        default = [],
+        )
+    hq_type = schema.Choice(
+        title = _(u'Qualification Obtained'),
+        required = False,
+        readonly = False,
+        vocabulary = high_qual,
+        )
+    hq_matric_no = schema.TextLine(
+        title = _(u'Former Matric Number'),
+        required = False,
+        readonly = False,
+        )
+    hq_degree = schema.Choice(
+        title = _(u'Class of Degree'),
+        required = False,
+        readonly = False,
+        vocabulary = high_grade,
+        )
+    hq_school = schema.TextLine(
+        title = _(u'Institution Attended'),
+        required = False,
+        readonly = False,
+        )
+    hq_session = schema.TextLine(
+        title = _(u'Years Attended'),
+        required = False,
+        readonly = False,
+        )
+    hq_disc = schema.TextLine(
+        title = _(u'Discipline'),
+        required = False,
+        readonly = False,
+        )
+    jamb_subjects = schema.Text(
+        title = _(u'Subjects and Scores'),
+        required = False,
+        )
+    jamb_score = schema.Int(
+        title = _(u'Total JAMB Score'),
+        required = False,
+        )
+    notice = schema.Text(
+        title = _(u'Notice'),
+        required = False,
+        )
+    screening_venue = schema.TextLine(
+        title = _(u'Screening Venue'),
+        required = False,
+        )
+    screening_date = schema.TextLine(
+        title = _(u'Screening Date'),
+        required = False,
+        )
+    screening_score = schema.Int(
+        title = _(u'Screening Score (%)'),
+        required = False,
+        )
+    aggregate = schema.Int(
+        title = _(u'Aggregate Score (%)'),
+        description = _(u'(average of relative JAMB and PUTME scores)'),
+        required = False,
+        )
+    result_uploaded = schema.Bool(
+        title = _(u'Result uploaded'),
+        default = False,
+        )
+    student_id = schema.TextLine(
+        title = _(u'Student Id'),
+        required = False,
+        readonly = False,
+        )
+    course_admitted = schema.Choice(
+        title = _(u'Admitted Course of Study'),
+        source = CertificateSource(),
+        required = False,
+        )
+    locked = schema.Bool(
+        title = _(u'Form locked'),
+        default = False,
+        )
 
 class ICustomPGApplicant(INigeriaPGApplicant):
@@ -75,5 +232,5 @@
         """
 
-class ICustomUGApplicantEdit(INigeriaUGApplicantEdit):
+class ICustomUGApplicantEdit(ICustomUGApplicant):
     """An undergraduate applicant interface for edit forms.
 
@@ -104,21 +261,2 @@
     """
 
-class IPUTMEApplicantEdit(IPUTMEApplicantEdit):
-    """An undergraduate applicant interface for editing.
-
-    Here we can repeat the fields from base data and set the
-    `required` and `readonly` attributes to True to further restrict
-    the data access. Or we can allow only certain certificates to be
-    selected by choosing the appropriate source.
-
-    We cannot omit fields here. This has to be done in the
-    respective form page.
-    """
-
-class ICustomApplicantUpdateByRegNo(INigeriaApplicantUpdateByRegNo):
-    """Representation of an applicant.
-
-    Skip regular reg_number validation if reg_number is used for finding
-    the applicant object.
-    """
-
Index: /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/applicants/tests/test_browser.py
===================================================================
--- /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/applicants/tests/test_browser.py	(revision 10132)
+++ /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/applicants/tests/test_browser.py	(revision 10132)
@@ -0,0 +1,137 @@
+## $Id$
+##
+## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+## GNU General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+import shutil
+import tempfile
+import datetime
+import pytz
+from zope.component.hooks import setSite, clearSite
+from zope.component import createObject
+from zope.testbrowser.testing import Browser
+from waeup.kofa.app import University
+from waeup.kofa.university.faculty import Faculty
+from waeup.kofa.university.department import Department
+from waeup.kofa.testing import FunctionalTestCase
+from waeup.kofa.applicants.container import ApplicantsContainer
+from waeup.kwarapoly.testing import FunctionalLayer
+
+
+class ApplicantUITest(FunctionalTestCase):
+    """Perform some browser tests.
+    """
+    layer = FunctionalLayer
+
+    def setUp(self):
+        super(ApplicantUITest, self).setUp()
+        # Setup a sample site for each test
+        app = University()
+        self.dc_root = tempfile.mkdtemp()
+        app['datacenter'].setStoragePath(self.dc_root)
+
+        # Prepopulate the ZODB...
+        self.getRootFolder()['app'] = app
+        # we add the site immediately after creation to the
+        # ZODB. Catalogs and other local utilities are not setup
+        # before that step.
+        self.app = self.getRootFolder()['app']
+        # Set site here. Some of the following setup code might need
+        # to access grok.getSite() and should get our new app then
+        setSite(app)
+
+        # Add nd applicants container
+        self.ndcontainer = ApplicantsContainer()
+        self.ndcontainer.mode = 'create'
+        self.ndcontainer.code = u'nd2011'
+        self.ndcontainer.prefix = u'nd'
+        self.ndcontainer.application_category = u'nd'
+        self.ndcontainer.year = 2011
+        self.ndcontainer.application_fee = 300.0
+        self.ndcontainer.title = u'This is the nd2011 container'
+        self.app['applicants']['nd2011'] = self.ndcontainer
+
+        delta = datetime.timedelta(days=10)
+        self.ndcontainer.startdate = datetime.datetime.now(pytz.utc) - delta
+        self.ndcontainer.enddate = datetime.datetime.now(pytz.utc) + delta
+
+        # Populate university
+        self.certificate = createObject('waeup.Certificate')
+        self.certificate.code = 'CERT1'
+        self.certificate.application_category = 'nd'
+        self.certificate.start_level = 100
+        self.certificate.end_level = 500
+        self.certificate.study_mode = u'nce_ft'
+        self.app['faculties']['fac1'] = Faculty()
+        self.app['faculties']['fac1']['dep1'] = Department()
+        self.app['faculties']['fac1']['dep1'].certificates.addCertificate(
+            self.certificate)
+
+        # Add (customized) applicants
+        ndapplicant = createObject(u'waeup.Applicant')
+        ndapplicant.firstname = u'Anna'
+        ndapplicant.lastname = u'Post'
+        self.app['applicants']['nd2011'].addApplicant(ndapplicant)
+        self.ndapplication_number = ndapplicant.application_number
+        self.ndapplicant = self.app['applicants']['nd2011'][
+            self.ndapplication_number]
+        self.ndapplicant_path = ('http://localhost/app/applicants/nd2011/%s'
+            % self.ndapplication_number)
+
+        self.browser = Browser()
+        self.browser.handleErrors = False
+
+    def tearDown(self):
+        super(ApplicantUITest, self).tearDown()
+        shutil.rmtree(self.dc_root)
+        clearSite()
+        return
+
+    def fill_correct_values(self):
+        self.browser.getControl(name="form.reg_number").value = '1234'
+        self.browser.getControl(name="form.firstname").value = 'John'
+        self.browser.getControl(name="form.lastname").value = 'Tester'
+        self.browser.getControl(name="form.date_of_birth").value = '09/09/1988'
+        self.browser.getControl(name="form.lga").value = ['foreigner']
+        self.browser.getControl(name="form.nationality").value = ['NG']
+        self.browser.getControl(name="form.sex").value = ['m']
+        self.browser.getControl(name="form.email").value = 'xx@yy.zz'
+
+    def test_manage_and_view_applicant(self):
+        # Managers can manage nd applicants.
+        self.browser.addHeader('Authorization', 'Basic mgr:mgrpw')
+        self.browser.open(self.ndapplicant_path)
+        self.assertEqual(self.browser.headers['Status'], '200 Ok')
+        self.assertTrue("'O' Level" in self.browser.contents)
+        self.assertFalse("Higher" in self.browser.contents)
+        self.browser.open(self.ndapplicant_path + '/manage')
+        self.assertEqual(self.browser.headers['Status'], '200 Ok')
+        self.assertTrue("'O' Level" in self.browser.contents)
+        self.assertTrue("Higher" in self.browser.contents)
+        self.browser.open(self.ndapplicant_path + '/edit')
+        self.assertEqual(self.browser.headers['Status'], '200 Ok')
+        self.assertTrue("'O' Level" in self.browser.contents)
+        self.assertFalse("Higher" in self.browser.contents)
+        self.browser.open(self.ndapplicant_path + '/application_slip.pdf')
+        self.assertEqual(self.browser.headers['Status'], '200 Ok')
+        # Now we turn the nd applicant into an hnd applicant.
+        self.ndapplicant.applicant_id = u'hnd_anything'
+        self.browser.open(self.ndapplicant_path)
+        self.assertTrue("Higher" in self.browser.contents)
+        self.assertTrue("'O' Level" in self.browser.contents)
+        self.browser.open(self.ndapplicant_path + '/edit')
+        self.assertTrue("Higher" in self.browser.contents)
+        self.assertTrue("'O' Level" in self.browser.contents)
+        return
Index: /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/applicants/utils.py
===================================================================
--- /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/applicants/utils.py	(revision 10131)
+++ /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/applicants/utils.py	(revision 10132)
@@ -23,4 +23,5 @@
 import grok
 from kofacustom.nigeria.applicants.utils import NigeriaApplicantsUtils
+from waeup.kwarapoly.interfaces import MessageFactory as _
 
 
@@ -41,2 +42,13 @@
         'pgpt': ['Postgraduate Part-Time Programmes', 'PG']
         }
+
+    SEPARATORS_DICT = {
+        'form.applicant_id': _(u'Base Data'),
+        'form.course1': _(u'Programmes/Courses Desired'),
+        'form.hq_type': _(u'Higher Education Record'),
+        'form.jamb_subjects': _(u'JAMB Data'),
+        'form.notice': _(u'Application Process Information'),
+        'form.pp_school': _(u'Post Primary School Qualification'),
+        'form.presently_inst': _(u'Presently attending a course or programme'),
+        'form.olevel_type': _(u"'O' Level Record"),
+        }
Index: /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/interswitch/browser.py
===================================================================
--- /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/interswitch/browser.py	(revision 10131)
+++ /main/waeup.kwarapoly/trunk/src/waeup/kwarapoly/interswitch/browser.py	(revision 10132)
@@ -226,6 +226,5 @@
             xmldict['institution_acct'] = '7000016463'
             xmldict['institution_bank_id'] = '9'
-        elif self.applicant.applicant_id.startswith('nd') \
-            or self.applicant.applicant_id.startswith('prend'):
+        elif self.applicant.is_nd:
             xmldict['institution_acct'] = '2014191363'
             xmldict['institution_bank_id'] = '8'
