|
|
|
@ -4,7 +4,7 @@ from werkzeug.urls import url_parse
@@ -4,7 +4,7 @@ from werkzeug.urls import url_parse
|
|
|
|
|
from biscd import app |
|
|
|
|
from .utils import flash_result |
|
|
|
|
from .models import Project, User |
|
|
|
|
from .froms import NewProjectForm, LoginForm, RegistrationForm, EmptyForm |
|
|
|
|
from .froms import NewProjectForm, LoginForm, RegistrationForm |
|
|
|
|
|
|
|
|
|
@app.route('/', methods=['GET', 'POST']) |
|
|
|
|
@app.route('/index', methods=['GET', 'POST']) |
|
|
|
@ -47,16 +47,34 @@ def register():
@@ -47,16 +47,34 @@ def register():
|
|
|
|
|
user = User(name=form.username.data, email=form.email.data) |
|
|
|
|
user.set_password(form.password.data) |
|
|
|
|
user.save() |
|
|
|
|
flash('Congratulations, you are now a registered user!', 'info') |
|
|
|
|
flash('Congratulations, you are now a registered user!', 'success') |
|
|
|
|
return redirect(url_for('login')) |
|
|
|
|
return render_template('register.html', title='Register', form=form) |
|
|
|
|
|
|
|
|
|
@app.route('/project/public', methods=['GET']) |
|
|
|
|
def public_projects(): |
|
|
|
|
projects = Project.get(access__public = True) |
|
|
|
|
return render_template('projects.html', projects=projects) |
|
|
|
|
|
|
|
|
|
@app.route('/project/<project_name>', methods=['GET']) |
|
|
|
|
@app.route('/project/add', methods=['GET', 'POST']) |
|
|
|
|
@login_required |
|
|
|
|
def project_add(): |
|
|
|
|
form = NewProjectForm() |
|
|
|
|
if form.validate_on_submit(): |
|
|
|
|
project = Project(name=form.projectname.data) |
|
|
|
|
project.access['owners'] = [current_user.name] |
|
|
|
|
project.save() |
|
|
|
|
flash('Your project is created!', 'success') |
|
|
|
|
return redirect(url_for('project_dashboard', project_name=project.name)) |
|
|
|
|
return render_template('project_add.html', form=form) |
|
|
|
|
|
|
|
|
|
@app.route('/project/<project_name>', methods=['GET']) |
|
|
|
|
def project_dashboard(project_name): |
|
|
|
|
project = Project.first_or_404(name=project_name) |
|
|
|
|
return render_template('project.html', project=project) |
|
|
|
|
access = project.user_access(current_user) |
|
|
|
|
if access is None: |
|
|
|
|
abort(404) |
|
|
|
|
return render_template('project.html', project=project, owner=(access == 'Owner')) |
|
|
|
|
|
|
|
|
|
@app.route('/project/<project_name>/update', methods=['GET']) |
|
|
|
|
@login_required |
|
|
|
|