## $Id: interfaces.py 7601 2012-02-08 07:05:16Z henrik $
##
## 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
##
"""Interfaces of academics specific objects.
"""
from zope import schema
from zope.interface import Attribute
from waeup.sirp.interfaces import (ISIRPObject, ISIRPContainer)

from waeup.sirp.university.vocabularies import (
    course_levels,
    semester,
    application_categories,
    study_modes,
    inst_types,
    CourseSource,
    )


class IFaculty(ISIRPContainer):
    """Representation of a university faculty.
    """
    code = schema.TextLine(
        title = u'Code',
        default = u'NA',
        required = True,
        readonly = True,
        )

    title = schema.TextLine(
        title = u'Name of faculty',
        default = u'Unnamed',
        required = True,
        )

    title_prefix = schema.Choice(
        title = u'Name prefix',
        default = u'faculty',
        vocabulary = inst_types,
        required = True,
        )

    def longtitle():
        """
        Returns the long title of a faculty.
        """

class IFacultyAdd(IFaculty):
    """Representation of a university faculty.
    """
    code = schema.TextLine(
        title = u'Code',
        description = u'This code will become part of the URL.',
        default = u'NA',
        required = True,
        readonly = False,
        )

IFacultyAdd['code'].order =  IFaculty['code'].order

class IFacultiesContainer(ISIRPContainer):
    """A container for faculties.
    """
    def addFaculty(faculty):
        """Add an IFactulty object.

        """
class IDepartment(ISIRPObject):
    """Representation of a department.
    """
    code = schema.TextLine(
        title = u'Code',
        default = u'NA',
        required = True,
        readonly = True,
        )

    title = schema.TextLine(
        title = u'Name of department',
        default = u'Unnamed',
        required = True,
        )

    title_prefix = schema.Choice(
        title = u'Name prefix',
        vocabulary = inst_types,
        default = u'department',
        required = True,
        )

    courses = Attribute("A container for courses.")
    certificates = Attribute("A container for certificates.")

    def longtitle():
        """
        Returns the long title of a department.
        """

class IDepartmentAdd(IDepartment):
    """Representation of a university department.
    """
    code = schema.TextLine(
        title = u'Code',
        description = u'This code will become part of the URL.',
        default = u'NA',
        required = True,
        readonly = False,
        )

IDepartmentAdd['code'].order =  IDepartment['code'].order

class ICoursesContainer(ISIRPContainer):
    """A container for faculties.
    """
    def addCourse(course):
        """Add an ICourse object.

        Returns the key, under which the object was stored.
        """

class ICourse(ISIRPObject):
    """Representation of a course.
    """
    code = schema.TextLine(
        title = u'Code',
        default = u'NA',
        required = True,
        readonly = True,
        )

    title = schema.TextLine(
        title = u'Title of course',
        default = u'Unnamed',
        required = True,
        )

    credits = schema.Int(
        title = u'Credits',
        default = 0,
        required = False,
        )

    passmark = schema.Int(
        title = u'Passmark',
        default = 40,
        required = False,
        )

    semester = schema.Choice(
        title = u'Semester/Term',
        default = 9,
        vocabulary = semester,
        required = True,
        )

    def longtitle():
        """
        Returns the long title of a course.
        """

class ICourseAdd(ICourse):
    """Representation of a course.
    """
    code = schema.TextLine(
        title = u'Code',
        description = u'Enter unique course code which will become part of the URL.',
        default = u'NA',
        required = True,
        readonly = False,
        )

ICourseAdd['code'].order =  ICourse['code'].order

class ICertificate(ISIRPObject):
    """Representation of a certificate.
    """
    code = schema.TextLine(
        title = u'Code',
        default = u'NA',
        required = True,
        readonly = True,
        )

    title = schema.TextLine(
        title = u'Title',
        default = u'Unnamed',
        required = True,
        )

    study_mode = schema.Choice(
        title = u'Study Mode',
        vocabulary = study_modes,
        default = u'ug_ft',
        required = True,
        )

    start_level = schema.Choice(
        title = u'Start Level',
        vocabulary = course_levels,
        default = 100,
        required = True,
        )

    end_level = schema.Choice(
        title = u'End Level',
        vocabulary = course_levels,
        default = 500,
        required = True,
        )

    application_category = schema.Choice(
        title = u'Application Category',
        vocabulary = application_categories,
        default = u'basic',
        required = True,
        )

    def longtitle():
        """
        Returns the long title of a certificate.
        """

class ICertificateAdd(ICertificate):
    """Representation of a certificate.
    """
    code = schema.TextLine(
        title = u'Code',
        default = u'NA',
        description = u'Enter unique certificate code which will become part of the URL.',
        required = True,
        readonly = False,
        )

ICertificateAdd['code'].order =  ICertificate['code'].order

class ICertificatesContainer(ISIRPContainer):
    """A container for certificates.
    """
    def addCertificate(certificate):
        """Add an ICertificate object.

        Returns the key, under which the object was stored.
        """

class ICertificateCourse(ISIRPObject):
    """A certificatecourse is referring a course and provides some own
       attributes.
    """
    course = schema.Choice(
        title = u'Course referrer',
        source = CourseSource(),
        readonly = True,
        )

    level = schema.Choice(
        title = u'Level',
        required = True,
        vocabulary = course_levels,
        readonly = False,
        )

    core_or_elective = schema.Bool(
        title = u'Is mandatory course (not elective)',
        required = True,
        default = True,
        )

    def getCourseCode():
        """Return the code of the course referred to.

        This is needed for cataloging.
        """

    def longtitle():
        """
        Returns the long title of a certificatecourse.
        """


class ICertificateCourseAdd(ICertificateCourse):
    """A certificatecourse is referring a course and
       provides some own attributes.
    """
    course = schema.Choice(
        title = u'Course',
        source = CourseSource(),
        readonly = False,
        )

ICertificateCourseAdd['course'].order =  ICertificateCourse['course'].order
