|
|
|
@ -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 |
|
|
|
|
from .froms import ProjectForm, LoginForm, RegistrationForm |
|
|
|
|
|
|
|
|
|
@app.route('/', methods=['GET', 'POST']) |
|
|
|
|
@app.route('/index', methods=['GET', 'POST']) |
|
|
|
@ -59,14 +59,40 @@ def public_projects():
@@ -59,14 +59,40 @@ def public_projects():
|
|
|
|
|
@app.route('/project/add', methods=['GET', 'POST']) |
|
|
|
|
@login_required |
|
|
|
|
def project_add(): |
|
|
|
|
form = NewProjectForm() |
|
|
|
|
project = Project(name='') |
|
|
|
|
form = ProjectForm() |
|
|
|
|
if form.validate_on_submit(): |
|
|
|
|
project = Project(name=form.projectname.data) |
|
|
|
|
project.access['owners'] = [current_user.name] |
|
|
|
|
project = Project(name=form.projectname.data, git_repo=form.git_repo.data) |
|
|
|
|
project.access['public'] = form.public.data |
|
|
|
|
if project.access['owners'] == []: |
|
|
|
|
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) |
|
|
|
|
return render_template('project_settings.html', form=form, project=project) |
|
|
|
|
|
|
|
|
|
@app.route('/project/<project_name>/settings', methods=['GET', 'POST']) |
|
|
|
|
@login_required |
|
|
|
|
def project_change_settings(project_name): |
|
|
|
|
project = Project.first_or_404(name=project_name) |
|
|
|
|
if project.user_access(current_user) != 'Owner': |
|
|
|
|
abort(401) |
|
|
|
|
form = ProjectForm() |
|
|
|
|
form.old_name = project.name |
|
|
|
|
if request.method == 'GET': |
|
|
|
|
# pylint: disable=no-member |
|
|
|
|
form.process() |
|
|
|
|
form.public.data = project.access.get('public', False) |
|
|
|
|
if form.validate_on_submit(): |
|
|
|
|
project = Project(name=form.projectname.data, git_repo=form.git_repo.data) |
|
|
|
|
project.access['public'] = form.public.data |
|
|
|
|
if project.access['owners'] == []: |
|
|
|
|
project.access['owners'] = [current_user.name] |
|
|
|
|
project.save() |
|
|
|
|
flash(f"{project.name} was updated!", 'success') |
|
|
|
|
return redirect(url_for('project_dashboard', project_name=project.name)) |
|
|
|
|
|
|
|
|
|
return render_template('project_settings.html', form=form, project=project) |
|
|
|
|
|
|
|
|
|
@app.route('/project/<project_name>', methods=['GET']) |
|
|
|
|
def project_dashboard(project_name): |
|
|
|
|