Example #1
0
 def get(self, request, *args, **kwargs):
     """
     :return: json
     """
     save_to_database()
     response = {}
     if 'travel_type' in kwargs:
         # If travel type exists return only average co2 produce
         travel_type = travel_types.get(kwargs['travel_type'])
         if travel_type is not None:
             response = travel_types.get(kwargs['travel_type'])
     else:
         response = json.dumps(travel_types)
     print 'Getting travel types'
     return HttpResponse(response, content_type="application/json")
Example #2
0
 def get(self, request, *args, **kwargs):
     """
     :return: json
     """
     save_to_database()
     response = {}
     if 'travel_type' in kwargs:
         # If travel type exists return only average co2 produce
         travel_type = travel_types.get(kwargs['travel_type'])
         if travel_type is not None:
             response = travel_types.get(kwargs['travel_type'])
     else:
         response = json.dumps(travel_types)
     print 'Getting travel types'
     return HttpResponse(response, content_type="application/json")
Example #3
0
    def get(self, request, *args, **kwargs):
        """
        :return: json
        """
        save_to_database()
        response = {}
        if 'travel_type' in kwargs:
            # If travel type exists return only average co2 produce
            travel_type = TravelType.all().filter('name', kwargs['travel_type'].capitalize())
            if travel_type.count() > 0:
                response = to_dict(travel_type.get())
        else:
            for travel_type in TravelType.all():
                response[travel_type.name] = travel_type.co2_exhausts

        logging.info('Getting travel types')
        return HttpResponse(json.dumps(response), content_type="application/json")
Example #4
0
    def get(self, request, *args, **kwargs):
        """
        :return: json
        """
        save_to_database()
        response = {}
        if 'travel_type' in kwargs:
            # If travel type exists return only average co2 produce
            travel_type = TravelType.all().filter(
                'name', kwargs['travel_type'].capitalize())
            if travel_type.count() > 0:
                response = to_dict(travel_type.get())
        else:
            for travel_type in TravelType.all():
                response[travel_type.name] = travel_type.co2_exhausts

        logging.info('Getting travel types')
        return HttpResponse(json.dumps(response),
                            content_type="application/json")