def save_teams(): # change flag for season to saved= True current_season = model.current_season() current_season.saved =True model.session.add(current_season) #add intital team ratings for team in model.current_teams(): team.getRating() model.session.commit() # This will disable team name and creation button return redirect('team_create')
class GameForm(Form): all_teams = model.current_teams() game_date = DateField('Game Date', [validators.Required(message= (u'Game Date: mm/dd/yyyy'))], format= '%m/%d/%Y', description=u'Game Date(mm/dd/yyyy)') home_team = SelectField('Home', [validators.Required(message=(u'Select Team'))], choices=[(str(i.id),i.teamname) for i in all_teams], description=u'Home Team') away_team = SelectField('Away', [validators.Required(message=(u'Select Team'))], choices=[(str(i.id),i.teamname) for i in all_teams], description=u'Opponent') home_score = IntegerField('Home Score', [validators.Optional()], description=u'Home Score') away_score = IntegerField('Away Score', [validators.Optional()], description=u'Opponent Score')
def save_teams(): # change flag for season to saved= True current_season = model.current_season() current_season.saved = True save_season = model.session.add(current_season) current_teams = model.current_teams() #add intital team ratings for team in current_teams: team.getRating() model.session.commit() # This will disable team name and creation button return redirect('team_create')
def show_matches(): all_teams = model.current_teams() teams={} for t in all_teams: teams[t.id]=t.teamname games = model.session.query(model.Game).\ order_by(model.Game.game_date.desc()).all() #----------render form to change score---# form_s = ScoreForm() return render_template('schedule.html', title='Matches', games=games, form_s=form_s, all_teams=all_teams, teams=teams )
def get_calendar(): form = GameForm() today = request.args.get('month') if today == None: today = datetime.date(datetime.now()) print today # --------calendar begins---------# year = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ] # by default the calendar begin the week with Monday (day 0) calendar.setfirstweekday(calendar.SUNDAY) #stiringify date and reorganize into integers current = re.split('-', str(today)) current_no = int(current[1]) current_month = year[current_no - 1] current_day = int(re.sub('\A0', '', current[2])) current_yr = int(current[0]) month = calendar.monthcalendar(current_yr, current_no) nweeks = len(month) each_week = [] for w in range(0, nweeks): week = month[w] each_week.append(week) #---------------calender ends-----------# #-----add matches--------# all_teams = model.current_teams() teams = {} for t in all_teams: teams[t.id] = t.teamname # render template to set games form = GameForm() games = model.session.query(model.Game).\ order_by(model.Game.game_date.desc()).all() if form.validate_on_submit(): if form.home_team.data == form.away_team.data: flash("Teams cannot be the same") return redirect('calendar') else: new_game= model.session.\ add(model.Game(game_date = form.game_date.data, home_team = form.home_team.data, away_team = form.away_team.data, home_score = form.home_score.data, away_score = form.away_score.data)) model.session.commit() flash('Game Added!') return redirect('calendar') #----------render form to change score---# form_s = ScoreForm() return render_template('calendar.html', title='Calendar', current_month=current_month, current_yr=current_yr, each_week=each_week, user=current_user, form=form, games=games, form_s=form_s, all_teams=all_teams, teams=teams)
def get_calendar(): form = GameForm() today = request.args.get('month') if today == None: today = datetime.date(datetime.now()) print today # --------calendar begins---------# year = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] # by default the calendar begin the week with Monday (day 0) calendar.setfirstweekday(calendar.SUNDAY) #stiringify date and reorganize into integers current = re.split('-', str(today)) current_no = int(current[1]) current_month = year[current_no - 1] current_day = int(re.sub('\A0', '',current[2])) current_yr = int(current[0]) month = calendar.monthcalendar(current_yr, current_no) nweeks = len(month) each_week=[] for w in range(0,nweeks): week = month[w] each_week.append(week) #---------------calender ends-----------# #-----add matches--------# all_teams = model.current_teams() teams={} for t in all_teams: teams[t.id]=t.teamname # render template to set games form= GameForm() games = model.session.query(model.Game).\ order_by(model.Game.game_date.desc()).all() if form.validate_on_submit(): if form.home_team.data == form.away_team.data: flash("Teams cannot be the same") return redirect('calendar') else: new_game= model.session.\ add(model.Game(game_date = form.game_date.data, home_team = form.home_team.data, away_team = form.away_team.data, home_score = form.home_score.data, away_score = form.away_score.data)) model.session.commit() flash('Game Added!') return redirect('calendar') #----------render form to change score---# form_s = ScoreForm() return render_template('calendar.html', title='Calendar', current_month= current_month, current_yr= current_yr, each_week = each_week, user= current_user, form=form, games=games, form_s=form_s, all_teams=all_teams, teams=teams )