def delete_project(id): project = UserProjects.get_project(id) if not project: abort(404) try: UserProjects.delete_project(project) except: flash("Error when deleting project") return redirect(url_for("account", user=session["user"])) return redirect(url_for("account", username=session["user"]))
def test_deleting_adn_updating_projects(self): with test_database(db, (Users, UserProjects)): user1 = Users.create_user("konrad", "test") UserProjects.create_project(title = "test project", body = "test", author = user1) project = UserProjects.get_project(1) UserProjects.update_project(project, "changed", "changed") project = UserProjects.get_project(1) self.assertEquals("changed", project.title) self.assertEquals("changed", project.body) UserProjects.delete_project(project) self.assertEquals(0, UserProjects.select().count())