def add_to_project(username, projectname): user = User.get_user_by_username(username) if user is None: return redirect(url_for('error.not_found_error')) project = Project.get_project_by_name(projectname) if project is None: return redirect(url_for('error.not_found_error')) user_projects = Project.get_projects_where_username_is_manager( current_user.username) form = AddToProjectForm() form.project.choices = [(project.id, project.name) \ for project in user_projects] if form.validate_on_submit(): Project.add_user_to_project(user.id, project.id) return redirect(url_for('user.profile', user=user)) return render_template('user/add_to_project.html', title='Edit', form=form)