{% load storage %}
{% load perms %}

<div class="card">
    <h5 class="card-header">Windows Drives & Partition</h5>
    <div class="card-body">
        {% if partitions %}
        <table class="table table-hover">
            <tr>
                <td>Drive</td>
                <td>Drive Size</td>
                <td>Drive Cluster</td>
                <td>Amount Partition</td>
                <td>Partitions</td>
            </tr>
            {% for partition in partitions %}
            <tr>
                <td>{{ partition.letter|linkify|placeholder }}</td>
                <td>{{ partition.fs_type|linkify|placeholder }}</td>
                <td>{{ partition.size|linkify|placeholder }} MB</td>
                <td>{{ partition.description|linkify|placeholder }}</td>
                <td>{{ partition.drive.identifier|linkify|placeholder }}</td>
                <td>{{ partition.drive.cluster|linkify|placeholder }}</td>
            </tr>
            {% endfor %}
        </table>
        {% else %}
        <div class="text-muted">None</div>
        {% endif %}
    </div>
    {% if perms.netbox_storage.add_drive %}
    <div class="card-footer text-end noprint">
        <a href="{% url 'plugins:netbox_storage:template_partition_add' %}?platform={{ object.id }}&return_url={% url 'dcim:platform' pk=object.pk %}" class="btn btn-sm btn-primary">
            <span class="mdi mdi-plus-thick" aria-hidden="true"></span> Add Partition to drive
        </a>
        {% with object|meta:"model_name" as object_type %}
            <a href="{% url 'plugins:netbox_storage:drive_add' %}?virtual_machine={{ object.pk }}" class="btn btn-sm btn-primary">
                <span class="mdi mdi-plus-thick" aria-hidden="true"></span> Add Drive to Windows VM
            </a>
        {% endwith %}
    </div>
    {% endif %}
</div>