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

{% block title %}{% trans 'Edit' %} - {{ title }}{% endblock %}

{% block extra_head %}
    {{ form.media }}
{% endblock %}

{% block content %}

    <h3>{% trans 'Edit' %} {{ title }}</h3>

    {% if form.Meta.model|get_class_name == 'Storage' %}
        {% include 'include/storage_backend_warning.html' %}
    {% endif %}

    <form action="." method="post">
        {% csrf_token %}
        {{ form|crispy }}
        <button href="{{ view.get_success_url }}" class="btn btn-success" type="submit"><i class="fas fa-save"></i> {% trans 'Save' %}</button>
        {% delete_url form.instance|get_class form.instance.pk as delete_view_url %}
        {% if delete_view_url %}
            {% if not object.numchild or object.numchild == 0 %}
                <a href="{{ delete_view_url }}"
                class="btn btn-danger"><i class="fas fa-trash-alt"></i> {% trans 'Delete' %}</a>
            {% endif %}
        {% endif %}
        {% if view_url %}
            <a href="{{ view_url }}" class="btn btn-info"><i class="far fa-eye"></i> {% trans 'View' %}</a>
        {% endif %}
        {% if delete_external_url %}
            <a href="{{ delete_external_url }}" class="btn btn-warning"><i
                    class="fas fa-exclamation-triangle"></i> {% trans 'Delete original file' %}</a>
        {% endif %}
    </form>

{% endblock %}