{% extends "base.html" %}
{% load i18n %}
{% load permissions %}
{% load crispy_forms_tags %}
{% load translations %}

{% block breadcrumbs %}
<li><a href="{{ object.project.get_absolute_url }}">{{ object.project }}</a></li>
<li><a href="{% url 'fonts' project=object.project.slug %}">{% trans "Font groups" %}</a></li>
<li><a href="{{ object.get_absolute_url }}">{{ object }}</a></li>
{% endblock %}

{% block content %}

<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Font group" %}</h4></div>
<table class="table table-striped">
<tr><th>{% trans "Name" %}</th><td colspan="2">{{ object.name }}</td></tr>
<tr><th>{% trans "Default font" %}</th><td colspan="2"><a href="{{ object.font.get_absolute_url }}">{{ object.font }}</a></td></tr>
{% for override in object.fontoverride_set.all %}
<tr>
<th><span class="badge pull-right flip">{% trans "language override" %}</span>{{ override.language }}</th>
<td><a href="{{ override.font.get_absolute_url }}">{{ override.font }}</a></td>
<td>
{% if can_edit %}
<form method="POST">
{% csrf_token %}
<input type="hidden" name="override" value="{{ override.pk }}" />
<button type="submit" class="btn btn-danger"><i class="fa fa-trash"></i> {% trans "Remove" %}</button>
</form>
{% endif %}
</td>
</tr>
{% endfor %}
</table>
<div class="panel-footer">
{% if can_edit %}
<a class="btn btn-danger link-post" href="{{ object.get_absolute_url }}"><i class="fa fa-trash"></i> {% trans "Delete" %}</a>
{% endif %}
</div>
</div>

{% if can_edit %}
<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Add language override" %}</h4></div>
<div class="panel-body">
{{ override_form|crispy }}
</div>
  <div class="panel-footer">
  <input type="submit" class="btn btn-primary" value="{% trans "Save" %}" />
  </div>
</div>
</form>

<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "Edit font group" %}</h4></div>
<div class="panel-body">
{{ form|crispy }}
</div>
  <div class="panel-footer">
  <input type="submit" class="btn btn-primary" value="{% trans "Save" %}" />
  </div>
</div>
</form>
{% endif %}

{% endblock %}
