Пример #1
0
def files_build(name, id, path = ""):
    project = models.Project.get(name = name)
    build = models.Build.get(project = name, id = id)

    file_path = build.get_file_path(path)
    is_directory = os.path.isdir(file_path)
    if not is_directory: return flask.send_file(file_path)

    if path and not path.endswith("/"):
        return flask.redirect(
            flask.url_for(
                "files_build", name = name, id = id, path = path + "/"
            )
        )

    files = build.get_files(path)
    return flask.render_template(
        "build_files.html.tpl",
        link = "projects",
        sub_link = "files",
        project = project,
        build = build,
        path = path,
        files = files
    )
Пример #2
0
def run_project(name):
    # retrieves the "custom" run function to be used
    # as the work "callable", note that the schedule flag
    # is not set meaning that no schedule will be done
    # after the execution
    project = models.Project.get(name=name)
    _run = project.get_run(schedule=False)

    # starts the running of the run method in a background
    # fashion (another thread) so that no blocking occurs
    quorum.run_back(_run)

    return flask.redirect(flask.url_for("show_project", name=name))
Пример #3
0
def create_project():
    # creates the new project, using the provided arguments and
    # then saves it into the data source, all the validations
    # should be ran upon the save operation
    project = models.Project.new()
    try:
        project.save()
    except quorum.ValidationError as error:
        return flask.render_template("project_new.html.tpl",
                                     link="new project",
                                     project=error.model,
                                     errors=error.errors)

    return flask.redirect(flask.url_for("show_project", name=project.name))
Пример #4
0
def run_project(name):
    # retrieves the "custom" run function to be used
    # as the work "callable", note that the schedule flag
    # is not set meaning that no schedule will be done
    # after the execution
    project = models.Project.get(name = name)
    _run = project.get_run(schedule = False)

    # starts the running of the run method in a background
    # fashion (another thread) so that no blocking occurs
    quorum.run_back(_run)

    return flask.redirect(
        flask.url_for("show_project", name = name)
    )
Пример #5
0
def create_project():
    # creates the new project, using the provided arguments and
    # then saves it into the data source, all the validations
    # should be ran upon the save operation
    project = models.Project.new()
    try: project.save()
    except quorum.ValidationError as error:
        return flask.render_template(
            "project_new.html.tpl",
            link = "new project",
            project = error.model,
            errors = error.errors
        )

    return flask.redirect(
        flask.url_for("show_project", name = project.name)
    )
Пример #6
0
def update_project(name):
    # finds the current project and applies the provided
    # arguments and then saves it into the data source,
    # all the validations should be ran upon the save operation
    project = models.Project.get(name=name)
    project.apply()
    try:
        project.save()
    except quorum.ValidationError as error:
        return flask.render_template("project_edit.html.tpl",
                                     link="projects",
                                     sub_link="edit",
                                     project=error.model,
                                     errors=error.errors)

    # redirects the user to the show page of the project that
    # was just updated
    return flask.redirect(flask.url_for("show_project", name=name))
Пример #7
0
def files_build(name, id, path=""):
    project = models.Project.get(name=name)
    build = models.Build.get(project=name, id=id)

    file_path = build.get_file_path(path)
    is_directory = os.path.isdir(file_path)
    if not is_directory: return flask.send_file(file_path)

    if path and not path.endswith("/"):
        return flask.redirect(
            flask.url_for("files_build", name=name, id=id, path=path + "/"))

    files = build.get_files(path)
    return flask.render_template("build_files.html.tpl",
                                 link="projects",
                                 sub_link="files",
                                 project=project,
                                 build=build,
                                 path=path,
                                 files=files)
Пример #8
0
def update_project(name):
    # finds the current project and applies the provided
    # arguments and then saves it into the data source,
    # all the validations should be ran upon the save operation
    project = models.Project.get(name = name)
    project.apply()
    try: project.save()
    except quorum.ValidationError as error:
        return flask.render_template(
            "project_edit.html.tpl",
            link = "projects",
            sub_link = "edit",
            project = error.model,
            errors = error.errors
        )

    # redirects the user to the show page of the project that
    # was just updated
    return flask.redirect(
        flask.url_for("show_project", name = name)
    )
Пример #9
0
def delete_project(name):
    project = models.Project.get(name = name)
    project.delete()
    return flask.redirect(
        flask.url_for("list_projects")
    )
Пример #10
0
def delete_build(name, id):
    build = models.Build.get(project = name, id = id)
    build.delete()
    return flask.redirect(
        flask.url_for("list_builds", name = name)
    )
Пример #11
0
def delete_project(name):
    project = models.Project.get(name=name)
    project.delete()
    return flask.redirect(flask.url_for("list_projects"))
Пример #12
0
def delete_build(name, id):
    build = models.Build.get(project=name, id=id)
    build.delete()
    return flask.redirect(flask.url_for("list_builds", name=name))