/usr/lib/python2.7/dist-packages/schooltool/intervention/intervention.py is in python-schooltool.intervention 2.7.1-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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | #
# 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, see <http://www.gnu.org/licenses/>.
#
import pytz
from persistent import Persistent
from datetime import datetime
from zope.annotation.interfaces import IAttributeAnnotatable
from zope.container.contained import Contained
from zope.container.btree import BTreeContainer
from zope.interface import implements
from zope.publisher.interfaces import IRequest
from zope.publisher.browser import TestRequest
from zope.security import management
from zope.security.proxy import removeSecurityProxy
from schooltool.contact.interfaces import IContact
from schooltool.relationship import RelationshipProperty
from schooltool.relationship.uri import URIObject
import interfaces
URICreator = URIObject(
'http://schooltool.org/ns/intervention/creator',
'Creator', 'The creator/sender of the intervention relationship.')
URIResponsible = URIObject(
'http://schooltool.org/ns/intervention/responsible',
'Responsible', 'The persons responsible relationship.')
URIAtOneTime = URIObject(
'http://schooltool.org/ns/intervention/atonetime',
'AtOneTime', 'The at one time responsible relationship.')
URIMessage = URIObject(
'http://schooltool.org/ns/intervention/message',
'Message', 'The intervention message.')
URIGoal = URIObject(
'http://schooltool.org/ns/intervention/goal',
'Goal', 'The intervention goal.')
URIContact = URIObject(
'http://schooltool.org/ns/intervention/contact',
'Contact', 'The contact being linked.')
def getRequest():
"""Return the request object for the current request.
In the case of unit testing, return a TestRequest instance."""
i = management.getInteraction()
for p in i.participations:
if IRequest.providedBy(p):
return p
return TestRequest()
def contactName(contact):
contact = removeSecurityProxy(contact)
return '%s %s' % (contact.first_name, contact.last_name)
def contactsName(contacts):
contacts = [removeSecurityProxy(c) for c in contacts]
unsorted = [((c.last_name, c.first_name), contactName(c))
for c in contacts]
return [name for sort, name in sorted(unsorted)]
def contactsEmail(contacts):
return sorted([contact.email for contact in contacts if contact.email])
class InterventionRoot(BTreeContainer):
"""Container of InterventionSchoolYear objects."""
implements(interfaces.IInterventionRoot)
class InterventionSchoolYear(BTreeContainer):
"""Container of InteventionStudent objects."""
implements(interfaces.IInterventionSchoolYear)
class InterventionStudent(BTreeContainer):
"""Container of the student's intervention containers."""
implements(interfaces.IInterventionStudent)
def __init__(self):
super(InterventionStudent, self).__init__()
class InterventionMessages(BTreeContainer):
"""Container of Tier1 InteventionMessage objects."""
implements(interfaces.IInterventionMessages)
class InterventionMessage(Persistent, Contained):
"""Intervention message about a given student."""
implements(interfaces.IInterventionMessage, IAttributeAnnotatable)
subject = None
created = None
sender = RelationshipProperty(URICreator, URIMessage, URIContact)
recipients = RelationshipProperty(URIResponsible, URIMessage,
URIContact)
def __init__(self, body, subject=None, status_change=False):
self.subject = subject
self.body = body
self.status_change = status_change
self.created = pytz.UTC.localize(datetime.utcnow())
class InterventionGoals(BTreeContainer):
"""Container of InterventionGoal objects."""
implements(interfaces.IInterventionGoals)
class InterventionGoal(Persistent, Contained):
"""Intervention goal for a given student."""
implements(interfaces.IInterventionGoal, IAttributeAnnotatable)
created = None
creator = RelationshipProperty(URICreator, URIGoal, URIContact)
_persons_responsible = RelationshipProperty(URIResponsible, URIGoal,
URIContact)
at_one_time_responsible = RelationshipProperty(URIAtOneTime, URIGoal,
URIContact)
def __init__(self, goal, timeline,
presenting_concerns=u'', strengths=u'', indicators=u'',
intervention=u'', goal_met=False,
follow_up_notes=u''):
self.presenting_concerns = presenting_concerns
self.goal = goal
self.strengths = strengths
self.indicators = indicators
self.intervention = intervention
self.timeline = timeline
self.goal_met = goal_met
self.follow_up_notes = follow_up_notes
self.notified = False
self.created = pytz.UTC.localize(datetime.utcnow())
@property
def persons_responsible(self):
return self._persons_responsible
@persons_responsible.setter
def persons_responsible(self, value):
contacts = [IContact(contact) for contact in value]
for contact in self._persons_responsible:
if contact not in contacts:
self._persons_responsible.remove(contact)
for contact in contacts:
if contact not in self._persons_responsible:
self._persons_responsible.add(contact)
if contact not in self.at_one_time_responsible:
self.at_one_time_responsible.add(contact)
|