예제 #1
0
 def contains(self, principal):
     person = IPerson(principal, None)
     if person is None:
         return False
     relationships = ContactRelationship.bind(contact=IContact(person))
     is_parent = bool(relationships.any(ACTIVE + PARENT))
     return is_parent
예제 #2
0
def city_getter(contact, formatter):
    contact = IContact(contact)
    city = contact.city
    if city is not None:
        city += ','
    state = contact.state
    postal_code = contact.postal_code
    return ' '.join(filter(None, [city, state, postal_code]))
예제 #3
0
 def submitItems(self):
     int_ids = getUtility(IIntIds)
     catalog = self.view.getCatalog()
     index = catalog['form_keys']
     for intid in self.view.getSelectedItemIds():
         key = '%s.%s' % (self.button_prefix,
                          index.documents_to_values[intid])
         if key in self.request:
             self.view.remove(IContact(int_ids.getObject(intid)))
예제 #4
0
 def items(self):
     result = []
     for member in self.context.members:
         if self.has_address(IContact(member)):
             result.append(member)
         for contact in IContactable(member).contacts:
             if self.has_address(contact):
                 result.append(contact)
     return result
예제 #5
0
 def update(self):
     user = IPerson(self.request.principal)
     super(SendEmailView, self).update()
     if not IContact(user).email:
         url = absoluteURL(self.context, self.request) + \
               '/noTeacherEmail.html'
         self.request.response.redirect(url)
         return
     self.updateDisplayWidgets()
예제 #6
0
 def contains(self, principal):
     person = IPerson(principal, None)
     if person is None:
         return False
     target = self.child
     if target is None:
         return False
     relationships = ContactRelationship.bind(contact=IContact(person))
     is_parent = target in relationships.any(ACTIVE + PARENT)
     return is_parent
예제 #7
0
 def columns(self):
     title = table.column.LocaleAwareGetterColumn(
         name='title',
         title=_(u'Name'),
         getter=lambda i, f: i.title,
         subsort=True)
     address_1 = zc.table.column.GetterColumn(
         name='address_1',
         title=_(u'Address 1'),
         getter=lambda i, f: IContact(i).address_line_1)
     address_2 = zc.table.column.GetterColumn(
         name='address_2',
         title=_(u'Address 2'),
         getter=lambda i, f: IContact(i).address_line_2)
     city = zc.table.column.GetterColumn(name='city',
                                         title=_(u'City'),
                                         getter=city_getter)
     country = zc.table.column.GetterColumn(
         name='country',
         title=_(u'Country'),
         getter=lambda i, f: IContact(i).country)
     return [title, address_1, address_2, city, country]
예제 #8
0
 def contactInfo(self, contact_context, title):
     contact = IContact(contact_context)
     return {
         'link': absoluteURL(contact_context, self.request),
         'relationship': title,
         'name': " ".join(self._extract_attrs(contact, IContactPerson)),
         'address': ", ".join(self._extract_attrs(contact, IAddress)),
         'emails': ", ".join(self._extract_attrs(contact, IEmails)),
         'phones':
         list(self._extract_attrs(contact, IPhones, add_title=True)),
         'languages': ", ".join(self._extract_attrs(contact, ILanguages)),
         '__parent__': contact_context,
     }
예제 #9
0
def setUpSchool(app):
    sy = ISchoolYearContainer(app)['2005'] = SchoolYear(
        '2005', date(2005, 1, 1), date(2005, 1, 30))

    term = sy['spring'] = Term('Spring', date(2005, 1, 1), date(2005, 1, 30))
    term.addWeekdays(0, 1, 2, 3, 4)

    pc = app['persons']
    teacher = pc['teacher'] = BasicPerson("teacher", "Mister", "T")
    s1 = pc['john'] = BasicPerson("john", "John", "Peterson")
    s2 = pc['pete'] = BasicPerson("pete", "Pete", "Johnson")

    contacts = IContactContainer(app)
    contact = Contact()
    contact.__name__ = 'pete_parent'
    contact.prefix = 'Ms.'
    contact.first_name = 'Susan'
    contact.middle_name = 'T.'
    contact.last_name = 'Johnson'
    contact.suffix = 'Jr.'
    contact.address_line_1 = '1 First St.'
    contact.address_line_2 = 'Apt. 1'
    contact.city = 'NY'
    contact.state = 'NY'
    contact.country = 'USA'
    contact.postal_code = '00000'
    contact.email = '*****@*****.**'
    contact.home_phone = '000-0000'
    contact.work_phone = '111-1111'
    contact.mobile_phone = '222-2222'
    contact.language = 'English'
    contacts['pete_parent'] = contact

    IContactable(s2).contacts.relate(contact, ACTIVE + PARENT, 'p')
    IContactable(s2).contacts.relate(IContact(teacher), ACTIVE + PARENT, 'p')

    d1 = IDemographics(s1)
    d1['ID'] = "112323"
    d1['ethnicity'] = u'Asian'
    d1['language'] = "English"
    d1['placeofbirth'] = "Humptington"
    d1['citizenship'] = "US"
    d2 = IDemographics(s2)
    d2['ID'] = "333655"
    d2['ethnicity'] = u'White'
    d2['language'] = "Brittish"
    d2['placeofbirth'] = "Providence"
    d2['citizenship'] = "UK"

    course = ICourseContainer(sy)['c1'] = Course("History")
예제 #10
0
def evolve(context):
    linkcatalogs.ensureEvolved(context)
    root = context.connection.root().get(ZopePublication.root_name, None)

    old_site = getSite()
    apps = findObjectsProviding(root, ISchoolToolApplication)
    for app in apps:
        setSite(app)
        # vivify person contact information
        persons = findObjectsProviding(app, IPerson)
        for person in persons:
            contact = IContact(person, None)

    setSite(old_site)
예제 #11
0
    def update(self):
        context_url = absoluteURL(self.context, self.request)
        catalog = self.getCatalog()
        int_ids = getUtility(IIntIds)
        index = catalog['form_keys']
        if 'ADD_ITEMS' in self.request:
            for intid in self.getAvailableItemIds():
                key = 'add_item.%s' % index.documents_to_values[intid]
                if key in self.request:
                    self.add(IContact(int_ids.getObject(intid)))
        elif 'REMOVE_ITEMS' in self.request:
            for intid in self.getSelectedItemIds():
                key = 'remove_item.%s' % index.documents_to_values[intid]
                if key in self.request:
                    self.remove(int_ids.getObject(intid))
        elif 'CANCEL' in self.request:
            self.request.response.redirect(context_url)

        self.setUpTables()
예제 #12
0
    def format_contact_persons(self):
        def contact_getter(attribute):
            def getter(contact):
                person = IBasicPerson(contact.__parent__, None)
                if person is None:
                    return getattr(contact, attribute)
                if attribute == '__name__':
                    return person.username
                return ''

            return getter

        fields = [('ID', Text, contact_getter('__name__')),
                  ('Prefix', Text, contact_getter('prefix')),
                  ('First Name', Text, contact_getter('first_name')),
                  ('Middle Name', Text, contact_getter('middle_name')),
                  ('Last Name', Text, contact_getter('last_name')),
                  ('Suffix', Text, contact_getter('suffix')),
                  ('Address line 1', Text, attrgetter('address_line_1')),
                  ('Address line 2', Text, attrgetter('address_line_2')),
                  ('City', Date, attrgetter('city')),
                  ('State', Date, attrgetter('state')),
                  ('Country', Date, attrgetter('country')),
                  ('Postal code', Date, attrgetter('postal_code')),
                  ('Home phone', Text, attrgetter('home_phone')),
                  ('Work phone', Text, attrgetter('work_phone')),
                  ('Mobile phone', Text, attrgetter('mobile_phone')),
                  ('Email', Text, attrgetter('email')),
                  ('Language', Text, attrgetter('language'))]

        items = []
        for person in self.context['persons'].values():
            items.append(IContact(person))
        for contact in IContactContainer(self.context).values():
            items.append(contact)

        return self.format_table(fields,
                                 items,
                                 importer='export_contacts',
                                 major_progress=(0, 2))
예제 #13
0
    def add(self, person):
        name = person.username

        persons = ISchoolToolApplication(None)['persons']
        persons[name] = person

        contact = removeSecurityProxy(self.contact)

        person.prefix = contact.prefix
        person.middle_name = contact.middle_name
        person.suffix = contact.suffix

        person.photo = contact.photo
        if person.photo is not None:
            person.photo.__parent__ = person

        self.copyContactInfo(contact, IContact(person))

        del contact.__parent__[contact.__name__]

        self.added = person
        return person
예제 #14
0
 def getOmmitedItemIds(self):
     int_ids = getUtility(IIntIds)
     self_contact = IContact(self.context)
     return self.getSelectedItemIds() + [int_ids.getId(self_contact)]
예제 #15
0
 def bound_contact(self):
     return IContact(self.context)
예제 #16
0
 def getOmmitedItems(self):
     for item in EditTemporalRelationships.getOmmitedItems(self):
         yield item
     self_contact = IContact(self.context)
     yield self_contact
예제 #17
0
 def __call__(self):
     contact = IContact(self.object)
     dependable = IDependable(contact)
     dependable.removeDependent("")
     notify(
         ObjectRemovedEvent(contact, contact.__parent__, contact.__name__))
예제 #18
0
 def __call__(self):
     contact = IContact(self.object)
     # notify about possible changes in contact information
     # note: we do not provide descriptions of changes
     notify(ObjectModifiedEvent(contact))
예제 #19
0
 def __call__(self):
     # auto-vivification of bound contact
     contact = IContact(self.object)
예제 #20
0
 def children(self):
     contact = IContact(self.person)
     relationships = ContactRelationship.bind(contact=contact)
     return list(relationships.any(ACTIVE+PARENT))
예제 #21
0
 def from_address(self):
     user = IPerson(self.request.principal, None)
     if user is None:
         return u''
     return IContact(user).email
예제 #22
0
 def getPerson(self):
     bound = IContact(self.person)
     return self.buildInfo(bound)
예제 #23
0
 def buildInfo(self, contact):
     contact = IContact(contact)
     title = get_relationship_title(self.person, contact)
     return self.contactInfo(contact, title)