Beispiel #1
0
def delete_content(update, context):

    log_id = context.user_data.get("log_id")
    conn = create_connection()
    work_content_id = select_record(
        conn, "logbook", ["work_content_id"], {"id": log_id}
    )[0][0]
    update_record(conn, "logbook", {"work_content_id": ""}, log_id)
    delete_record(conn, "contents", {"id": work_content_id})
    return log_id
Beispiel #2
0
def remove_log(update, context):
    choices = {"YES": True, "NO": False}
    answer = choices.get(update.message.text)
    if answer:
        log_id = context.user_data.get("remove_log_id")

        conn = create_connection()
        delete_record(conn, "logbook", {"id": log_id})
        conn.close()

        text_message = f"Log No.{log_id} has been Deleted\n"
        reply_markdown(update, context, text_message)
        context.user_data.clear()
    else:
        text_message = "process has been stoped. The log has not been deleted."
        reply_markdown(update, context, text_message)
    return ConversationHandler.END
Beispiel #3
0
def override_log_and_ask_work_type(update, context):

    choices = {"REMOVE SIGN IN LOG": True, "NO": False}
    answer = choices.get(update.message.text)
    if answer:
        log_id = context.user_data.get("log_id")
        conn = create_connection()
        delete_record(conn, "logbook", {"id": log_id})
        conn.close()

        text_message = f"Log No. {log_id} has been Deleted\n"
        reply_markdown(update, context, text_message)
    else:
        text_message = "process has been stoped. The log has not been deleted."
        reply_markdown(update, context, text_message)
        return ConversationHandler.END

    log_id = post_basic_user_data(update, context, "signing in")
    context.user_data["log_id"] = log_id
    return ask_sub_category(update, context)