{% extends "main.html" %}
{% load i18n %}
{% load contest_extras %}

{% block title %}{% trans "Entry " %} {{ entry.id }}{% endblock %}

{% block content %}
<h2>{% trans "Entry " %} {{ entry.id }}</h2>

<ul>
  <li>User: {{ entry.user }}</li>
  <li>Uploaded: {{ entry.uploaded|date:"Y-m-d H:i:s" }}</li>
  <li>Code size: {{ entry.codesize|filesizeformat }}</li>
</ul>

<h2>{% trans "All fights" %}</h2>
<table class="table">
  <thead>
    <tr>
      <th>id</th>
      <th>Opponent</th>
      <th>Your role (x/o)</th>
      <th>{% trans "Result" %}</th>
    </tr>
  </thead>
  {% for fight in fights %}

  <tr class="{{ fight|result_of:entry.user }}">

    <td>{{ fight.id }}</td>
    <td>
      {% if fight.x.user == entry.user %}
        <a href="{{ fight.o.get_absolute_url }}">{{ fight.o }}</a>
      {% else %}
        <a href="{{ fight.x.get_absolute_url }}">{{ fight.x }}</a>
      {% endif %}
    </td>
    <td>
      {% if fight.x.user == entry.user %}x{% else %}o{% endif %}
    </td>
    <td>
      <a href="{{ fight.get_absolute_url }}">{{ fight|result_of:entry.user }}</a>
    </td>
  </tr>
  {% endfor %}
</table>

<h2>{% trans "Code" %} ({{ entry.codesize|filesizeformat }})</h2>
{% if request.user.is_superuser or request.user == entry.user or entry.user.username == "Qualification-Bot" %}
<pre>{{ entry.code }}</pre>
{% else %}
You have to be logged in as admin to see the code.
{% endif %}

{% endblock %}
