コード例 #1
0
def teams_show(team_id):
    return render_template(
        "teams/show.html",
        team_id=team_id,
        team=Team.find_team(team_id),
        units=Team.get_units_in_team(team_id),
        number_of_units=Team.number_of_units_in_team(team_id),
        form=AddUnitForm())
コード例 #2
0
def teams_add_unit(team_id):
    form = AddUnitForm(request.form)

    if not form.validate():
        return render_template(
            "teams/show.html",
            form=form,
            number_of_units=Team.number_of_units_in_team(team_id),
            team=Team.find_team(team_id))

    unit_name = form.name.data
    unit_ids = Unit.get_unit_ids_with_name(unit_name)

    if unit_ids:
        tu = TeamUnit(team_id=team_id, unit_id=unit_ids[0])
        db.session.add(tu)
        db.session.commit()

    return redirect(url_for("teams_index"))