예제 #1
0
def index(request):

    gameList = games.objects.all()

    gameJSON = []

    for game in gameList:

        dictionary = {"lat": game.lat, "long": game.long, "when": str(game.when), "sport": game.sport, "open": game.isItOpen, "players_needed": game.players_needed, "skill_level": game.skill_level}

        entry = simplejson.dumps(dictionary)

        gameJSON.append(entry)
    

    form = filterForm()
    addForm = addGameForm()

    addForm = addGameForm()

    context = {
        "gameList": gameJSON,
        "form": form,
        "addForm": addForm,
        }

    return render(request, "index.html", context)
예제 #2
0
def addGame(request):

    if request.is_ajax():

        addForm = addGameForm()

        context = {
            "statusUpdate": statusUpdate,
            "addForm": addForm,
            }

        return render(request, "addGame.html", context)
예제 #3
0
def submitGame(request):

    if request.method == "POST" and request.is_ajax():

        validate = addGameForm(request.POST)

        if validate.is_valid():
            
            new_game = validate.save()

            gameList = games.objects.all()

            justPosted = new_game

            response = HttpResponse("success")

            return response

        else:

            response = HttpResponse(validate.errors)

            return response