Exemplo n.º 1
0
def delete(request):
    try:
        object = EventGoalkeeperSaves(id=request.POST["object_id"])
        object.delete()
        response = {}
    except Exception, error:
        response = {"error": str(error)}
Exemplo n.º 2
0
def create(request):

    # attempt to save a goal
    try:
        event = Event.objects.get(id=request.POST["event_id"])
        teamFor = Team.objects.get(id=request.POST["saves_team"])

        # find out which team was scored against
        if event.homeTeam == teamFor:
            teamAgainst = event.awayTeam
        else:
            teamAgainst = event.homeTeam

        # populate goalkeeper object and call save
        object = EventGoalkeeperSaves()
        object.event = event
        object.team = teamFor
        object.againstTeam = teamAgainst
        object.player = request.POST["saves_player"]
        object.firstPeriodSaves = request.POST["saves_1st"]
        object.secondPeriodSaves = request.POST["saves_2nd"]
        object.thirdPeriodSaves = request.POST["saves_3rd"]
        object.overtimeSaves = request.POST["saves_ot"]
        object.save()

        response = {
            "object_id": object.id,
            "team": str(object.team),
            "player": object.player,
            "first": object.firstPeriodSaves,
            "second": object.secondPeriodSaves,
            "third": object.thirdPeriodSaves,
            "ot": object.overtimeSaves,
        }

    except Exception, error:
        response = {"error": str(error)}