2
# SchoolTool - common information systems platform for school administration
3
# Copyright (c) 2005 Shuttleworth Foundation
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
from zope.catalog.interfaces import ICatalog
21
from zope.component import getUtility
22
from zope.security.proxy import removeSecurityProxy
24
from zc.catalog.catalogindex import ValueIndex
25
from zc.catalog.extentcatalog import Catalog
26
from zc.catalog.extentcatalog import FilterExtent
28
from schooltool.table.catalog import ConvertingIndex
29
from schooltool.table.catalog import FilterImplementing
30
from schooltool.utility.utility import UtilitySetUp
35
INTERVENTION_CATALOG_KEY = 'schooltool.intervention'
39
return Catalog(FilterExtent(FilterImplementing(
40
interfaces.IInterventionMarker)))
43
def catalogSetUp(catalog):
44
catalog['first_name'] = ConvertingIndex(converter=getStudentFirstName)
45
catalog['last_name'] = ConvertingIndex(converter=getStudentLastName)
46
catalog['persons_responsible'] = ConvertingIndex(
47
converter=interfaces.IInterventionPersonsResponsible)
48
catalog['created'] = ValueIndex('created')
49
catalog['schoolYearId'] = ConvertingIndex(converter=getSchoolYearId)
50
catalog['intervention_type'] = ConvertingIndex(
51
converter=interfaces.IInterventionType)
54
catalogSetUpSubscriber = UtilitySetUp(
55
catalogFactory, ICatalog, INTERVENTION_CATALOG_KEY, setUp=catalogSetUp)
58
def getInterventionCatalog(container):
59
return getUtility(ICatalog, INTERVENTION_CATALOG_KEY)
62
def getStudentFirstName(obj):
63
return obj.student.first_name
66
def getStudentLastName(obj):
67
return obj.student.last_name
70
def getMessagePersonsResponsible(obj):
74
def getGoalPersonsResponsible(obj):
75
# XXX not using removeSecurityProxy caused ZODB to crash
76
# Cannot pickle <type 'zope.security._proxy._Proxy'> objects
77
return removeSecurityProxy(obj.persons_responsible)
80
def getMessageType(obj):
88
def getSchoolYearId(obj):
89
sy = interfaces.IInterventionSchoolYear(obj)
93
def messageGetter(obj):
96
value = value[:47] + '...'
101
value = obj.presenting_concerns
103
value = value[:47] + '...'