This file is indexed.

/usr/share/pyshared/schooltool/contact/contact.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
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#
#
# SchoolTool - common information systems platform for school administration
# Copyright (c) 2009 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
#
"""
Contact objects
"""
from persistent import Persistent

from zope.catalog.text import TextIndex
from zope.component import adapter, adapts
from zope.index.text.interfaces import ISearchableText
from zope.interface import implementer
from zope.interface import implements
from zope.intid.interfaces import IIntIds
from zope.container.contained import Contained
from zope.container.btree import BTreeContainer
from zope.component import getUtility

from schooltool.app.interfaces import ISchoolToolApplication
from schooltool.app.app import InitBase, StartUpBase
from schooltool.app.catalog import AttributeCatalog
from schooltool.utility.utility import UtilitySetUp
from schooltool.contact.interfaces import IContactPersonInfo
from schooltool.contact.interfaces import IContactable
from schooltool.contact.interfaces import IContact, IContactContained
from schooltool.contact.interfaces import IContactContainer
from schooltool.contact.interfaces import IUniqueFormKey
from schooltool.relationship.uri import URIObject
from schooltool.relationship.relationship import BoundRelationshipProperty
from schooltool.relationship.relationship import RelationshipProperty
from schooltool.relationship.relationship import RelationshipSchema
from schooltool.securitypolicy import crowds
from schooltool.table.catalog import ConvertingIndex
from schooltool.common import simple_form_key
from schooltool.person.interfaces import IPerson
from schooltool.course.section import PersonInstructorsCrowd

from schooltool.common import SchoolToolMessage as _


URIContactRelationship = URIObject('http://schooltool.org/ns/contact',
                                   'Contact relationship',
                                   'The contact relationship.')

URIContact = URIObject('http://schooltool.org/ns/contact/contact',
                       'Contact', 'A contact relationship contact record role.')

URIPerson = URIObject('http://schooltool.org/ns/contact/person',
                      'Person', 'A contact relationship person role.')

Contact = RelationshipSchema(URIContactRelationship,
                             contact=URIContact, person=URIPerson)


class ContactGroup(crowds.DescriptionGroup):

    title = _(u"Contacts")

    description = _(u"""
    All SchoolTool users have contact information, that includes home address,
    phone number, email address, etc.

    "External contacts" can be created - people who are not SchoolTool users,
    but may need to recieve notifications and information about the student
    or the school as a whole.
    """)


class ContactContainer(BTreeContainer):
    """Container of persons."""

    implements(IContactContainer)


class Contact(Persistent, Contained):
    """Contact."""

    implements(IContactContained)

    prefix = None
    first_name = None
    middle_name = None
    last_name = None
    suffix = None
    address_line_1 = None
    address_line_2 = None
    city = None
    state = None
    country = None
    postal_code = None
    email = None
    home_phone = None
    work_phone = None
    mobile_phone = None
    other_1 = None
    other_2 = None
    language = None

    persons = RelationshipProperty(URIContactRelationship,
                                   my_role=URIContact,
                                   other_role=URIPerson)

    @property
    def title(self):
        return "%s %s" % (self.first_name, self.last_name)


class ContactPersonInfo(Persistent, Contained):
    """Additional information about contact of a specific person."""

    implements(IContactPersonInfo)

    __parent__ = None
    relationship = None

    def getRelationshipTitle(self):
        vocabulary = IContactPersonInfo['relationship'].vocabulary
        try:
            term = vocabulary.getTerm(self.relationship)
        except LookupError:
            return u''
        return term.title


class ContextRelationshipProperty(RelationshipProperty):
    """Context relationship property."""

    def __get__(self, instance, owner):
        """Bind the property to the context of an instance."""
        if instance is None:
            return self
        else:
            return BoundRelationshipProperty(instance.context,
                                             self.rel_type,
                                             self.my_role,
                                             self.other_role)


class Contactable(object):
    implements(IContactable)

    contacts = ContextRelationshipProperty(URIContactRelationship,
                                           my_role=URIPerson,
                                           other_role=URIContact)

    def __init__(self, context):
        self.context = context


class ContactAppStartup(StartUpBase):
    def __call__(self):
        if 'schooltool.contact' not in self.app:
            self.app['schooltool.contact'] = ContactContainer()


class ContactInit(InitBase):
    def __call__(self):
        self.app['schooltool.contact'] = ContactContainer()


@implementer(IContactContainer)
@adapter(ISchoolToolApplication)
def getContactContainer(app):
    return app['schooltool.contact']


@adapter(IContact)
@implementer(IUniqueFormKey)
def getContactFormKey(contact):
    doc_id = getUtility(IIntIds).getId(contact)
    return 'contacts.%s%x' % (simple_form_key(contact), doc_id)


class ContactCatalog(AttributeCatalog):
    version = '4 - added text index'
    interface = IContact
    attributes = ('first_name', 'last_name', 'title')

    def setIndexes(self, catalog):
        super(ContactCatalog, self).setIndexes(catalog)
        catalog['form_keys'] = ConvertingIndex(converter=IUniqueFormKey)
        catalog['text'] = TextIndex('getSearchableText', ISearchableText, True)


getContactCatalog = ContactCatalog.get


class SearchableTextContact(object):

    adapts(IContact)
    implements(ISearchableText)

    def __init__(self, context):
        self.context = context

    def getSearchableText(self):
        result = [self.context.first_name, self.context.last_name]
        return ' '.join(result)


class ContactPersonInstructorsCrowd(PersonInstructorsCrowd):
    """Crowd of instructors of any of related persons to this contact."""

    title = _(u'Instructors')
    description = _(u'Instructors of student(s) related to this contact.')

    def contains(self, principal):
        user = IPerson(principal, None)
        for person in self.context.persons:
            sections = self._getSections(person)
            for section in sections:
                if user in section.instructors:
                    return True
        return False