Exemplo n.º 1
0
def delete_game(request, key=None):
    game = None
    if key is not None:
        game = Game.get(key)
    if key and request.method == 'POST':
        game.delete()
    return HttpResponseRedirect('/admin/games/')
Exemplo n.º 2
0
def edit_game(request, key=None):
    game = None
    if key is not None:
        game = Game.get(key)
    if request.method == 'POST':
        form = GameForm(request.POST)
        if form.is_valid():
            game = Game.from_form(form)
            game.put()
            return HttpResponseRedirect('/admin/games/')
    elif game:
        form = GameForm({'sport': game.sport,
                         'team1': game.team1,
                         'team2': game.team2,
                         'dtstart': game.dtstart})
    else:
        form = GameForm()

    return render_admin_template('admin/games/edit.html', dict(
            game=game, game_form=form))
Exemplo n.º 3
0
def load_nhl(request):
    """Populate the data store with an initial set of games."""
    games = csv.reader(open(os.path.dirname(__file__) + '/../../nhl.csv', 'r'))
    gs = []
    for game in games:
        year = int(game[0])
        month = int(game[1])
        day = int(game[2])
        hour = int(game[3])
        minute = int(game[4])
        second = int(game[5])
        # dst = int(game[6])
        team1 = game[7]
        team2 = game[8]
        tzinfo = eastern_time
        dtstart = datetime.datetime(year, month, day, hour, minute, second, 0, tzinfo)
        g = Game(sport='NHL', team1=team1, team2=team2, dtstart=dtstart)
        g.put()
        gs.append(g)

    return render_admin_template('admin/games.html', dict(games=gs))