2019-03-18 08:42:13 +01:00
|
|
|
from zerver.models import Realm
|
2019-04-24 04:30:15 +02:00
|
|
|
from zerver.lib.cache import cache_with_key, realm_rendered_description_cache_key, \
|
|
|
|
realm_text_description_cache_key
|
2019-03-18 08:42:13 +01:00
|
|
|
from zerver.lib.bugdown import convert as bugdown_convert
|
2019-04-24 04:30:15 +02:00
|
|
|
from zerver.lib.html_to_text import html_to_text
|
2019-03-18 08:42:13 +01:00
|
|
|
|
|
|
|
@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)
|
2019-04-24 04:30:15 +02:00
|
|
|
|
|
|
|
@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)
|
2019-05-02 02:35:20 +02:00
|
|
|
return html_to_text(html_description, {'p': ' | ', 'li': ' * '})
|