#
# SchoolTool - common information systems platform for school administration
# Copyright (c) 2005 Shuttleworth Foundation
#
# 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.container.interfaces import IContainer, IContained
from zope.container.constraints import contains, containers
from zope.interface import Interface, implements, Attribute
from zope.schema.interfaces import IList, IBool
from zope.schema import TextLine, Text, Bool, List, Date, Datetime

from schooltool.intervention import InterventionGettext as _


class IInterventionMarker(Interface):
    """A marker interface for all intervention classes."""


class IPersonListField(IList):
    """A field that represents a list of people."""


class PersonListField(List):
    """A field that represents a list of people."""

    implements(IPersonListField)


class IGoalMetField(IBool):
    """A field that represents the goal met boolean."""


class GoalMetField(Bool):
    """A field that represents the goal met boolean."""

    implements(IGoalMetField)


class IInterventionRoot(IContainer):
    """Container of IInterventionSchoolYear objects."""

    contains('schooltool.intervention.interfaces.IInterventionSchoolYear')


class IInterventionSchoolYear(IContainer):
    """Container of the IInteventionStudent objects."""

    contains('schooltool.intervention.interfaces.IInterventionStudent')
    containers(IInterventionRoot)


class IInterventionStudent(IContainer):
    """Container of the student's intervention containers."""

    student = Attribute("Student under intervention")

    contains('zope.app.IContainer')
    containers(IInterventionSchoolYear)


class IInterventionMessages(IContainer):
    """Container of intervention messages."""

    student = Attribute("Student under intervention")

    contains('schooltool.intervention.interfaces.IInterventionMessage')
    containers(IInterventionStudent)


class IInterventionMessage(IContained):
    """Intervention message about a given student."""

    student = Attribute("Student under intervention")

    sender = TextLine(
        title=u"Sender's person id"
        )

    recipients = PersonListField(
        title=_("Recipients"),
        value_type=TextLine(title=u"Recipient's person id"),
        )

    body = Text(
        title=_("Message body")
        )

    status_change = Bool(
        title=u"Status Change Message",
        required=False
        )

    created = Datetime(
        title=u"Creation Date/Time",
        )

    containers(IInterventionMessages)


class IInterventionGoals(IContainer):
    """Container of the studnet's interventions goals."""

    student = Attribute("Student under intervention")

    contains('schooltool.intervention.interfaces.IInterventionGoal')
    containers(IInterventionStudent)


class IInterventionGoal(IContained):
    """intervention goal for a given student."""

    student = Attribute("Student under intervention")

    presenting_concerns = Text(
        title=_("Presenting concerns"),
        )

    goal = Text(
        title=_("Goal"),
        )

    strengths = Text(
        title=_("Strengths"),
        )

    indicators = Text(
        title=_("Indicators"),
        )

    intervention = Text(
        title=_("Intervention"),
        )

    timeline = Date(
        title=_("Timeline"),
        )

    persons_responsible = PersonListField(
        title=_("Persons responsible"),
        value_type=TextLine(title=u"Responsible person's person id"),
        )

    goal_met = GoalMetField(
        title=u"Goal met",
        required=False
        )

    follow_up_notes = Text(
        title=_("Follow-up notes"),
        required=False
        )

    notified = Bool(
        title=u"Notification sent to persons responsible"
        )

    creator = TextLine(
        title=u"Creator's person id"
        )

    created = Datetime(
        title=u"Creation Date/Time",
        )

    containers(IInterventionGoals)

