def update_file_data(): try: req_data = request.get_json() user_id = ObjectId(str(req_data['user_id'])) file_id = ObjectId(str(req_data['file_id'])) name = req_data['name'] email = req_data['email'] mobile = req_data['mobile'] skills = req_data['skills'] qualifications = req_data['qualifications'] is_active = req_data['is_active'] user = validate_user(user_id) if user is None: response = {"status": "error", "message": "User doesn't exist"} return json.dumps(response) file_doc = CATALOG_FILES_COL.find_one({"_id": file_id}) if not file_doc: response = {"status": "error", "message": "Record doesn't exist"} return json.dumps(response) file_catalog = USER_CATALOGS_COL.find_one({"_id": file_doc["catalog"]}) if not file_catalog: response = { "status": "error", "message": "File catalog doesn't exist" } return json.dumps(response) if file_catalog["user"] != user["_id"]: response = { "status": "error", "message": "You are not authorized to update this record." } return json.dumps(response) CATALOG_FILES_COL.update_one({"_id": file_doc["_id"]}, { "$set": { "Name": name, "Email_Address": email, "Mobile_No": mobile, "Skills": skills, "Degree": qualifications, "is_active": is_active, "is_manually_updated": True } }) response = { "status": "success", "message": "Record updated successfully." } except Exception as err: response = { "status": "error", "message": "Unable to process request.", 'error': str(err) } return json.dumps(response)
def update_file(up_file_doc): CATALOG_FILES_COL.update_one({"_id": up_file_doc["_id"]}, {'$set': {'is_entity_extracted': False}}) return up_file_doc