예제 #1
0
def user_avatar(request, user, size):
    """User avatar view."""
    allowed_sizes = (
        # Used in top navigation
        24,
        # In text avatars
        32,
        # 80 pixes used when linked with weblate.org
        80,
        # Public profile
        128,
    )
    if size not in allowed_sizes:
        raise Http404(f"Not supported size: {size}")

    user = get_object_or_404(User, username=user)

    if user.email == "*****@*****.**":
        return redirect(get_fallback_avatar_url(size))
    if user.email == "noreply+{}@weblate.org".format(user.pk):
        return redirect(os.path.join(settings.STATIC_URL, "state/ghost.svg"))

    response = HttpResponse(content_type="image/png",
                            content=get_avatar_image(user, size))

    patch_response_headers(response, 3600 * 24 * 7)

    return response
예제 #2
0
def user_avatar(request, user, size):
    """
    User avatar page.
    """
    user = get_object_or_404(User, username=user)

    if user.email == "*****@*****.**":
        return redirect(get_fallback_avatar_url(size))

    return HttpResponse(content_type="image/png", content=get_avatar_image(user, size))
예제 #3
0
파일: views.py 프로젝트: dhodhala88/Bosch1
def user_avatar(request, user, size):
    '''
    User avatar page.
    '''
    user = get_object_or_404(User, username=user)

    if user.email == '*****@*****.**':
        return redirect(get_fallback_avatar_url(size))

    return HttpResponse(content_type='image/png',
                        content=get_avatar_image(user, size))
예제 #4
0
def user_avatar(request, user, size):
    """User avatar view."""
    user = get_object_or_404(User, username=user)

    if user.email == '*****@*****.**':
        return redirect(get_fallback_avatar_url(size))

    response = HttpResponse(content_type='image/png',
                            content=get_avatar_image(user, size))

    patch_response_headers(response, 3600 * 24 * 7)

    return response
예제 #5
0
파일: views.py 프로젝트: dekoza/weblate
def user_avatar(request, user, size):
    """User avatar view."""
    user = get_object_or_404(User, username=user)

    if user.email == '*****@*****.**':
        return redirect(get_fallback_avatar_url(size))

    response = HttpResponse(
        content_type='image/png',
        content=get_avatar_image(request, user, size)
    )

    patch_response_headers(response, 3600 * 24 * 7)

    return response
예제 #6
0
def user_avatar(request, user, size):
    """User avatar view."""
    user = get_object_or_404(User, username=user)

    if user.email == "*****@*****.**":
        return redirect(get_fallback_avatar_url(size))
    if user.email == "noreply+{}@weblate.org".format(user.pk):
        return redirect(os.path.join(settings.STATIC_URL, "state/ghost.svg"))

    response = HttpResponse(content_type="image/png",
                            content=get_avatar_image(user, size))

    patch_response_headers(response, 3600 * 24 * 7)

    return response