예제 #1
0
def searchable_text(obj):
    items = []

    acc = IAddress(obj, None)
    if acc:
        items += [
            safe_unicode(acc.street) or '',
            safe_unicode(acc.zip_code) or '',
            safe_unicode(acc.city) or '',
            safe_unicode(get_pycountry_name(acc.country)) if acc.country else ''  # noqa
        ]

    acc = IContact(obj, None)
    if acc:
        items += [
            safe_unicode(acc.email) or '',
            safe_unicode(acc.website) or '',
            safe_unicode(acc.phone) or '',
            safe_unicode(acc.mobile) or '',
            safe_unicode(acc.fax) or '',
        ]

    acc = IPerson(obj, None)
    if acc:
        items += [
            safe_unicode(acc.first_name) or '',
            safe_unicode(acc.last_name) or ''
        ]

    ret = _concat_and_utf8(*items)
    return ret
예제 #2
0
    def data(self):
        if getattr(self, '_data', False):
            return self._data

        context = self.context

        data = {}

        data['title'] = self.title
        data['description'] = self.description

        coordinates = self.data_coordinates
        if coordinates:
            data['latitude'] = coordinates[0]
            data['longitude'] = coordinates[1]

        acc = IAddress(context, None)
        address = {}
        if acc:
            address['street'] = acc.street
            address['zip_code'] = acc.zip_code
            address['city'] = acc.city
            address['country'] = get_pycountry_name(acc.country) or u''
            address['notes'] = acc.notes.output if acc.notes else u''
        data['address'] = {
            key: value
            for key, value in address.items() if value
        }

        acc = IContact(context, None)
        contact = {}
        if acc:
            contact['email'] = acc.email
            contact['web'] = acc.website
            contact['phone'] = acc.phone
            contact['mobile'] = acc.mobile
            contact['fax'] = acc.fax
        data['contact'] = {
            key: value
            for key, value in contact.items() if value
        }

        acc = ISocial(context, None)
        social = {}
        if acc:
            social['facebook'] = acc.facebook_url
            social['twitter'] = acc.twitter_url
            social['google_plus'] = acc.google_plus_url
            social['instagram'] = acc.instagram_url
        data['social'] = {key: value for key, value in social.items() if value}

        self._data = data
        return data
예제 #3
0
    def data(self):
        if getattr(self, '_data', False):
            return self._data

        context = self.context

        data = {}

        data['title'] = self.title
        data['description'] = self.description

        coordinates = self.data_coordinates
        if coordinates:
            data['latitude'] = coordinates[0]
            data['longitude'] = coordinates[1]

        acc = IAddress(context, None)
        address = {}
        if acc:
            address['street'] = acc.street
            address['zip_code'] = acc.zip_code
            address['city'] = acc.city
            address['country'] = get_pycountry_name(acc.country) or u''
            address['notes'] = acc.notes.output if acc.notes else u''
        data['address'] = {
            key: value for key, value in address.items() if value
        }

        acc = IContact(context, None)
        contact = {}
        if acc:
            contact['email'] = acc.email
            contact['web'] = acc.website
            contact['phone'] = acc.phone
            contact['mobile'] = acc.mobile
            contact['fax'] = acc.fax
        data['contact'] = {
            key: value for key, value in contact.items() if value
        }

        acc = ISocial(context, None)
        social = {}
        if acc:
            social['facebook'] = acc.facebook_url
            social['twitter'] = acc.twitter_url
            social['google_plus'] = acc.google_plus_url
            social['instagram'] = acc.instagram_url
        data['social'] = {
            key: value for key, value in social.items() if value
        }

        self._data = data
        return data
예제 #4
0
def get_venue_address_string(venue):
    address = IAddress(venue, None)
    if not address:
        return

    country = get_pycountry_name(address.country)
    ret = join_nonempty((
        address.street,
        join_nonempty((address.zip_code, address.city), sep=u' '),
        country
    ), sep=u', ')

    return ret
예제 #5
0
    def location(self):
        context = self.context
        location_ref = ILocation(context, None)
        if not location_ref:
            return
        location_uid = location_ref.location_uid
        location_notes = location_ref.location_notes
        location = uuidToObject(location_uid)

        meta_basic = IBasic(location, None)
        add = IAddress(location, None)

        location_url = None
        ret = u''
        if meta_basic and add:
            # I'm a location reference.
            # Create a link with href, title and urltext.

            # construct url to location
            site = getSite()
            location_url = location.absolute_url()
            site_path = u'/'.join(site.getPhysicalPath())
            location_path = u'/'.join(location.getPhysicalPath())
            if site_path not in location_path:
                # location in different site - cannot directly open it
                location_url = u'{0}/@@venue_view?uid={1}'.format(
                    site.absolute_url(), location_uid
                )

            country = get_pycountry_name(add.country)
            ret = self._location_link_template.format(  # noqa
                url=location_url,
                address=join_nonempty(
                    (
                        add.street,
                        join_nonempty((add.zip_code, add.city), sep=u' '),
                        country,
                    ),
                    sep=u', ',
                ),
                title=meta_basic.title,
            )

        ret = safe_unicode(ret)
        location_notes = safe_unicode(location_notes)

        ret = join_nonempty([ret, location_notes], u'. ')

        return ret
예제 #6
0
    def location(self):
        context = self.context
        location_ref = ILocation(context, None)
        if not location_ref:
            return
        location_uid = location_ref.location_uid
        location_notes = location_ref.location_notes
        location = uuidToObject(location_uid)

        meta_basic = IBasic(location, None)
        add = IAddress(location, None)

        location_url = None
        ret = u''
        if meta_basic and add:
            # I'm a location reference.
            # Create a link with href, title and urltext.

            # construct url to location
            site = getSite()
            location_url = location.absolute_url()
            site_path = u'/'.join(site.getPhysicalPath())
            location_path = u'/'.join(location.getPhysicalPath())
            if site_path not in location_path:
                # location in different site - cannot directly open it
                location_url = u'{0}/@@venue_view?uid={1}'.format(
                    site.absolute_url(), location_uid)

            country = get_pycountry_name(add.country)
            ret = self._location_link_template.format(  # noqa
                url=location_url,
                address=join_nonempty(
                    (
                        add.street,
                        join_nonempty((add.zip_code, add.city), sep=u' '),
                        country,
                    ),
                    sep=u', ',
                ),
                title=meta_basic.title,
            )

        ret = safe_unicode(ret)
        location_notes = safe_unicode(location_notes)

        ret = join_nonempty([ret, location_notes], u'. ')

        return ret