Exemplo n.º 1
0
def random_comic_url(request):
    """
    returns the URL for a random comic

    called via ajax, should not be cached
    """
    if not request.is_ajax():
        raise Http404

    comic_chronology = request.GET.get("current_comic", "1")
    comic_chronology = int(comic_chronology)

    try:
        current_comic = Comic.objects.get(chronology=comic_chronology, published=True)
    except ObjectDoesNotExist:
        current_comic = None

    random_comic = get_random_comic(current_comic)
    response_data = {"url": random_comic.get_absolute_url()}
    response_data = json.dumps(response_data)

    return HttpResponse(response_data, mimetype='application/json')
Exemplo n.º 2
0
def get_random_comic_link(current_comic):
    """
    Returns a URL for a random comic that is not 'current_comic'
    """
    comic = get_random_comic(current_comic)
    return comic.get_absolute_url()
Exemplo n.º 3
0
def get_random_comic_link(current_comic):
    """
    Returns a URL for a random comic that is not 'current_comic'
    """
    comic = get_random_comic(current_comic)
    return comic.get_absolute_url()