def post(self, code_list, code): if IcdModel.find_by_list_and_code(code_list, code): return {'message': "A '{}' code already exists in list '{}'.".format(code, code_list)}, 400 data = Icd.parser.parse_args() entry = IcdModel(code_list, code, data['description']) try: entry.save_to_db() except: return {'message': "Something we wrong inserting the code."}, 500 return entry.json(), 201
def put(self, code_list, code): entry = IcdModel.find_by_list_and_code(code_list, code) data = Icd.parser.parse_args() if entry: entry.description = data['description'] else: entry = IcdModel(code_list, code, data['description']) try: entry.save_to_db() except: return {'message': "Something we wrong inserting the code."}, 500 return entry.json(), 201