def teams_create(): form = TeamForm(request.form) if not form.validate(): return render_template("teams/new.html", form=form) tm = Team(form.name.data) tm.account_id = current_user.id db.session().add(tm) db.session().commit() #Luodaan liitostauluun paikat tiimille (Jäävät alussa "Free" asetukselle) team_id = tm.id mate1 = Teammate(team_id) mate1.role = 1 mate2 = Teammate(team_id) mate2.role = 2 mate3 = Teammate(team_id) mate3.role = 3 mate4 = Teammate(team_id) mate4.role = 4 mate5 = Teammate(team_id) mate5.role = 5 db.session().add(mate1) db.session().add(mate2) db.session().add(mate3) db.session().add(mate4) db.session().add(mate5) db.session().commit() return redirect(url_for("teams_index"))
def teams_create(): form = TeamForm(request.form) if not form.validate(): return render_template("teams/new.html", form=form) t = Team(form.name.data) db.session().add(t) db.session().commit() return redirect(url_for("teams_index"))
def team_signup(): error = None form = TeamForm() if form.validate_on_submit(): try: t = Team(name=form.name.data) db.session.add(t) db.session.commit() flash("Team created") except Exception as e: error = e return redirect(url_for("user_signup", team_id=t.id)) return render_template("/teams/new.html", form=form, error=error)
def teams_create(): form = TeamForm(request.form) if not form.validate(): return render_template("teams/new.html", form=form) t = Team(name=form.name.data) t.race = form.race.data t.resurrect = form.resurrect.data t.account_id = current_user.id db.session().add(t) db.session().commit() return redirect(url_for("teams_index"))
def teams_index(): return render_template("teams/list.html", teams=Team.find_users_teams(current_user.id), form=TeamForm(), units=Team.units_in_teams(current_user.id), unit_numbers=Team.number_of_units_in_teams( current_user.id))
def teams_create(): if current_user.isAdmin == False: return redirect(url_for("teams_index")) form = TeamForm(request.form) if not form.validate(): return render_template("teams/new.html", form=form) t = Team(form.name.data) t.home = form.home.data db.session().add(t) db.session().commit() return redirect(url_for("teams_index"))
def teams_edit(team_id): teams = Team.find_teams_of_a_user(current_user.id) team_ids = [team[0] for team in teams] form = TeamForm() team = Team.query.filter_by(id=team_id).first() if request.method == "GET": if int(team_id) in team_ids: return render_template("/teams/editteam.html", team=team, form=form) else: print("Team is not a current user's team") return redirect(url_for("index")) if request.form["btn"] == "Set as representive": user = User.query.filter_by(id=current_user.id).first() user.representive_team_id = team_id db.session().commit() return render_template("/teams/editteam.html", team=team, form=form) if request.form["btn"] == "Change name": if request.method == "POST": form = TeamForm(request.form) new_name = form.team_name.data team.name = new_name db.session().commit() return render_template("/teams/editteam.html", team=team, form=form) if request.form["btn"] == "Remove from my teams": if request.method == "POST": user = User.query.filter_by(id=current_user.id).first() if (user.representive_team_id == int(team_id)): errorMsg = "Cannot remove representive team. Set another team as reprsentive team first." return render_template("/teams/editteam.html", team=team, form=form, error=errorMsg) else: user.remove_team(team_id) return redirect(url_for('teams_form'))
def teams_create(): form = TeamForm(request.form) if not form.validate(): return render_template("teams/list.html", teams=Team.find_users_teams(current_user.id), units=Team.units_in_teams(current_user.id), unit_numbers=Team.number_of_units_in_teams( current_user.id), form=form) t = Team(form.name.data) t.account_id = current_user.id db.session.add(t) db.session().commit() return redirect(url_for("teams_index"))
def teams_form(): user = User.query.filter_by(id=current_user.id).first() teams = Team.find_teams_of_a_user(current_user.id) teams_list = [(team[0], team[1]) for team in teams] form = TeamForm() form.team_list.choices = teams_list if request.method == "GET": return render_template("/teams/teamform.html", form=form, teams=teams) if request.form["btn"] == "Add team": if request.method == "POST": form = TeamForm(request.form) name = form.team_name.data team = Team.query.filter_by(name=name).first() if team: user.user_teams.append(team) db.session().commit() teams = Team.find_teams_of_a_user(current_user.id) form = TeamForm() return redirect(url_for("teams_form")) new_team = Team(name) db.session().add(new_team) new_team.members.append(user) db.session().commit() return redirect(url_for("teams_form")) if request.form["btn"] == "Modify team": if request.method == "POST": form = TeamForm(request.form) selected_id = form.team_list.data return redirect(url_for('teams_edit', team_id=selected_id))
def teams_form(): if current_user.isAdmin == False: return redirect(url_for("teams_index")) return render_template("teams/new.html", form=TeamForm())
def teams_form(): return render_template("teams/new.html", form=TeamForm())