예제 #1
0
파일: timers.py 프로젝트: exler/moonmen
def delete(timer_id):
    query_db("DELETE FROM timers WHERE id = ? AND instance_id = ?",
             [timer_id, session["instance_id"]],
             commit=True)
    flash("Timer deleted successfully")

    return redirect(url_for("timers.index"))
예제 #2
0
파일: files.py 프로젝트: exler/moonmen
def delete(file_id):
    file = query_db("SELECT path FROM files WHERE id = ? AND instance_id = ?",
                    [file_id, session["instance_id"]])[0]
    os.remove(get_upload_path(file["path"]))
    query_db("DELETE FROM files WHERE id = ? AND instance_id = ?",
             [file_id, session["instance_id"]],
             commit=True)
    flash("File deleted successfully")

    return redirect(url_for("files.index"))
예제 #3
0
파일: timers.py 프로젝트: exler/moonmen
def add():
    timer_name = request.form.get("name")
    timer_dt = request.form.get("dt")

    query_db(
        "INSERT INTO timers (name, dt, instance_id) VALUES (?, ?, ?)",
        [timer_name, timer_dt, session["instance_id"]],
        commit=True,
    )
    flash("Timer added successfully")

    return redirect(url_for("timers.index"))
예제 #4
0
파일: timers.py 프로젝트: exler/moonmen
def edit(timer_id):
    timer_name = request.form.get("name")
    timer_dt = request.form.get("dt")

    query_db(
        "UPDATE timers SET name = ?, dt = ? WHERE id = ? AND instance_id = ?",
        [timer_name, timer_dt, timer_id, session["instance_id"]],
        commit=True,
    )
    flash("Timer updated successfully")

    return redirect(url_for("timers.index"))
예제 #5
0
def edit(note_id):
    note_title = request.form.get("title")
    note_content = request.form.get("content")
    note_language = request.form.get("language")

    query_db(
        "UPDATE notes SET title = ?, content = ?, language = ? WHERE id = ? AND instance_id = ?",
        [note_title, note_content, note_language, note_id, session["instance_id"]],
        commit=True,
    )
    flash("Note updated successfully")

    return redirect(url_for("notes.index"))
예제 #6
0
def add():
    note_title = request.form.get("title")
    note_content = request.form.get("content")
    note_language = request.form.get("language")

    query_db(
        "INSERT INTO notes (title, content, language, instance_id) VALUES (?, ?, ?, ?)",
        [note_title, note_content, note_language, session["instance_id"]],
        commit=True,
    )
    flash("Note added successfully")

    return redirect(url_for("notes.index"))
예제 #7
0
파일: tasks.py 프로젝트: exler/moonmen
def edit(task_id):
    task_title = request.form.get("title")
    task_description = request.form.get("description")
    task_status = request.form.get("status")

    query_db(
        "UPDATE tasks SET title = ?, description = ?, status = ? WHERE id = ? AND instance_id = ?",
        [task_title, task_description, task_status, task_id, session["instance_id"]],
        commit=True,
    )
    flash("Task updated successfully")

    return redirect(url_for("tasks.index"))
예제 #8
0
파일: tasks.py 프로젝트: exler/moonmen
def add():
    task_title = request.form.get("title")
    task_description = request.form.get("description")
    task_status = request.form.get("status")

    query_db(
        "INSERT INTO tasks (title, description, status, instance_id) VALUES (?, ?, ?, ?)",
        [task_title, task_description, task_status, session["instance_id"]],
        commit=True,
    )
    flash("Task added successfully")

    return redirect(url_for("tasks.index"))
예제 #9
0
파일: files.py 프로젝트: exler/moonmen
def download(file_id):
    f = query_db(
        "SELECT name, path FROM files WHERE id = ? AND instance_id = ?",
        [file_id, session["instance_id"]])[0]
    return send_file(get_upload_path(f["path"]),
                     download_name=f["name"],
                     as_attachment=True)
예제 #10
0
파일: auth.py 프로젝트: exler/moonmen
def login():
    if request.method == "POST":
        instance_name = request.form.get("instance")
        instance_password = request.form.get("password")

        instance = query_db(
            "SELECT id, password FROM instances WHERE name = ?",
            [instance_name])

        if not instance:
            flash("No instance with given name")
        else:
            instance = instance[0]
            if check_password_hash(instance["password"], instance_password):
                session["instance_id"] = instance["id"]
                session["instance_name"] = instance_name
            else:
                flash("Wrong password")

        return redirect(url_for("index"))
    else:
        if "instance_id" in session:
            return redirect(url_for("index"))
        else:
            return render_template("auth/login.html")
예제 #11
0
def index():
    notes = query_db("SELECT id, title, content, language FROM notes WHERE instance_id = ?", [session["instance_id"]])

    return render_template(
        "notes.html",
        notes=notes,
    )
예제 #12
0
파일: commands.py 프로젝트: exler/moonmen
def init_project(project_name):
    click.echo(click.style(HEADER, fg="yellow"))
    click.echo(click.style(f"(!) Initializing project '{project_name}'", fg="yellow"))
    try:
        project_desc = input("description: ")
        project_repo = input("repository: ")
        project_password = getpass.getpass("password: "******"INSERT INTO instances (name, password, description, repository) VALUES (?, ?, ?, ?)",
            [project_name, project_password, project_desc, project_repo],
            commit=True,
        )

        click.echo(click.style("\n(!) Project details saved", fg="blue"))
    except KeyboardInterrupt:
        click.echo(click.style("\n(!) Project initialization canceled", fg="red"))
예제 #13
0
파일: dashboard.py 프로젝트: exler/moonmen
def index():
    instance_id = session["instance_id"]
    instance = query_db(
        "SELECT description, repository FROM instances WHERE id = ?",
        [instance_id])[0]

    return render_template("dashboard.html",
                           instance_desc=instance["description"],
                           instance_repo=instance["repository"])
예제 #14
0
파일: files.py 프로젝트: exler/moonmen
def upload():
    file = request.files["file"]

    if file and allowed_file(file.filename):
        filename = secure_filename(file.filename)
        path = uuid.uuid4().hex

        query_db(
            "INSERT INTO files (name, path, instance_id) VALUES (?, ?, ?)",
            [filename, path, session["instance_id"]],
            commit=True,
        )

        file.save(get_upload_path(path))

        flash("File uploaded successfully")
    else:
        flash("Wrong filetype!")

    return redirect(url_for("files.index"))
예제 #15
0
파일: auth.py 프로젝트: exler/moonmen
def change_password():
    if request.method == "POST":
        old_password = request.form.get("old_password", "")
        new_password = request.form.get("new_password", "")
        new_password_confirmation = request.form.get(
            "new_password_confirmation", "")

        instance = query_db("SELECT password FROM instances WHERE id = ?",
                            [session["instance_id"]])[0]

        if not check_password_hash(instance["password"], old_password):
            flash("Old password is not valid")
        elif new_password != new_password_confirmation:
            flash("Password confirmation does not match the new password")
        elif new_password == old_password:
            flash("New password cannot be the same as old password")
        else:
            query_db("UPDATE instances SET password = ?",
                     [generate_password_hash(new_password)],
                     commit=True)
            flash("Password changed successfully")
            return redirect(url_for("index"))

    return render_template("auth/change_password.html")
예제 #16
0
def delete(note_id):
    query_db("DELETE FROM notes WHERE id = ? AND instance_id = ?", [note_id, session["instance_id"]], commit=True)
    flash("Note deleted successfully")

    return redirect(url_for("notes.index"))
예제 #17
0
파일: files.py 프로젝트: exler/moonmen
def index():
    files = query_db("SELECT id, name FROM files WHERE instance_id = ?",
                     [session["instance_id"]])

    return render_template("files.html", files=files)
예제 #18
0
파일: timers.py 프로젝트: exler/moonmen
def index():
    timers = query_db("SELECT id, name, dt FROM timers WHERE instance_id = ?",
                      [session["instance_id"]])

    return render_template("timers.html", timers=timers)
예제 #19
0
파일: tasks.py 프로젝트: exler/moonmen
def index():
    tasks = query_db("SELECT id, title, description, status FROM tasks WHERE instance_id = ?", [session["instance_id"]])

    return render_template("tasks.html", tasks=tasks, statuses=TaskStatus.get_choices())