def delete_project(pid): """ Delete the specified project. """ pdb = database.ProjectDatabase() project = pdb.delete_project(pid) return flask.redirect(flask.url_for('projects'))
def get_project_db(pid): """ Get our project database. """ pdb = database.ProjectDatabase() project = pdb.get_project(pid) if project is None: flask.abort(404) return project
def project_notes(pid): """ Display all project notes. """ pdb = database.ProjectDatabase() project = get_project_db(pid) if flask.request.method == 'POST': note = flask.request.form['note'] pdb.update_project_note(pid, note) return flask.redirect(flask.url_for('get_project', pid=pid)) else: return flask.render_template('project_notes.html', pid=pid, name=project['name'], note=project['note'])
def projects(): """ Get a list of all projects. """ pdb = database.ProjectDatabase() stats = {} if flask.request.method == 'POST': name = flask.request.form['project_name'] pdb.create_project(name) project_list = pdb.get_projects() for project in project_list: db = database.ScanDatabase(project['dbfile']) stats[project['id']] = db.get_stats() return flask.render_template('projects.html', projects=project_list, stats=stats)