def update_ticket(ticket_id): """Update a specific ticket.""" ticket_data = request.get_json() user_by_id = None response = None # get ticket by id ticket_by_id = TicketController.get_ticket_by_id(ticket_id) # check if there is assignee key provided in request if "ticket_assignee" in ticket_data: user_by_id = UserController.get_users_by_id( ticket_data["ticket_assignee"]) if user_by_id is None: return (error_response(404, "Resource Not Found") ) # return not found response if wrong user provided # check if ticket was found and update accordingly if ticket_by_id: TicketController.update_ticket(ticket_by_id, ticket_data, user_by_id) response = success_response_body(ticket_data) else: # return no user error response = error_response(404, "Resource Not Found") return response
def update_ticket(ticket_id): """Update a ticket.""" ticket_data = request.get_json() put_ticket = TicketController.update_ticket(ticket_id, ticket_data) return jsonify(put_ticket)