def _get_listings(self, params):
        """Query the recent listings from the MLS."""

        search_params = {
            'limit': self.limit,
            'offset': self.request.get('b_start', 0),
            'lang': self.portal_state.language(),
            'agency_listings': self.agency_exclusive
        }
        search_params.update(params)

        results, batching = search(search_params, context=self.context)

        if len(results) < 1:
            # Retry search
            results, batching = search(search_params, context=self.context)

        self._listings = results
        self._batching = batching
 def _get_listings(self):
     """Query the recent listings from the MLS."""
     params = {
         'limit': self.limit,
         'offset': self.request.get('b_start', 0),
         'lang': self.portal_state.language(),
     }
     params.update(self.config)
     params = prepare_search_params(params)
     results, batching = search(params, context=self.context)
     self._listings = results
     self._batching = batching
Ejemplo n.º 3
0
 def _get_listings(self, params):
     """Query the recent listings from the MLS."""
     search_params = {
         "limit": self.limit,
         "offset": self.request.get("b_start", 0),
         "lang": self.portal_state.language(),
         "agency_listings": self.config.get("agency_listings", False),
     }
     search_params.update(params)
     results, batching = search(params=search_params, context=self.context, config=self.config)
     self._listings = results
     self._batching = batching
Ejemplo n.º 4
0
    def results(self):
        items = []

        self.configured_fields = self.get_configured_fields()
        size_conf = [
            i for i in self.configured_fields if i['id'] == 'count'
        ]

        if size_conf and 'size' in size_conf[0].keys():
            size = int(size_conf[0]['size'])
        else:
            size = 5

        offset = 0
        offset_conf = [
            i for i in self.configured_fields if i['id'] == 'offset'
        ]
        if offset_conf:
            try:
                offset = int(offset_conf[0].get('offset', 0))
            except ValueError:
                offset = 0

        uuid = self.data.get('uuid', None)
        obj = uuidToObject(uuid)
        if uuid and obj:
            if not self.has_listing_collection(obj):
                return items
            config = copy.copy(self.get_config(obj))
            portal_state = getMultiAdapter(
                (self.context, self.request),
                name='plone_portal_state',
            )
            params = {
                'limit': size,
                'offset': offset,
                'lang': portal_state.language(),
            }
            config.update(params)
            items = api.search(
                params=api.prepare_search_params(config),
                batching=False,
                context=obj,
            )
        else:
            self.remove_relation()

        return items
Ejemplo n.º 5
0
 def _get_listings(self, params):
     """Query the recent listings from the MLS."""
     search_params = {
         'limit': self.limit,
         'offset': self.request.get('b_start', 0),
         'lang': self.portal_state.language(),
         'agency_listings': self.config.get('agency_listings', False),
         'agency_priority': self.config.get('agency_priority', False),
     }
     search_params.update(params)
     results, batching = search(
         params=search_params,
         context=self.context,
         config=self.config,
     )
     self._listings = results
     self._batching = batching
Ejemplo n.º 6
0
    def _get_listings(self):
        """Query the recent listings from the MLS."""
        listing_ids = self.context.listing_ids
        if len(listing_ids) == 0:
            return
        listing_ids = [lid.lower() for lid in listing_ids]
        params = {
            'limit': 0,
            'offset': 0,
            'lang': self.portal_state.language(),
        }
        params.update({
            'listing_ids': listing_ids,
        })
        params = prepare_search_params(params)
        results = search(params, batching=False, context=self.context)
        if results is None or len(results) == 0:
            return

        # sort the results based on the listing_ids
        results = [(item['id']['value'], item) for item in results]
        results = dict(results)
        return [results.get(id) for id in listing_ids if id in results]
    def items(self):
        """Return the collection items."""
        items = []
        context = self.get_context
        if not context or not self.has_listing_collection(context):
            return items

        context_config = copy.copy(self.get_config(context))
        language = plone_api.portal.get_current_language(context=context)
        params = {
            'lang': language,
            'limit': self.size,
            'offset': self.start_at,
        }
        context_config.update(params)
        params = api.prepare_search_params(context_config)
        items = api.search(
            params=params,
            batching=False,
            context=context,
            config=self.get_config(context),
        )
        return items