def update(self): super(Person, self).update() self.person = self.context person = self.person self.name = person.Title() if IBirthday.providedBy(person): birthday = person.birthday if birthday is not None: birthday = date_to_DateTime(birthday) self.birthday = self.context.toLocalizedTime(birthday) else: self.birthday = "" self.person_title = person.person_title self.gender = person.gender or '' catalog = getToolByName(self.context, 'portal_catalog') context_path = '/'.join(person.getPhysicalPath()) results = catalog.searchResults(path={'query': context_path, 'depth': 1}) self.held_positions = results contactable = IContactable(person) contact_details = contactable.get_contact_details() self.email = contact_details['email'] self.phone = contact_details['phone'] self.fax = contact_details['fax'] self.cell_phone = contact_details['cell_phone'] self.im_handle = contact_details['im_handle'] self.website = contact_details['website'] self.address = contact_details['address'] # also show fields that were added TTW self.ttw_fields = get_ttw_fields(person)
def update(self): super(Contact, self).update() held_position = self.context self.portal_url = api.portal.get().absolute_url() start_date = held_position.start_date if start_date is not None: start_date = date_to_DateTime(start_date) self.start_date = self.context.toLocalizedTime(start_date) end_date = held_position.end_date if end_date is not None: end_date = date_to_DateTime(end_date) self.end_date = self.context.toLocalizedTime(end_date) person = held_position.get_person() self.person = person self.fullname = person.Title() self.title = held_position.Title() if IBirthday.providedBy(person): birthday = person.birthday if birthday is not None: birthday = date_to_DateTime(birthday) self.birthday = self.context.toLocalizedTime(birthday) else: self.birthday = None self.gender = person.gender or '' self.position = held_position.get_position() organization = held_position.get_organization() self.organizations = organization and organization.get_organizations_chain() or []
def get_vcard(self): vcard = ContactableVCard.get_vcard(self) vcard.add('kind') vcard.kind.value = "individual" held_position = self.context contactable = IContactable(held_position) person = contactable.person position = contactable.position organizations = contactable.organizations vcard.add('n') firstname = safe_unicode(person.firstname or '', encoding='utf8') lastname = safe_unicode(person.lastname or '', encoding='utf8') person_title = safe_unicode(person.person_title or '', encoding='utf8') vcard.n.value = vobject.vcard.Name(prefix=person_title, family=lastname, given=firstname) vcard.add('fn') vcard.fn.value = ' '.join([e for e in (firstname, lastname) if e]) if IBirthday.providedBy(person) and person.birthday is not None: vcard.add('bday') vcard.bday.value = person.birthday.isoformat() if position is not None: position_name = safe_unicode(position.Title(), encoding='utf8') vcard.add('role') vcard.role.value = position_name vcard.add('title') vcard.title.value = position_name vcard.add('org') vcard.org.value = [ safe_unicode(org.Title(), encoding='utf8') for org in organizations ] # TODO ? # vcard.add('photo') # vcard.photo.value = person.photo # if person.latitude is not None and \ # person.longitude is not None: # vcard.add('geo') # vcard.geo.value = "%.2f;%.2f" % (person.latitude, person.longitude) return vcard
def update(self): super(Contact, self).update() held_position = self.context self.portal_url = api.portal.get().absolute_url() start_date = held_position.start_date if start_date is not None: start_date = date_to_DateTime(start_date) self.start_date = self.context.toLocalizedTime(start_date) end_date = held_position.end_date if end_date is not None: end_date = date_to_DateTime(end_date) self.end_date = self.context.toLocalizedTime(end_date) person = held_position.get_person() self.person = person self.fullname = person.Title() self.title = held_position.Title() if IBirthday.providedBy(person): birthday = person.birthday if birthday is not None: birthday = date_to_DateTime(birthday) self.birthday = self.context.toLocalizedTime(birthday) else: self.birthday = None self.gender = person.gender or '' self.position = held_position.get_position() organization = held_position.get_organization() self.organizations = organization and organization.get_organizations_chain() or [] contactable = IContactable(held_position) contact_details = contactable.get_contact_details() self.email = contact_details['email'] self.phone = contact_details['phone'] self.cell_phone = contact_details['cell_phone'] self.fax = contact_details['fax'] self.im_handle = contact_details['im_handle'] self.website = contact_details['website'] self.address = contact_details['address'] # also show fields that were added TTW self.ttw_fields = get_ttw_fields(held_position)
def get_vcard(self): vcard = ContactableVCard.get_vcard(self) vcard.add('kind') vcard.kind.value = "individual" held_position = self.context contactable = IContactable(held_position) person = contactable.person position = contactable.position organizations = contactable.organizations vcard.add('n') firstname = safe_unicode(person.firstname or '', encoding='utf8') lastname = safe_unicode(person.lastname or '', encoding='utf8') person_title = safe_unicode(person.person_title or '', encoding='utf8') vcard.n.value = vobject.vcard.Name(prefix=person_title, family=lastname, given=firstname) vcard.add('fn') vcard.fn.value = ' '.join([e for e in (firstname, lastname) if e]) if IBirthday.providedBy(person) and person.birthday is not None: vcard.add('bday') vcard.bday.value = person.birthday.isoformat() if position is not None: position_name = safe_unicode(position.Title(), encoding='utf8') vcard.add('role') vcard.role.value = position_name vcard.add('title') vcard.title.value = position_name vcard.add('org') vcard.org.value = [safe_unicode(org.Title(), encoding='utf8') for org in organizations] # TODO ? #vcard.add('photo') #vcard.photo.value = person.photo # if person.latitude is not None and \ # person.longitude is not None: # vcard.add('geo') # vcard.geo.value = "%.2f;%.2f" % (person.latitude, person.longitude) return vcard
def update(self): self.person = self.context person = self.person sm = getSecurityManager() self.name = person.Title() if IBirthday.providedBy(person): birthday = person.birthday if birthday is not None: birthday = date_to_DateTime(birthday) self.birthday = self.context.toLocalizedTime(birthday) else: self.birthday = "" self.person_title = person.person_title self.gender = person.gender or '' self.can_edit = sm.checkPermission('Modify portal content', person)
def update(self): super(Person, self).update() self.person = self.context person = self.person self.name = person.Title() if IBirthday.providedBy(person): birthday = person.birthday if birthday is not None: birthday = date_to_DateTime(birthday) self.birthday = self.context.toLocalizedTime(birthday) else: self.birthday = "" self.person_title = person.person_title self.gender = person.gender or '' catalog = getToolByName(self.context, 'portal_catalog') context_path = '/'.join(person.getPhysicalPath()) results = catalog.searchResults(path={ 'query': context_path, 'depth': 1 }) self.held_positions = results contactable = IContactable(person) contact_details = contactable.get_contact_details() self.email = contact_details['email'] self.phone = contact_details['phone'] self.fax = contact_details['fax'] self.cell_phone = contact_details['cell_phone'] self.im_handle = contact_details['im_handle'] self.website = contact_details['website'] self.address = contact_details['address'] # also show fields that were added TTW self.ttw_fields = get_ttw_fields(person)
def update(self): super(Contact, self).update() held_position = self.context self.portal_url = api.portal.get().absolute_url() start_date = held_position.start_date if start_date is not None: start_date = date_to_DateTime(start_date) self.start_date = self.context.toLocalizedTime(start_date) end_date = held_position.end_date if end_date is not None: end_date = date_to_DateTime(end_date) self.end_date = self.context.toLocalizedTime(end_date) person = held_position.get_person() self.person = person self.fullname = person.Title() self.title = held_position.Title() if IBirthday.providedBy(person): birthday = person.birthday if birthday is not None: birthday = date_to_DateTime(birthday) self.birthday = self.context.toLocalizedTime(birthday) else: self.birthday = None self.gender = person.gender or '' self.position = held_position.get_position() organization = held_position.get_organization() self.organizations = organization and organization.get_organizations_chain( ) or []