def update_student_schema(): content = request.get_json() count = 0 for k, v in content.items(): if k in student_schema.keys(): student_schema[k] = v count += 1 else: logging.error(k + ' does not exists in student schema, can not update it') # update the schema in mongodb result = util.update_eve_setting('student', student_schema) stop_eve_process() time.sleep(0.1) start_eve_process() return Response('{"_status": "SUCCESS", "_success": {"message": "'+str(count)+' column(s) updated", "code": 200}}', mimetype='application/json', status=200)
def delete_student_schema(): #check if attribute is in student schema content = request.get_json() count = 0 for k in content: if k in student_schema.keys(): del student_schema[k] count = count + 1 else: logging.error(k + ' does not exists in student schema, can not delete it') result = util.update_eve_setting("student", student_schema) #restart eve service to load new schema settings stop_eve_process() time.sleep(0.1) start_eve_process() return Response('{"_status": "SUCCESS", "_success": {"message": "'+str(count)+' column(s) deleted", "code": 200}}', mimetype = 'application/json', status = 200)