コード例 #1
0
ファイル: handlers.py プロジェクト: bugkiwi/lizard-fewsjdbc
 def read(self, request, jdbc_source_slug):
     result = {}
     result['info'] = documentation(self.__class__)
     jdbc_source = JdbcSource.objects.get(slug=jdbc_source_slug)
     result['data'] = self._return_data(
         jdbc_source.get_filter_tree(),
         request, jdbc_source_slug)
     return result
コード例 #2
0
ファイル: handlers.py プロジェクト: bugkiwi/lizard-fewsjdbc
 def read(self, request):
     result = {}
     result['info'] = documentation(self.__class__)
     data = []
     for jdbc_source in JdbcSource.objects.all():
         url = request.build_absolute_uri(
             reverse(FILTER_URL_NAME,
                     kwargs={'jdbc_source_slug': jdbc_source.slug}))
         data.append({'title': jdbc_source.name,
                      'url': url})
     result['data'] = data
     return result
コード例 #3
0
ファイル: handlers.py プロジェクト: bugkiwi/lizard-fewsjdbc
    def read(self, request,
             jdbc_source_slug, filter_id, parameter_id, location_id):
        safe_filter_id = filter_id
        filter_id = urllib.unquote(filter_id)
        safe_parameter_id = parameter_id
        parameter_id = urllib.unquote(parameter_id)
        safe_location_id = location_id
        location_id = urllib.unquote(location_id)
        result = {}
        result['info'] = documentation(self.__class__)

        alternative_representations = []
        for format in ('csv', 'png', 'html'):
            url = request.build_absolute_uri(
                reverse(
                    TIMESERIE_URL_NAME + '_' + format,
                    kwargs={'jdbc_source_slug': jdbc_source_slug,
                            'filter_id': safe_filter_id,
                            'parameter_id': safe_parameter_id,
                            'location_id': safe_location_id}))
            alternative_representations.append(
                {'url': url,
                 'format': format})
        result['alternative_representations'] = alternative_representations

        jdbc_source = JdbcSource.objects.get(slug=jdbc_source_slug)
        start_date, end_date = start_end_dates(request)
        data = jdbc_source.get_timeseries(
            filter_id, location_id, parameter_id,
            start_date, end_date)
        if not data:
            response = rc.NOT_FOUND
            response.write(
                "No data found for this filter/parameter/location combination")
            return response
        result['data'] = data

        # TODO: fix this parameter_name, get_parameter_name does not exist

        # result['parameter_name'] = jdbc_source.get_parameter_name(
        # parameter_id)

        result['parameter_name'] = parameter_id
        # ^^^ Not sure this is a great place to set this, but we need it for
        # now.

        return result
コード例 #4
0
ファイル: handlers.py プロジェクト: bugkiwi/lizard-fewsjdbc
 def read(self, request, jdbc_source_slug, filter_id):
     safe_filter_id = filter_id
     filter_id = urllib.unquote(filter_id)
     result = {}
     result['info'] = documentation(self.__class__)
     jdbc_source = JdbcSource.objects.get(slug=jdbc_source_slug)
     data = []
     for parameter in jdbc_source.get_named_parameters(
         filter_id):
         safe_parameter_id = urllib.quote(parameter['parameterid'], '')
         url = request.build_absolute_uri(
             reverse(
                 LOCATION_URL_NAME,
                 kwargs={'jdbc_source_slug': jdbc_source_slug,
                         'filter_id': safe_filter_id,
                         'parameter_id': safe_parameter_id}))
         data.append({'title': parameter['parameter'],
                      'url': url})
     result['data'] = data
     return result
コード例 #5
0
ファイル: handlers.py プロジェクト: bugkiwi/lizard-fewsjdbc
 def read(self, request, jdbc_source_slug, filter_id, parameter_id):
     safe_filter_id = filter_id
     filter_id = urllib.unquote(filter_id)
     safe_parameter_id = parameter_id
     parameter_id = urllib.unquote(parameter_id)
     result = {}
     result['info'] = documentation(self.__class__)
     jdbc_source = JdbcSource.objects.get(slug=jdbc_source_slug)
     data = []
     for location in jdbc_source.get_locations(filter_id, parameter_id):
         safe_location_id = urllib.quote(location['locationid'], '')
          # TODO: add geojson coordinates!!!
         url = request.build_absolute_uri(
             reverse(
                 TIMESERIE_URL_NAME,
                 kwargs={'jdbc_source_slug': jdbc_source_slug,
                         'filter_id': safe_filter_id,
                         'parameter_id': safe_parameter_id,
                         'location_id': safe_location_id}))
         data.append({'title': location['location'],
                      'url': url})
     result['data'] = data
     return result