Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[bug 693988] Fix preview on edit answer page as well.

  • Loading branch information...
commit 95f2a99fe665f7ff0cd6989fbe0af5ca12f7dc4f 1 parent 5a0b8c1
@rlr rlr authored
View
4 apps/questions/models.py
@@ -485,10 +485,6 @@ def _has_beta(version, dev_releases):
def _content_parsed(obj):
- if not obj.id:
- # Don't cache if we don't have an ID (previews)
- return wiki_to_html(obj.content)
-
cache_key = obj.html_cache_key % obj.id
html = cache.get(cache_key)
if html is None:
View
26 apps/questions/templates/questions/edit_answer.html
@@ -46,26 +46,20 @@
{{ attachments_form('questions.Answer', answer.pk, answer.images.all(), settings, request.user) }}
<div class="form-widget submit">
- <input type="submit" class="btn" value="{{ _('Update answer') }}" />
- <input type="submit" class="preview link-btn" name="preview" value="{{ _('Preview Reply') }}" />
+ <input type="submit" class="btn-important" value="{{ _('Update answer') }}" />
+ <input type="submit" id="preview" name="preview" value="{{ _('Preview Reply') }}"
+ data-preview-url="{{ url('questions.answer_preview_async') }}"
+ data-preview-container-id="answer-preview"
+ data-preview-content-id="id_content" />
<a href="{{ url('questions.answers', answer.question.id) }}">{{ _('Cancel') }}</a>
</div>
</form>
- {% if answer_preview %}
- <section id="answer-preview">
- <header>
- <h1>{{ _('Answer Preview:') }}</h1>
- </header>
- <ol class="answers">
- <li class="answer">
- {% set answer = answer_preview %}
- {% set question = answer.question %}
- {% include "questions/includes/answer.html" %}
- </li>
- </ol>
- </section>
- {% endif %}
+ <section id="answer-preview">
+ {% if answer_preview %}
+ {% include "questions/includes/answer_preview.html" %}
+ {% endif %}
+ </section>
</div>
</article>
{% endblock %}
View
7 apps/questions/templates/questions/includes/answer.html
@@ -34,7 +34,12 @@
</div>
<div class="main-section">
<div class="content">
- {{ answer.content_parsed|safe }}
+ {% if is_preview %}
+ {# Don't use cached content_parsed #}
+ {{ answer.content|wiki_to_html }}
+ {% else %}
+ {{ answer.content_parsed|safe }}
+ {% endif %}
<div class="stem"></div>{# for the speech bubble arrow #}
</div>
<div class="ans-attachments attachments-list">
View
1  apps/questions/templates/questions/includes/answer_preview.html
@@ -5,6 +5,7 @@
<ol class="answers">
<li class="answer">
{% set answer = answer_preview %}
+ {% set is_preview = True %}
{% include "questions/includes/answer.html" %}
</li>
</ol>
Please sign in to comment.
Something went wrong with that request. Please try again.