Skip to content

Commit

Permalink
[bug 693988] Fix preview on edit answer page as well.
Browse files Browse the repository at this point in the history
  • Loading branch information
rlr committed Oct 17, 2011
1 parent 5a0b8c1 commit 95f2a99
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
4 changes: 0 additions & 4 deletions apps/questions/models.py
Expand Up @@ -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:
Expand Down
26 changes: 10 additions & 16 deletions apps/questions/templates/questions/edit_answer.html
Expand Up @@ -46,26 +46,20 @@ <h2>{{ _('Edit an answer') }}</h2>
{{ 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 %}
Expand Down
7 changes: 6 additions & 1 deletion apps/questions/templates/questions/includes/answer.html
Expand Up @@ -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">
Expand Down
Expand Up @@ -5,6 +5,7 @@ <h1>{{ _('Reply Preview') }}</h1>
<ol class="answers">
<li class="answer">
{% set answer = answer_preview %}
{% set is_preview = True %}
{% include "questions/includes/answer.html" %}
</li>
</ol>

0 comments on commit 95f2a99

Please sign in to comment.