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

{% block title %}{{ user.username }}{% endblock %}

{% block content %}
 {% if form %}
  <h1>{{ user.username }}</h1>
  <form class="form-horizontal" method="post" action="{% url 'users:rfid::create' %}" enctype="multipart/form-data">
    {% csrf_token %}
    {{ form|crispy }}
    {{ form_blurb|crispy }}
    <div class="control-group">
      <div class="controls">
        <button type="submit" class="btn">Update</button>
      </div>
    </div>
  </form>
  {% else %}
    <table class="table table-striped">
      <thead>
        <tr>
          <th>#</th>
          <th>Code</th>
          <th>Short Description</th>
          <th><a class="btn btn-primary pull-right" href="{% url 'users:rfid:create' %}">Create</a></th>
        </tr>
      </thead>
      {% for rfid in rfids %}
      <tr>
        <th scope="row"> {{ forloop.counter }} </th>
        <td>
          {{ rfid.code }}
        </td>
        <td>
          {{ rfid.description }}
        </td>
        <td>
          <a href="{% url 'users:rfid::delete' rfid.id %}">Delete</a>
        </td>
      </tr>
      {% endfor %}
    </table>
  {% endif %}
{% endblock %}
