Skip to content
Snippets Groups Projects
Commit dee07866 authored by radvalig's avatar radvalig
Browse files

fixed retrival of all items

parent 393f4e88
No related branches found
No related tags found
1 merge request!4Authentication with jwt
Pipeline #14716 failed
......@@ -105,7 +105,7 @@ api = Api(flask_app)
jwt = JWTManager(flask_app)
# added auction item resource
api.add_resource(items.AuctionItem, "/auction_item/<id>")
api.add_resource(items.AuctionItem, "/auction_item/", "/auction_item/<id>")
@flask_app.route("/server-info")
......
......@@ -14,20 +14,29 @@ ITEM_ENDPOINT : str = r"/auction_item"
logger = logging.getLogger(__name__)
class AuctionItem (Resource):
"""Auction item class that will for handling this object
"""Auction item class used to represent resource, and create GET, POST calls
Args:
Resource (_type_): _description_
"""
@jwt_required
#@jwt_required
def get(self, id = None):
"""GET method
Args:
id (str, optional): id for specif item, if it is not provided it will return all items. Defaults to None.
Returns:
json: json representation of item objects
"""
#current_user = get_jwt_identity()
item = items.Item()
if not id:
logger.info("retriving item without id!")
logger.info("retriving all items!")
query_result = item.get_all()
temp = json.dumps(query_result, default=str)
item_from_db = [item_from_db for item_from_db in query_result]
temp = json.dumps(item_from_db, default=str)
return temp
logger.info(f"Trying to retrive a item with id: {id}")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment