def populate_picks():
    year = 2014
    week = 1
    user = '******'
    add_pick(get_week(year, week), get_user_by_username(user), get_game(year, week, 1), game_winner=1)
    add_pick(get_week(year, week), get_user_by_username(user), get_game(year, week, 2), game_winner=1)
    add_pick(get_week(year, week), get_user_by_username(user), get_game(year, week, 3), game_winner=1)
    add_pick(get_week(year, week), get_user_by_username(user), get_game(year, week, 4), game_winner=1)
    add_pick(get_week(year, week), get_user_by_username(user), get_game(year, week, 5), game_winner=1)
    add_pick(get_week(year, week), get_user_by_username(user), get_game(year, week, 6), game_winner=1)
    add_pick(get_week(year, week), get_user_by_username(user), get_game(year, week, 7), game_winner=1)
    add_pick(get_week(year, week), get_user_by_username(user), get_game(year, week, 8), game_winner=1)
    add_pick(get_week(year, week), get_user_by_username(user), get_game(year, week, 9), game_winner=1)
    add_pick(get_week(year, week), get_user_by_username(user), get_game(year, week, 10), game_winner=1)
Exemple #2
0
 def __get_week_games_in_database_indexed_by_game_number(
         self, year, week_number):
     game_numbers = range(1, 11)
     return {
         game_num: get_game(year, week_number, game_num)
         for game_num in game_numbers
     }
Exemple #3
0
 def __get_week_games_in_database_indexed_by_id(self, year, week_number):
     game_numbers = range(1, 11)
     week_games = dict()
     for game_num in game_numbers:
         game = get_game(year, week_number, game_num)
         week_games[game.id] = game
     return week_games
Exemple #4
0
def populate_picks():
    year = 2014
    week = 1
    user = '******'
    add_pick(get_week(year, week),
             get_user_by_username(user),
             get_game(year, week, 1),
             game_winner=1)
    add_pick(get_week(year, week),
             get_user_by_username(user),
             get_game(year, week, 2),
             game_winner=1)
    add_pick(get_week(year, week),
             get_user_by_username(user),
             get_game(year, week, 3),
             game_winner=1)
    add_pick(get_week(year, week),
             get_user_by_username(user),
             get_game(year, week, 4),
             game_winner=1)
    add_pick(get_week(year, week),
             get_user_by_username(user),
             get_game(year, week, 5),
             game_winner=1)
    add_pick(get_week(year, week),
             get_user_by_username(user),
             get_game(year, week, 6),
             game_winner=1)
    add_pick(get_week(year, week),
             get_user_by_username(user),
             get_game(year, week, 7),
             game_winner=1)
    add_pick(get_week(year, week),
             get_user_by_username(user),
             get_game(year, week, 8),
             game_winner=1)
    add_pick(get_week(year, week),
             get_user_by_username(user),
             get_game(year, week, 9),
             game_winner=1)
    add_pick(get_week(year, week),
             get_user_by_username(user),
             get_game(year, week, 10),
             game_winner=1)
    def save_picks(self,picks):
        self.__picks_sanity_check(picks)

        player = Player.objects.get(id=self.player_id)

        update_submit_time = False

        for pick in picks:
            game_number = pick.number
            game = get_game(self.year,self.week_number,game_number)

            existing_pick = self.__get_existing_pick(player,game)

            if existing_pick != None:
                pick_changed = self.__edit_pick(game_number,existing_pick,pick)
                if pick_changed:
                    update_submit_time = True
            else:
                self.__create_pick(player,game,pick)
                update_submit_time = True

        if update_submit_time:
            self.__update_submit_time(player)
 def __update_submit_time(self,player):
     game = get_game(self.year,self.week_number,10)
     pick = self.__get_existing_pick(player,game)
     pick.submit_time = tz.now()
     pick.save()