Exemple #1
0
    def get(self):
        self.get_current_user()
        kwargs = dict(self.application.static_kwargs)
        kind = self.get_argument('kind')
        kwargs['page_name'] = kind
        kwargs['config'] = config
        query = self.get_argument('query', None)
        radius = self.get_argument('radius', None)
        if query is None or query == '':
            lat = self.get_argument('lat', None)
            lng = self.get_argument('lng', None)
            if lat is None or lng is None:
                lat = '40.050137'
                lng = '-74.221251'
            if radius is None:
                radius = '100'
        else:
            query = self.get_argument('query', None)
            google = GoogleGeo(self.db, config)
            query_results = google.address_search(query)
            query_array = query_results['response']

            ## get 1st result
            lat = query_array[0]['geometry']['location']['lat']
            lng = query_array[0]['geometry']['location']['lng']
            if radius is None:
                radius = '100'

        geo_results = Geocoder.reverse_geocode(float(lat), float(lng))
        kwargs['full_address'] = geo_results[0]

        resource = Resource(self.db, config)
        results = resource.list(kind, lat, lng, radius)
        kwargs['resource_objects'] = results['response']
        if int(len(results['response'])) == 0:
            self.write(
                self.application.loader.load(
                    'mobile/resources_none.html').generate(**kwargs))
            return

        if kind == 'employment':
            jobs = resource.list('job', lat, lng, radius)
            kwargs['jobs'] = jobs['response']

            job_gig = resource.list('job_gig', lat, lng, radius)
            kwargs['job_gig'] = job_gig['response']

        self.write(
            self.application.loader.load('mobile/resources.html').generate(
                **kwargs))
Exemple #2
0
 def get(self):
     kind = self.get_argument('kind', None)
     lat = self.get_argument('lat', None)
     lng = self.get_argument('lng', None)
     radius = self.get_argument('radius', None)
     resource = Resource(self.db, config)
     self.write(resource.list(kind, lat, lng, radius))