Inline most calls to set_rendered_content().

This is part of breaking the circular dependency on
bugdown in models.py.  A subsequent commit will fully
kill off set_rendered_content().
This commit is contained in:
Steve Howell 2016-10-04 07:49:16 -07:00
parent 583a6bbadd
commit 6b71f5bd5f
2 changed files with 11 additions and 4 deletions

View File

@ -9,7 +9,10 @@ from django.utils.translation import ugettext as _
from django.conf import settings
from django.core import validators
from django.contrib.sessions.models import Session
from zerver.lib.bugdown import BugdownRenderingException
from zerver.lib.bugdown import (
BugdownRenderingException,
version as bugdown_version
)
from zerver.lib.cache import (
to_dict_cache_key,
to_dict_cache_key_id,
@ -714,7 +717,8 @@ def do_send_messages(messages):
message['message'],
message['message'].content,
message_users=message['active_recipients'])
message['message'].set_rendered_content(rendered_content)
message['message'].rendered_content = rendered_content
message['message'].rendered_content_version = bugdown_version
for message in messages:
message['message'].update_calculated_fields()
@ -2498,7 +2502,8 @@ def do_update_message(user_profile, message, subject, propagate_mode, content, r
edit_history_event["prev_rendered_content"] = message.rendered_content
edit_history_event["prev_rendered_content_version"] = message.rendered_content_version
message.content = content
message.set_rendered_content(rendered_content)
message.rendered_content = rendered_content
message.rendered_content_version = bugdown_version
event["content"] = content
event["rendered_content"] = rendered_content

View File

@ -197,7 +197,9 @@ class MessageDict(object):
# It's unfortunate that we need to have side effects on the message
# in some cases.
rendered_content = message.render_markdown(content, sender_realm_domain)
message.set_rendered_content(rendered_content, True)
message.rendered_content = rendered_content
message.rendered_content_version = bugdown.version
message.save_rendered_content()
if rendered_content is not None:
obj['content'] = rendered_content