Skip to content
This repository has been archived by the owner on Feb 14, 2023. It is now read-only.

Commit

Permalink
Show solutions if available
Browse files Browse the repository at this point in the history
  • Loading branch information
xobb1t committed Jul 30, 2011
1 parent 704f195 commit 6e21a2b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
19 changes: 12 additions & 7 deletions project/lint/templatetags/lint.py
Expand Up @@ -13,14 +13,19 @@ def report_create_form():


@register.inclusion_tag('lint/tags/results_fix.html')
def results_fix(data):
lines = json.loads(data, )
result = []
for line_info in lines:
result.append({
def results_fix(fix):
source_result, solution_result = [], []
for line_info in json.loads(fix.source):
source_result.append({
'number': line_info[0],
'is_significant': line_info[1],
'text': line_info[2],
})
return {'result': result}

for line_info in json.loads(fix.solution):
solution_result.append({
'number': line_info[0],
'is_significant': line_info[1],
'text': line_info[2],
})
return {'source_result': source_result, 'fix': fix,
'solution_result': solution_result}
9 changes: 1 addition & 8 deletions project/templates/lint/results.html
Expand Up @@ -13,14 +13,7 @@ <h2>Results url:</h2>
<h2>Fixes:</h2>
{% with report.fixes.all as fixes %}
{% for fix in fixes %}
<div class="description">
<h3{% if forloop.first %} class="first"{% endif %}>{{ fix.path }}</h3>
<p>{{ fix.description }}</p>
{% results_fix fix.source %}
{% if fix.solution %}
{% results_fix fix.solution %}
{% endif %}
</div>
{% results_fix fix %}
{% endfor %}
{% endwith %}
{% endblock %}
23 changes: 18 additions & 5 deletions project/templates/lint/tags/results_fix.html
@@ -1,5 +1,18 @@
{% for line in result %}
{% if forloop.first %}<ol class="fix{% if solution %} yes{% endif %}" start="{{ line.number }}">{% endif %}
<li{% if line.is_significant %} class="significant"{% endif %}><pre><code>{{ line.text }}</code></pre></li>
{% if froloop.last %}</ol>{% endif %}
{% endfor %}
<div class="description">
<h3{% if forloop.first %} class="first"{% endif %}>{{ fix.path }}</h3>
<p>{{ fix.description }}</p>

{% for line in source_result %}
{% if forloop.first %}<ol class="fix" start="{{ line.number }}">{% endif %}
<li{% if line.is_significant %} class="significant"{% endif %}><pre><code>{{ line.text }}</code></pre></li>
{% if froloop.last %}</ol>{% endif %}
{% endfor %}
{% if fix.solution %}

{% for line in solution_result %}
{% if forloop.first %}<ol class="fix yes" start="{{ line.number }}">{% endif %}
<li{% if line.is_significant %} class="significant"{% endif %}><pre><code>{{ line.text }}</code></pre></li>
{% if froloop.last %}</ol>{% endif %}
{% endfor %}
{% endif %}
</div>

0 comments on commit 6e21a2b

Please sign in to comment.