コード例 #1
0
ファイル: libtrips.py プロジェクト: almet/bv.libclient
    def search_trip(self, **kwargs):
        """May be triggered by an AJAX call.
        kwargs contains json info to unpack
        But : it may not contain the "route" information which will trigger a bug
        """
        temp_results = self._search_trip(**kwargs)
        object = Trip

        return_dict = {}
        for key, value in temp_results.items():
            if key in ('trip_demands', 'trip_offers'):
                if value:
                    realvalue = [dict_to_object_func(dict, object) for dict in value]
                else:
                    realvalue = []
            elif key == 'trip':
                realvalue = dict_to_object_func(value, object)
            return_dict[key] = realvalue
        return return_dict
コード例 #2
0
ファイル: libtrips.py プロジェクト: almet/bv.libclient
 def edit_trip(self, trip_id, **kwargs):
     """Send new informations about the trip to the API, and return the right
     response/error.
     
     """
     kwargs = self._transform_dows(kwargs)
     response = self.get_resource('trip').put(path='%s/' % trip_id, **kwargs)
     if response.status_int == 200:
         return dict_to_object_func(json.loads(response.body_string()), Trip)
     else:
         raise EditTripFormError(json.loads(response.body_string()))