def delete(self, id): if security.can_modify(request.cookies.get("user")): find_id = security.getObjectId(id) if find_id: model.Deck.find_one({"_id": find_id}).delete() else: abort(403)
def post(self): if security.can_modify(request.cookies.get("user")): try: new_deck = model.Deck(**request.get_json().get("deck")) new_deck.commit() return jsonify(new_deck.dump()) except marshmallow.exceptions.ValidationError as e: abort(400) else: abort(403)
def put(self, id): if security.can_modify(request.cookies.get("user")): find_id = security.getObjectId(id) if find_id: new_deck = request.get_json().get("deck") if new_deck: try: old_deck_obj = model.Deck.find_one({"_id": find_id}) old_deck_obj.update(new_deck) old_deck_obj.commit() return (old_deck_obj.dump()) except marshmallow.exceptions.ValidationError as e: abort(400) abort(403)