예제 #1
0
def roster_management():

    if "gm_email" in session:
        team = Team()
        team_data = team.get_team_data_by_gm_email(session["gm_email"])

        # Add team_id to session
        for td in team_data:
            app.logger.debug("team_id: %s" % td["team_id"])
            session["team_id"] = td["team_id"]

        roster_form = RosterManagementForm()

        if roster_form.validate_on_submit():
            if roster_form.add_button.data:
                team.add_player(roster_form.first_name.data,
                                roster_form.last_name.data)
                for t in team_data:
                    team.assign_player_to_team(roster_form.first_name.data,
                                               roster_form.last_name.data,
                                               t["team_name"])
                app.logger.debug(
                    "%s %s is added to the roster." %
                    (roster_form.first_name.data, roster_form.last_name.data))
            return redirect(url_for('roster_management'))
        else:
            app.logger.debug(
                "NOT ADDED: %s %s" %
                (roster_form.first_name.data, roster_form.last_name.data))
            return render_template("gm/roster_management.html",
                                   team_data=team_data,
                                   form=roster_form)
예제 #2
0
def team_registration():
    if "gm_email" in session:
        return "You already have a team registered!"

    form = TeamRegistration()
    team = Team()

    if form.validate_on_submit():
        team.add_user(form.gm_email.data, form.password.data,
                      form.gm_name.data)
        team.add_team(form.team_name.data, form.gm_name.data)
        for player in form.players.data:
            team.add_player(player['first_name'], player['last_name'])
            team.assign_player_to_team(player['first_name'],
                                       player['last_name'],
                                       form.team_name.data)
        flash("Account created for %s" % form.gm_email.data, 'success')
        return redirect(url_for('team_registration_confirmation'))
    else:
        # return form.errors
        return render_template('team_registration.html',
                               show_home=0,
                               title='Team Registration',
                               form=form)