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
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))
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))
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
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
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