Beispiel #1
0
    def filter_stream(self, req, method, filename, stream, data):
        """Return a filtered Genshi event stream, or the original unfiltered
        stream if no match.

        `req` is the current request object, `method` is the Genshi render
        method (xml, xhtml or text), `filename` is the filename of the template
        to be rendered, `stream` is the event stream and `data` is the data for
        the current template.

        See the Genshi documentation for more information.
        """
        if filename == "query.html" and self.inject_query:
            self.geoticket()  # sanity check
            chrome = Chrome(self.env)
            variables = ("center_location", "radius")
            _data = dict([(i, data.get(i)) for i in variables])

            # georegions
            _data["geo_column_label"] = None
            _data["regions"] = None
            if self.env.is_component_enabled(GeoRegions):
                georegions = GeoRegions(self.env)
                if georegions.enabled():
                    regions = georegions.regions()
                    if regions:
                        column, regions = regions
                        _data["geo_column_label"] = column
                        _data["regions"] = regions
                        _data["region"] = req.args.get("region")

            template = chrome.load_template("geoquery.html")
            stream |= Transformer("//fieldset[@id='columns']").after(template.generate(**_data))

        return stream
Beispiel #2
0
    def filter_stream(self, req, method, filename, stream, data):
        """Return a filtered Genshi event stream, or the original unfiltered
        stream if no match.

        `req` is the current request object, `method` is the Genshi render
        method (xml, xhtml or text), `filename` is the filename of the template
        to be rendered, `stream` is the event stream and `data` is the data for
        the current template.

        See the Genshi documentation for more information.
        """
        if filename == 'query.html' and self.inject_query:
            self.geoticket()  # sanity check
            chrome = Chrome(self.env)
            variables = ('center_location', 'radius')
            _data = dict([(i, data.get(i)) for i in variables])

            # georegions
            _data['geo_column_label'] = None
            _data['regions'] = None
            if self.env.is_component_enabled(GeoRegions):
                georegions = GeoRegions(self.env)
                if georegions.enabled():
                    regions = georegions.regions()
                    if regions:
                        column, regions = regions
                        _data['geo_column_label'] = column
                        _data['regions'] = regions
                        _data['region'] = req.args.get('region')

            template = chrome.load_template('geoquery.html')
            stream |= Transformer("//fieldset[@id='columns']").after(
                template.generate(**_data))

        return stream
Beispiel #3
0
 def query_by_polygon(self, region):
     georegions = GeoRegions(self.env)
     return georegions.tickets_in_region(region)
Beispiel #4
0
 def query_by_polygon(self, region):
     georegions = GeoRegions(self.env)
     return georegions.tickets_in_region(region)