<%inherit file="base.html"/>
<%
import itertools
c = itertools.cycle(['odd','even'])
%>
<h2>${app['name']} (${app['group']})</h2>
<div id="failed" class="application"  \
    data-name="${app['name']}" \
    data-version="${app['version']}" \
    data-group="${app['group']|h}">
  
  <div class="command" \
        data-queue="${command['queue']}">
  
    <a class="action" data-type="command" data-action="/failed/remove-all" href="#">Remove All</a>
    |
    <a class="action" data-type="command" data-action="/failed/requeue-all" href="#">Requeue All</a>

    <table>

    % for f in failed:
      <%
        color_class = c.next()
      %>
     <tr class="${f['id']} data ${color_class}" data-fid="${f['id']}">
         <td>${f['id']}</td>
         <td>${f['response']['status']}</td>
         <td>${f.get('time')}</td>
         <td>${f['response'].get('error_type')}</td>
         <td>${f['response'].get('error_value')}</td>
         <td><pre>${f['response'].get('traceback')}</pre></td>
     </tr>
     <tr class="${f['id']} actions ${color_class} command" data-fid="${f['id']}" data-queue="${command['queue']}">
       <td colspan="6">
         <small>
           [ <a class="action requeue" data-type="command" data-fail-id="${f['id']}" data-action="/failed/requeue" href="#">requeue</a> ]
           [ <a class="action remove"  data-type="command" data-fail-id="${f['id']}" data-action="/failed/remove" href="#">remove</a> ]
        </small>
       </td>
     </tr>
     <tr class="${f['id']} log ${color_class}" data-fid="${f['id']}"><td colspan="6"></td></tr>
    % endfor
    </table>

  </div>

</div>