예제 #1
0
파일: pages.py 프로젝트: djibux/website
def screenshot_add(request, slug):
    game = get_object_or_404(Game, slug=slug)
    form = ScreenshotForm(request.POST or None, request.FILES or None, game_id=game.id)
    if form.is_valid():
        form.instance.uploaded_by = request.user
        form.save()
        return redirect(reverse("game_detail", kwargs={"slug": slug}))
    return render(request, "games/screenshot/add.html", {"form": form})
예제 #2
0
파일: pages.py 프로젝트: lutris/website
def screenshot_add(request, slug):
    game = get_object_or_404(Game, slug=slug)
    form = ScreenshotForm(request.POST or None, request.FILES or None, game_id=game.id)
    if form.is_valid():
        form.instance.uploaded_by = request.user
        form.save()
        return redirect(reverse("game_detail", kwargs={"slug": slug}))
    return render(request, "games/screenshot/add.html", {"form": form})
예제 #3
0
파일: views.py 프로젝트: rlr/doozer
def screenshots(request, game_id):
    """View/edit screenshots for a game."""
    game = get_object_or_404(Game, id=game_id, creator=request.user)
    room_for_more = game.screenshot_set.count() < settings.SCREENSHOTS_MAX
    form = ScreenshotForm()

    game = get_object_or_404(Game, creator=request.user, pk=game_id)
    form = GameForm(instance=game)
    room_for_more = game.screenshot_set.count() < settings.SCREENSHOTS_MAX
    screenshot_form = ScreenshotForm()


    if request.POST and room_for_more:
        screenshot_form = ScreenshotForm(request.POST, request.FILES)
        if screenshot_form.is_valid():
            new_screenshot = screenshot_form.save(commit=False)
            new_screenshot.game = game
            new_screenshot.save()

            messages.success(request, "Your screenshot has been uploaded!")
            return HttpResponseRedirect(reverse('games.edit',
                                                args=[game.id]))
    c = {'game': game,
         'form': form,
         'room_for_more': room_for_more,
         'screenshot_form': screenshot_form,
    }
    return render(request, 'games/edit.html', c)
def screenshots(request, game_id):
    """View/edit screenshots for a game."""
    game = get_object_or_404(Game, id=game_id, creator=request.user)
    room_for_more = game.screenshot_set.count() < settings.SCREENSHOTS_MAX
    form = ScreenshotForm()

    game = get_object_or_404(Game, creator=request.user, pk=game_id)
    form = GameForm(instance=game)
    room_for_more = game.screenshot_set.count() < settings.SCREENSHOTS_MAX
    screenshot_form = ScreenshotForm()

    if request.POST and room_for_more:
        screenshot_form = ScreenshotForm(request.POST, request.FILES)
        if screenshot_form.is_valid():
            new_screenshot = screenshot_form.save(commit=False)
            new_screenshot.game = game
            new_screenshot.save()

            messages.success(request, "Your screenshot has been uploaded!")
            return HttpResponseRedirect(reverse('games.edit', args=[game.id]))
    c = {
        'game': game,
        'form': form,
        'room_for_more': room_for_more,
        'screenshot_form': screenshot_form,
    }
    return render(request, 'games/edit.html', c)