Files
zulip/zerver/lib/realm_description.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

21 lines
859 B
Python

from zerver.lib.bugdown import convert as bugdown_convert
from zerver.lib.cache import (
cache_with_key,
realm_rendered_description_cache_key,
realm_text_description_cache_key,
)
from zerver.lib.html_to_text import html_to_text
from zerver.models import Realm
@cache_with_key(realm_rendered_description_cache_key, timeout=3600*24*7)
def get_realm_rendered_description(realm: Realm) -> str:
realm_description_raw = realm.description or "The coolest place in the universe."
return bugdown_convert(realm_description_raw, message_realm=realm,
no_previews=True)
@cache_with_key(realm_text_description_cache_key, timeout=3600*24*7)
def get_realm_text_description(realm: Realm) -> str:
html_description = get_realm_rendered_description(realm)
return html_to_text(html_description, {'p': ' | ', 'li': ' * '})