## $Id: interfaces.py 8504 2012-05-23 21:27:57Z henrik $
##
## Copyright (C) 2012 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
##
from zope import schema
from waeup.kofa.schema import TextLineChoice
from waeup.kofa.interfaces import SimpleKofaVocabulary, academic_sessions_vocab
from waeup.kofa.schema import FormattedDate
from waeup.kofa.schoolgrades import ResultEntryField
from waeup.kofa.students.vocabularies import nats_vocab
from waeup.kofa.students.interfaces import (
    IStudentBase, IUGStudentClearance, IPGStudentClearance,
    IStudentPersonal, IStudentNavigation, IStudentStudyLevel,
    IStudentStudyCourse, ICourseTicket
    )
from waeup.kofa.students.vocabularies import (
    nats_vocab, contextual_reg_num_source)
from waeup.fceokene.interfaces import (
    high_qual, high_grade, exam_types, LGASource)
from waeup.fceokene.interfaces import MessageFactory as _
from waeup.fceokene.payments.interfaces import ICustomOnlinePayment
from waeup.fceokene.utils.lgas import LGAS


class ICustomStudentBase(IStudentBase):
    """Representation of student base data.

    """

    reg_number = TextLineChoice(
        title = _(u'Registration Number'),
        required = False,
        readonly = False,
        source = contextual_reg_num_source,
        )

class ICustomStudentPersonal(IStudentPersonal):
    """Student personal data.

    """

    marit_stat = schema.Choice(
        title = u'Maritual Status',
        default = 'unmarried',
        required = False,
        vocabulary = SimpleKofaVocabulary(
            (_('Unmarried'), 'unmarried'),
            (_('Married'), 'married'),)
        )

class ICustomUGStudentClearance(IUGStudentClearance):
    """Representation of ug student clearance data.

    """
    date_of_birth = FormattedDate(
        title = _(u'Date of Birth'),
        required = False,
        show_year = True,
        )

    nationality = schema.Choice(
        source = nats_vocab,
        title = _(u'Nationality'),
        required = False,
        )

    lga = schema.Choice(
        source = LGASource(),
        title = _(u'State/LGA (Nigerians only)'),
        required = False,
        )

    def_adm = schema.Bool(
        title = _(u'Deferent of Admission'),
        required = False,
        readonly = False,
        )

    fst_sit_fname = schema.TextLine(
        title = _(u'Full Name'),
        required = False,
        readonly = False,
        )
    fst_sit_no = schema.TextLine(
        title = _(u'Exam Number'),
        required = False,
        readonly = False,
        )

    fst_sit_date = FormattedDate(
        title = _(u'Exam Date'),
        required = False,
        readonly = False,
        show_year = True,
        )

    fst_sit_type = schema.Choice(
        title = _(u'Exam Type'),
        required = False,
        readonly = False,
        vocabulary = exam_types,
        )

    fst_sit_results = schema.List(
        title = _(u'Exam Results'),
        value_type = ResultEntryField(),
        required = False,
        readonly = False,
        default = [],
        )

    scd_sit_fname = schema.TextLine(
        title = _(u'Full Name'),
        required = False,
        readonly = False,
        )
    scd_sit_no = schema.TextLine(
        title = _(u'Exam Number'),
        required = False,
        readonly = False,
        )

    scd_sit_date = FormattedDate(
        title = _(u'Exam Date'),
        required = False,
        readonly = False,
        show_year = True,
        )

    scd_sit_type = schema.Choice(
        title = _(u'Exam Type'),
        required = False,
        readonly = False,
        vocabulary = exam_types,
        )

    scd_sit_results = schema.List(
        title = _(u'Exam Results'),
        value_type = ResultEntryField(),
        required = False,
        readonly = False,
        default = [],
        )

    alr_fname = schema.TextLine(
        title = _(u'Full Name'),
        required = False,
        readonly = False,
        )
    alr_no = schema.TextLine(
        title = _(u'Exam Number'),
        required = False,
        readonly = False,
        )

    alr_date = FormattedDate(
        title = _(u'Exam Date'),
        required = False,
        readonly = False,
        show_year = True,
        )

    alr_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,
        )


class ICustomPGStudentClearance(ICustomUGStudentClearance):
    """Representation of pg student clearance data.

    """

    hq2_type = schema.Choice(
        title = _(u'Qualification Obtained'),
        required = False,
        readonly = False,
        vocabulary = high_qual,
        )

    hq2_matric_no = schema.TextLine(
        title = _(u'Former Matric Number'),
        required = False,
        readonly = False,
        )

    hq2_degree = schema.Choice(
        title = _(u'Class of Degree'),
        required = False,
        readonly = False,
        vocabulary = high_grade,
        )

    hq2_school = schema.TextLine(
        title = _(u'Institution Attended'),
        required = False,
        readonly = False,
        )

    hq2_session = schema.TextLine(
        title = _(u'Years Attended'),
        required = False,
        readonly = False,
        )

    hq2_disc = schema.TextLine(
        title = _(u'Discipline'),
        required = False,
        readonly = False,
        )

    nysc_year = schema.Int(
        title = _(u'Nysc Year'),
        required = False,
        readonly = False,
        )

    nysc_lga = schema.Choice(
        source = LGASource(),
        title = _(u'Nysc Location'),
        required = False,
        )

    employer = schema.TextLine(
        title = _(u'Employer'),
        required = False,
        readonly = False,
        )

    emp_position = schema.TextLine(
        title = _(u'Employer Position'),
        required = False,
        readonly = False,
        )

    emp_start = FormattedDate(
        title = _(u'Start Date'),
        required = False,
        readonly = False,
        show_year = True,
        )

    emp_end = FormattedDate(
        title = _(u'End Date'),
        required = False,
        readonly = False,
        show_year = True,
        )

    emp_reason = schema.TextLine(
        title = _(u'Reason for Leaving'),
        required = False,
        readonly = False,
        )

    employer2 = schema.TextLine(
        title = _(u'2nd Employer'),
        required = False,
        readonly = False,
        )

    emp2_position = schema.TextLine(
        title = _(u'2nd Employer Position'),
        required = False,
        readonly = False,
        )

    emp2_start = FormattedDate(
        title = _(u'Start Date'),
        required = False,
        readonly = False,
        show_year = True,
        )
    emp2_end = FormattedDate(
        title = _(u'End Date'),
        required = False,
        readonly = False,
        show_year = True,
        )

    emp2_reason = schema.TextLine(
        title = _(u'Reason for Leaving'),
        required = False,
        readonly = False,
        )

    former_matric = schema.TextLine(
        title = _(u'If yes, matric number'),
        required = False,
        readonly = False,
        )


class ICustomStudent(ICustomStudentBase,ICustomUGStudentClearance,
    ICustomPGStudentClearance,ICustomStudentPersonal):
    """Representation of a student.

    """

class ICustomStudentStudyCourse(IStudentStudyCourse):
    """A container for student study levels.

    """

class ICustomStudentStudyLevel(IStudentStudyLevel):
    """A container for course tickets.

    """

class ICustomStudentOnlinePayment(ICustomOnlinePayment):
    """A student payment via payment gateways.

    This Interface does not inherit from IStudentOnlinePayment.
    Thus all fields from IStudentOnlinePayment have to be repeated here.
    """

    p_level = schema.Int(
        title = _(u'Payment Level'),
        required = False,
        readonly = True,
        )

ICustomStudentOnlinePayment['p_level'].order = ICustomStudentOnlinePayment[
    'p_session'].order

class ICustomCourseTicket(ICourseTicket):
    """A course ticket.

    """