Files
zulip/zerver/lib/realm_icon.py
Anders Kaseorg 365fe0b3d5 python: Sort imports with isort.
Fixes #2665.

Regenerated by tabbott with `lint --fix` after a rebase and change in
parameters.

Note from tabbott: In a few cases, this converts technical debt in the
form of unsorted imports into different technical debt in the form of
our largest files having very long, ugly import sequences at the
start.  I expect this change will increase pressure for us to split
those files, which isn't a bad thing.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
2020-06-11 16:45:32 -07:00

19 lines
625 B
Python

from django.conf import settings
from zerver.lib.avatar_hash import gravatar_hash
from zerver.lib.upload import upload_backend
from zerver.models import Realm
def realm_icon_url(realm: Realm) -> str:
return get_realm_icon_url(realm)
def get_realm_icon_url(realm: Realm) -> str:
if realm.icon_source == 'U':
return upload_backend.get_realm_icon_url(realm.id, realm.icon_version)
elif settings.ENABLE_GRAVATAR:
hash_key = gravatar_hash(realm.string_id)
return f"https://secure.gravatar.com/avatar/{hash_key}?d=identicon"
else:
return settings.DEFAULT_AVATAR_URI+'?version=0'