def add_freetext(): if not is_logged_in(): return 'User is not logged in; creator_id is not set' if not is_current_session_set(): return 'Current session is not set' db = Database() value = request.data.decode() category_id = db.get_category_id_by_name("FREETEXT") db.add_entry_with_category(get_current_session_id(), get_current_user_id(), category_id, value) return "OK"
def add_event(): if not is_logged_in(): return 'User is not logged in; creator_id is not set' if not is_current_session_set(): return 'Current session is not set' data = request.data.decode() category = data[data.index('=') + 1:data.index('\n')] data = data[data.index('\n') + 1:] db = Database() if category.upper() == "ALERT": logging.info("ALERT posted") db.add_alert(get_current_session_id(), get_current_user_id(), data) else: logging.info("EVENT posted") db.add_entry_with_category(get_current_session_id(), get_current_user_id(), db.get_category_id_by_name(category), data) return 'OK'