image_attachments_panel.html 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. {% load helpers %}
  2. <div class="card">
  3. <h5 class="card-header">
  4. Images
  5. </h5>
  6. <div class="card-body">
  7. {% with images=object.images.all %}
  8. {% if images.exists %}
  9. <table class="table table-hover">
  10. <tr>
  11. <th>Name</th>
  12. <th>Size</th>
  13. <th>Created</th>
  14. <th></th>
  15. </tr>
  16. {% for attachment in images %}
  17. <tr{% if not attachment.size %} class="table-danger"{% endif %}>
  18. <td>
  19. <i class="mdi mdi-file-image-outline"></i>
  20. <a class="image-preview" href="{{ attachment.image.url }}" target="_blank">{{ attachment }}</a>
  21. </td>
  22. <td>{{ attachment.size|filesizeformat }}</td>
  23. <td>{{ attachment.created|annotated_date }}</td>
  24. <td class="text-end noprint">
  25. {% if perms.extras.change_imageattachment %}
  26. <a href="{% url 'extras:imageattachment_edit' pk=attachment.pk %}" class="btn btn-warning btn-sm lh-1" title="Edit Image">
  27. <i class="mdi mdi-pencil" aria-hidden="true"></i>
  28. </a>
  29. {% endif %}
  30. {% if perms.extras.delete_imageattachment %}
  31. <a href="{% url 'extras:imageattachment_delete' pk=attachment.pk %}" class="btn btn-danger btn-sm lh-1" title="Delete Image">
  32. <i class="mdi mdi-trash-can-outline" aria-hidden="true"></i>
  33. </a>
  34. {% endif %}
  35. </td>
  36. </tr>
  37. {% endfor %}
  38. </table>
  39. {% else %}
  40. <div class="text-muted">None</div>
  41. {% endif %}
  42. {% endwith %}
  43. </div>
  44. {% if perms.extras.add_imageattachment %}
  45. <div class="card-footer text-end noprint">
  46. <a href="{% url 'extras:imageattachment_add' %}?content_type={{ object|content_type_id }}&object_id={{ object.pk }}" class="btn btn-primary btn-sm">
  47. <i class="mdi mdi-plus-thick" aria-hidden="true"></i> Attach an image
  48. </a>
  49. </div>
  50. {% endif %}
  51. </div>