Beispiel #1
0
def run():
    """
    Pulls down all people and companies in the highrise account specified
    by the HIGHRISE_SERVER and HIGHRISE_AUTH_TOKEN env vars
    and returns a dictionary in the format:
    {
        <id>: {
            'name': <name>
            'lat': <lat>,
            'lng': <lng>
        },
        ...
    }
    """
    HIGHRISE_SERVER = os.environ.get('HIGHRISE_SERVER')
    HIGHRISE_AUTH_TOKEN = os.environ.get('HIGHRISE_AUTH_TOKEN')

    if not HIGHRISE_SERVER and HIGHRISE_AUTH_TOKEN:
        raise Exception(
            'HIGHRISE_SERVER and HIGHRISE_AUTH_TOKEN are required env vars'
        )

    Highrise.set_server(HIGHRISE_SERVER)
    Highrise.auth(HIGHRISE_AUTH_TOKEN)

    gn = geocoders.GeoNames()

    data = {}
    for x in Person.all() + Company.all():
        cd = x.contact_data
        zipcode = None
        if cd.addresses:
            a = cd.addresses[0]
            zipcode = a.zip
            if zipcode:
                if type(x) == Person:
                    name = '%s %s (%s)' % (x.first_name, x.last_name, x.company_name)
                elif type(x) == Company:
                    name = x.name
                try:
                    print 'Finding lat/lng for %s' % name
                    place, (lat,lng) = gn.geocode(zipcode)
                    data[x.id] = {'name': name, 'lat': lat, 'lng': lng}
                except Exception:
                    pass
    return data
Beispiel #2
0
 def highrise_import_tasks_of_company(cls, request):
     company = Company.get(request.id)
     tasks = company.tasks
     return tasks
Beispiel #3
0
 def highrise_import_notes_of_company(cls, request):
     company = Company.get(request.id)
     notes = company.notes
     return notes
Beispiel #4
0
 def highrise_import_company_details(cls, company_id):
     companie = Company.get(company_id)
     return companie
Beispiel #5
0
    def highrise_import_companies(cls, request):

        Highrise.set_server(request.server_name)
        Highrise.auth(request.key)
        companies = Company.all()
        return companies
Beispiel #6
0
 def highrise_import_tasks_of_company(cls, request):
     company = Company.get(request.id)
     tasks = company.tasks
     return tasks
Beispiel #7
0
 def highrise_import_notes_of_company(cls, request):
     company = Company.get(request.id)
     notes = company.notes
     return notes
Beispiel #8
0
 def highrise_import_company_details(cls, company_id):
     companie = Company.get(company_id)
     return companie
Beispiel #9
0
    def highrise_import_companies(cls, request):

        Highrise.set_server(request.server_name)
        Highrise.auth(request.key)
        companies = Company.all()
        return companies