Skip to content

Commit

Permalink
examiner: Extract PDF links to separate template
Browse files Browse the repository at this point in the history
  • Loading branch information
JakobGM committed Jan 26, 2019
1 parent d6f85cf commit 8d65a2d
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 110 deletions.
112 changes: 2 additions & 110 deletions examiner/templates/examiner/exam_archive.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,122 +106,14 @@ <h1 class="mx-auto text-center mt-5" style="font-size: 3em;">
<td>
{# Iterate over all the exam languages #}
{% for language, pdfs in exam_set.exams.items %}

{# Iterate over all the exam PDFs available for the category #}
{% for sha1, pdf in pdfs.items %}

{# First the main PDF for this exam #}
{% if forloop.first %}
<div class="my-1" style="display: inline-block;">

{# Add hidden fix button #}
<a
type="button"
class="btn btn-outline-success btn-sm mr-2 fix-button collapse multi-collapse"
href="{% url 'examiner:verify_pdf' sha1 %}">
Fiks
</a>

{# Link to the first PDF with filename #}
<a href="{{ pdf.urls.0 }}" target="_blank">
{% if language == 'Engelsk' %}
🇬🇧
{% elif language == 'Nynorsk' %}
🇳🇴
{% elif language == 'Bokmål' %}
🇳🇴
{% else %}
&nbsp;<i class="fa fa-question-circle" style="color:grey"></i>
{% endif %}
{{ pdf.filename | truncatechars:25 }}
{% if language == 'Nynorsk' %}
<div style="color: silver; display: inline-block;">(nynorsk)</div>
{% endif %}
</a>

</div>

{# New line before alternative PDFs #}
{% elif forloop.counter == 2 %}
<br>
<i class="fa fa-external-link"></i>
{% endif %}

{# Add we now add all the alternative PDFs with counters #}
{% if forloop.counter > 1 %}
<a href="{{ pdf.urls.0 }}" title="{{ pdf.filename }}" target="_blank">
[{{ forloop.counter }}]
</a>
{% endif %}

{# Add hidden text field for this PDF, used for searching #}
<div style="display:none;" class="text-content">{{ pdf.text }}</div>

{% endfor %}

{# Break between each language #}
<br>
{% include 'examiner/pdf_links.html' %}
{% endfor %}
</td>

<td>
{# Iterate over all the solution languages #}
{% for language, pdfs in exam_set.solutions.items %}

{# Iterate over all the PDFs available for the category #}
{% for sha1, pdf in pdfs.items %}

{# First the main PDF for the category #}
{% if forloop.first %}
<div class="my-1" style="display: inline-block;">

{# Add hidden fix button #}
<a
type="button"
class="btn btn-outline-success btn-sm mr-2 fix-button collapse multi-collapse"
href="{% url 'examiner:verify_pdf' sha1 %}">
Fiks
</a>

{# Link to the first PDF with filename #}
<a href="{{ pdf.urls.0 }}" target="_blank">
{% if language == 'Engelsk' %}
🇬🇧
{% elif language == 'Nynorsk' %}
🇳🇴
{% elif language == 'Bokmål' %}
🇳🇴
{% else %}
&nbsp;<i class="fa fa-question-circle" style="color:grey"></i>
{% endif %}
<i>{{ pdf.filename | truncatechars:25 }}</i>
{% if language == 'Nynorsk' %}
<div style="color: silver; display: inline-block;">(nynorsk)</div>
{% endif %}
</a>

</div>

{# New line before alternative PDFs #}
{% elif forloop.counter == 2 %}
<br>
<i class="fa fa-external-link"></i>
{% endif %}

{# Add we now add all the alternative PDFs with counters #}
{% if forloop.counter > 1 %}
<a href="{{ pdf.urls.0 }}" title="{{ pdf.filename }}" target="_blank">
[{{ forloop.counter }}]
</a>
{% endif %}

{# Add hidden text field for this PDF, used for searching #}
<div style="display:none;">{{ pdf.text }}</div>

{% endfor %}

{# Break between languages #}
<br>
{% include 'examiner/pdf_links.html' %}
{% endfor %}
</td>
</tr>
Expand Down
55 changes: 55 additions & 0 deletions examiner/templates/examiner/pdf_links.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{# Iterate over all the PDFs available for the category #}
{# Requires context variables: pdfs, language #}
{% for sha1, pdf in pdfs.items %}

{# First the main PDF for the category #}
{% if forloop.first %}
<div class="my-1" style="display: inline-block;">

{# Add hidden fix button #}
<a
type="button"
class="btn btn-outline-success btn-sm mr-2 fix-button collapse multi-collapse"
href="{% url 'examiner:verify_pdf' sha1 %}">
Fiks
</a>

{# Link to the first PDF with filename #}
<a href="{{ pdf.urls.0 }}" target="_blank">
{% if language == 'Engelsk' %}
🇬🇧
{% elif language == 'Nynorsk' %}
🇳🇴
{% elif language == 'Bokmål' %}
🇳🇴
{% else %}
&nbsp;<i class="fa fa-question-circle" style="color:grey"></i>
{% endif %}
<i>{{ pdf.filename | truncatechars:25 }}</i>
{% if language == 'Nynorsk' %}
<div style="color: silver; display: inline-block;">(nynorsk)</div>
{% endif %}
</a>

</div>

{# New line before alternative PDFs #}
{% elif forloop.counter == 2 %}
<br>
<i class="fa fa-external-link"></i>
{% endif %}

{# Add we now add all the alternative PDFs with counters #}
{% if forloop.counter > 1 %}
<a href="{{ pdf.urls.0 }}" title="{{ pdf.filename }}" target="_blank">
[{{ forloop.counter }}]
</a>
{% endif %}

{# Add hidden text field for this PDF, used for searching #}
<div style="display:none;">{{ pdf.text }}</div>

{% endfor %}

{# Break between languages #}
<br>

0 comments on commit 8d65a2d

Please sign in to comment.