{% extends "template.html" %}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

{% block body %}
<div>
<form action="action.html">
  <p>
  <input name="view" class="submit" type="submit"
         value="{{ _('View') }}"/>
  <input name="recheck" class="submit" type="submit"
         value="{{ _('Recheck') }}"/>
  <input name="deliver" class="submit" type="submit"
         value="{{ _('Deliver') }}"/>
  {% for qname in REQUESTS.get('qname', []) %}
  <input name="qname" type="hidden" value="{{ qname }}"/>
  {% endfor %}
  </p>
</form>
<hr/>

{% if 'qname' not in REQUESTS %}
<div>{{ _('ERROR: Nothing selected!') }}</div>
{% endif %}

{% for qn in REQUESTS.get('qname', []) %}

  {% set VIEW = True %}
  {% set r = check_permission(qn) %}
  {% set error = r.error %}
  {% set qname = r.qname %}

{% if error %}
<h3>{{ error|e }}</h3>
{% else %}

{% if 'recheck' in REQ %}
<div>
{# ### Recheck quarantined file ### #}
{% set VIEW = False %}
{% set r = action_recheck(qname) %}
{% if r.error %}<p>{{ r.error|e }}</p>{% endif %}
{% if r.level!=None %}
<div class="{{ r.div_class }}">
{{ qname|e }}: {{ r.virname|e }} ({{ r.level }})<br/>
</div>
{% endif %}
</div>
{% endif %}

{% if 'deliver' in REQ %}
<div>
{# ### Deliver quarantined file ### #}
{% set VIEW = False %}
{% set r = action_deliver(qname) %}
{% if r.error %}<p>{{ r.error|e }}</p>{% endif %}
{% if r.status %}<pre>{{ r.status|e }}</pre>{% endif %}
</div>
{% endif %}

{% if ('view' in REQ) or VIEW %}
<div>
{# ### View quarantined file ### #}
{% set headers = None %}
{% set r = action_view(qname) %}
{% if r.show_headers %}
<pre class="header">{{ '\n'.join(r.show_headers)|e }}</pre>
<pre>{{ unicode(r.email.body(), errors='replace')|e }}</pre>
{% endif %}
<hr/>
</div>
{% endif %}

{% endif %}

{% endfor %}

</div>
{% endblock %}

</html>
