def join_code(): project_name = request.form.get('project_name') join_code = request.form.get('join_code') if not DBProxy.verify_join_code(project_name, join_code): flash('invalid project name or join code', 'warning') return redirect(url_for('dashboard')) email = get_email_from_request() DBProxy.add_user_to_project(email, project_name=project_name) flash(f'added project {project_name}', 'success') return redirect(url_for('dashboard'))
def is_in_admin_file(email): with open(ADMIN_PATH, mode='r') as f: admins = f.read().split('\n') adminBool = False for admin in admins: if admin == email: adminBool = True break if adminBool: for project in DBProxy.get_all_projects(): DBProxy.add_user_to_project(email, project.id) return adminBool
def add_project(): # Get data from form project_name = request.form.get('project_name') if ' ' in project_name: flash('project name may not contain spaces', 'warning') return redirect(url_for('dashboard')) sorting_algorithm_name = request.form.get('selector_algorithm') public = (True if request.form.get('public') == 'on' else False) join_code = request.form.get('join_code') description = request.form.get('description') message, status = ProjectHandler.create_project( name=project_name, sorting_algorithm_name=sorting_algorithm_name, public=public, join_code=join_code, description=description, files=request.files.getlist("file"), ) if status == 'success': DBProxy.add_user_to_project(email=get_email_from_request(), project_name=project_name) flash(message, status) return redirect(url_for('dashboard'))
def add_public_project(): project_name = request.form.get('project_name') email = get_email_from_request() DBProxy.add_user_to_project(email, project_name=project_name) return redirect(url_for('dashboard'))