def get_contact_details(self, keys=(), fallback=True): if not IContactDetails.providedBy(self.context): raise TypeError( "Your contactable content must provide IContactDetails " "if it doesn't have a more specific contactable adapter") contact_details = {} if keys: contact_details_fields = [k for k in keys if k != 'address'] else: contact_details_fields = CONTACT_DETAILS_FIELDS context = aq_base(self.context) for field in contact_details_fields: # search the object that carries the field value = getattr(context, field, '') or '' contact_details[field] = value if (not keys) or ('address' in keys): contact_details['address'] = get_address(context) if 'website' in contact_details: contact_details['website'] = get_valid_url( contact_details['website']) return contact_details
def update(self): organization = self.context othercontacts = [] held_positions = organization.get_held_positions() held_positions.sort(key=lambda x: held_position_sortable_title(x)()) for hp in held_positions: contact = {} person = hp.get_person() contact['title'] = person.Title() contact['held_position'] = hp.Title() contact['label'] = hp.label contact['obj'] = hp if IContactDetails.providedBy(hp): contactable = hp elif IContactDetails.providedBy(person): contactable = person contact['email'] = contactable.email contact['phone'] = contactable.phone contact['cell_phone'] = contactable.cell_phone contact['fax'] = contactable.fax contact['im_handle'] = contactable.im_handle contact['website'] = get_valid_url(contactable.website) othercontacts.append(contact) self.othercontacts = othercontacts
def get_contact_details(self, keys=(), fallback=True): contact_details = {} if keys: contact_details_fields = [k for k in keys if k != 'address'] else: contact_details_fields = CONTACT_DETAILS_FIELDS if fallback: contactables = self._get_contactables() else: contactables = [self.context] for field in contact_details_fields: # search the object that carries the field for obj in contactables: obj = aq_base(obj) value = getattr(obj, field, '') or '' if value: contact_details[field] = value break else: contact_details[field] = '' if (not keys) or ('address' in keys): contact_details['address'] = self._get_address(contactables) if 'website' in contact_details: contact_details['website'] = get_valid_url( contact_details['website']) return contact_details
def get_contact_details(self, keys=(), fallback=True): if not IContactDetails.providedBy(self.context): raise TypeError("Your contactable content must provide IContactDetails " "if it doesn't have a more specific contactable adapter") contact_details = {} if keys: contact_details_fields = [k for k in keys if k != 'address'] else: contact_details_fields = CONTACT_DETAILS_FIELDS context = aq_base(self.context) for field in contact_details_fields: # search the object that carries the field value = getattr(context, field, '') or '' contact_details[field] = value if (not keys) or ('address' in keys): contact_details['address'] = get_address(context) if 'website' in contact_details: contact_details['website'] = get_valid_url( contact_details['website']) return contact_details
def get_contact_details(self, keys=(), fallback=True): contact_details = {} if keys: contact_details_fields = [k for k in keys if k != 'address'] else: contact_details_fields = CONTACT_DETAILS_FIELDS if fallback: contactables = self._get_contactables() else: contactables = [self.context] for field in contact_details_fields: # search the object that carries the field for obj in contactables: obj = aq_base(obj) value = getattr(obj, field, '') or '' if value: contact_details[field] = value break else: contact_details[field] = '' if (not keys) or ('address' in keys): contact_details['address'] = self._get_address(contactables) if 'website' in contact_details: contact_details['website'] = get_valid_url(contact_details['website']) return contact_details
def update(self): organization = self.context othercontacts = [] held_positions = organization.get_held_positions() held_positions.sort(key=lambda x: x.get_sortable_title()) for hp in held_positions: contact = {} person = hp.get_person() contact['person'] = person contact['title'] = person.Title() contact['held_position'] = hp.Title() contact['label'] = hp.get_label() contact['obj'] = hp contact['display_photo'] = api.portal.get_registry_record( name='display_contact_photo_on_organization_view', interface=IContactCoreParameters) contact['has_photo'] = contact['display_photo'] and hp.photo or None if IContactDetails.providedBy(hp): contactable = hp elif IContactDetails.providedBy(person): contactable = person contact['email'] = contactable.email contact['phone'] = contactable.phone contact['cell_phone'] = contactable.cell_phone contact['fax'] = contactable.fax contact['im_handle'] = contactable.im_handle contact['website'] = get_valid_url(contactable.website) othercontacts.append(contact) self.othercontacts = othercontacts