/usr/share/pyshared/schooltool/schoolyear/interfaces.py is in python-schooltool 1:2.1.0-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | #
# SchoolTool - common information systems platform for school administration
# Copyright (c) 2008 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
#
"""
School year implementation
"""
from zope.interface import Interface
from zope.schema import Date, TextLine
from zope.location.interfaces import ILocation
from zope.container.interfaces import IWriteContainer
from zope.container.interfaces import IReadContainer
from zope.container.interfaces import IContainer
from zope.container import constraints
from schooltool.term.interfaces import ITermContainer
from schooltool.common import SchoolToolMessage as _
class IWriteSchoolYear(IWriteContainer):
"""An interface for the write aspects of a container."""
class IReadSchoolYear(IReadContainer, ILocation):
title = TextLine(
title=_("Title"))
first = Date(
title=_(u"The first day of the period of time covered."))
last = Date(
title=_(u"The last day of the period covered."))
class ISchoolYear(IWriteSchoolYear, IReadSchoolYear, ITermContainer):
"""School year"""
class ISchoolYearContainer(IContainer, ILocation):
"""Container for school years"""
constraints.contains(ISchoolYear)
def validateForOverlap(schoolyear):
"""Validate school year for overlap with other school years."""
def getActiveSchoolYear():
"""Return the active schoolyear."""
class ISubscriber(Interface):
"""An event handler implements this"""
def __call__():
"""Perform the action."""
class TermOverlapError(Exception):
def __init__(self, term, overlapping_terms):
self.term = term
self.overlapping_terms = overlapping_terms
def __repr__(self):
return "Date range you have selected overlaps with term(s) (%s)" % (
", ".join(sorted(term.title
for term in self.overlapping_terms)))
__str__ = __repr__
class TermOverflowError(Exception):
def __init__(self, schoolyear, overflowing_terms):
self.schoolyear = schoolyear
self.overflowing_terms = overflowing_terms
def __repr__(self):
return "Date range you are trying to set is too small to contain following term(s) (%s)" % (
", ".join(sorted(term.title
for term in self.overflowing_terms)))
__str__ = __repr__
class SchoolYearOverlapError(Exception):
def __init__(self, schoolyear, overlapping_schoolyears):
self.schoolyear = schoolyear
self.overlapping_schoolyears = overlapping_schoolyears
def __repr__(self):
if self.schoolyear is not None:
title = "SchoolYear '%s'" % self.schoolyear.title
else:
title = "DateRange"
return "%s overlaps with SchoolYear(s) (%s)" % (
title,
", ".join(sorted(schoolyear.title
for schoolyear in self.overlapping_schoolyears)))
__str__ = __repr__
|