forked from zulip/zulip
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
streams: Render and store the stream description from the backend.
This commit does the following three things: 1. Update stream model to accomodate rendered description. 2. Render and save the stream rendered description on update. 3. Render and save stream descriptions on creation. Further, the stream's rendered description is also sent whenever the stream's description is being sent. This is preparatory work for eliminating the use of the non-authoritative marked.js markdown parser for stream descriptions.
- Loading branch information
Showing
10 changed files
with
70 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
from django.apps import apps | ||
from django.db.models import F | ||
|
||
from django.db.migrations.state import StateApps | ||
from django.db.backends.postgresql_psycopg2.schema import DatabaseSchemaEditor | ||
|
||
from zerver.lib.bugdown import convert as bugdown_convert | ||
|
||
def render_all_stream_descriptions(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: | ||
Stream = apps.get_model('zerver', 'Stream') | ||
all_streams = Stream.objects.exclude(description='') | ||
for stream in all_streams: | ||
stream.rendered_description = bugdown_convert(stream.description) | ||
stream.save(update_fields=["rendered_description"]) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('zerver', '0205_remove_realmauditlog_requires_billing_update'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='stream', | ||
name='rendered_description', | ||
field=models.TextField(default=''), | ||
), | ||
migrations.RunPython(render_all_stream_descriptions, | ||
reverse_code=migrations.RunPython.noop), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters