{% extends "base.html" %}
{% load humanize %}

{% block title %}
EVE Online - Characters
{% endblock %}


<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
    <!-- Content Header (Page header) -->
    {% block header %}
    EVE Online
    {% endblock %}

    {% block description %}
    View Characters
    {% endblock %}

    <!-- Main content -->
    {% block content %}
    
    <div class="box box-primary">
    <div class="box-body">
    <table class="datatable table table-bordered table-hover">
        <thead>
            <tr>
                <th>Verified</th>
                <th>Character</th>
                <th>Primary Character</th>
                <th>Corporation</th>
                <th>Alliance</th>
            </tr>
        </thead>
        <tbody>
            {% for character in characters %}
            <tr>
                <td>
                {% if character.token %}
                <i class="fa fa-lg fa-check text-success"></i>
                {% else %}
                <i class="fa fa-lg fa-times text-danger"></i>
                {% endif %}
                </td>

                <td>
                    <div class="pull-left" style="padding-right: 8px;">
                       <img width="16px" src="https://imageserver.eveonline.com/Character/{{character.external_id}}_64.jpg" class="img-circle" alt="Avatar"> 
                       {% if 'django_eveonline_connector' in INSTALLED_APPS %}
                       <a href="{% url 'django-eveonline-connector-view-character' character.external_id %}">{{character.name}}</a>
                       {% else %}
                       {{character.name}}
                       {% endif %}
                    </div>
                </td>

                <td>
                    <div class="pull-left" style="padding-right: 8px;">
                    {% if character.token.user.primary_evecharacter %}
                       <img width="16px" src="https://imageserver.eveonline.com/Character/{{character.token.user.primary_evecharacter.get_character.external_id}}_64.jpg" class="img-circle" alt="Avatar"> 
                       {% if 'django_eveonline_connector' in INSTALLED_APPS %}
                       <a href="{% url 'django-eveonline-connector-view-character' character.token.user.primary_evecharacter.get_character.external_id %}">{{character.token.user.primary_evecharacter.get_character.name}}</a>
                       {% else %}
                       {{character.name}}
                       {% endif %}
                    {% endif %}
                    </div>
                </td>

                <td>
                    <img width="16px" src="https://imageserver.eveonline.com/Corporation/{{character.corporation.external_id}}_64.png" class="img-circle" alt="Avatar">
                    {{character.corporation}}
                </td>

                <td>
                {% if character.corporation.alliance %}
                <img width="16px" src="https://imageserver.eveonline.com/Alliance/{{character.corporation.alliance.external_id}}_64.png" class="img-circle" alt="Avatar">
                {{character.corporation.alliance}}
                {% else %}
                None 
                {% endif %}
                </td>
            </tr>
            {% endfor %}
            <!-- Bottom Divider -->
            
        </tbody>
    </table>
    </div>
    </div>
    {% endblock %}
    <!-- /.content -->
</div>

{% block scripts %}
<script>
$(function () {
    $('table').DataTable({
      'paging'      : false,
      'lengthChange': false,
      'searching'   : true,
      'ordering'    : true,
      'info'        : true,
      'autoWidth'   : false
    })
 })
</script>
{% endblock %}