Esempio n. 1
0
def create_project():
    form = StartProjectForm()

    if form.validate_on_submit():

        if Project.find_by_title(form.title.data, current_user.user_id) == None:
            project = Project(title = form.title.data,
                description = form.description.data, user_id = current_user.user_id)
            project.save_to_db()
            return redirect(url_for("projects.overview", title=project.title))
    return render_template("projects/create.html", form=form, action="create")
Esempio n. 2
0
def add_project_comment(project_title):
    form = AddCommentForm()

    if form.validate_on_submit():
        project = Project.find_by_title(project_title, current_user.user_id)
        comment = ProjectComment(project.project_id, current_user.user_id,
                                 form.comment.data)
        comment.save_to_db()
        return redirect(url_for("projects.overview", title=project_title))

    return render_template("comments/add.html",
                           form=form,
                           title=project_title,
                           action="create")
Esempio n. 3
0
def update(title):
    form = StartProjectForm()
    form.submit.label.text = "Update"
    project = Project.find_by_title(title, current_user.user_id)

    if form.validate_on_submit():
        project.title = form.title.data
        project.description = form.description.data
        project.save_to_db()
        return redirect(url_for("projects.overview", title=project.title))
    elif request.method == "GET":
        form.title.data = title
        form.description.data = project.description

    return render_template("projects/create.html", form=form, action="update")
Esempio n. 4
0
    def test_project(self):
        self.create_user(user_name="testuser",
                         email="*****@*****.**",
                         password="******")
        user = User.query.filter_by(user_name="testuser").first()
        self.create_project(title="test_project",
                            description="A test project",
                            user_id=user.get_id())
        self.create_project(title="test_project2",
                            description="Another test project",
                            user_id=user.get_id())

        project = Project.find_by_title("test_project", 1)
        self.assertEquals(project.project_id, 1)
        self.assertEquals(project.description, "A test project")
        self.assertEquals(project.status_id, 1)
Esempio n. 5
0
def add_task(project_title):
    form = AddTaskForm()

    if form.validate_on_submit():

        if Task.find_by_title(form.title.data, current_user.user_id) == None:
            project = Project.find_by_title(project_title,
                                            current_user.user_id)
            task = Task(title=form.title.data,
                        description=form.description.data,
                        project_id=project.project_id,
                        user_id=current_user.user_id)
            task.save_to_db()

        return redirect(url_for("tasks.overview", title=task.title))

    return render_template("tasks/add.html",
                           form=form,
                           project_title=project_title,
                           action="create")
Esempio n. 6
0
def delete(title):
    project = Project.find_by_title(title, current_user.user_id)
    project.delete()
    return redirect(url_for("users.home"))
Esempio n. 7
0
def overview(title):
    project = Project.find_by_title(title, current_user.user_id)
    return render_template("projects/overview.html", project=project)