object.html 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. {% extends 'generic/_base.html' %}
  2. {% load buttons %}
  3. {% load custom_links %}
  4. {% load helpers %}
  5. {% load perms %}
  6. {% load plugins %}
  7. {% load tabs %}
  8. {% load i18n %}
  9. {% comment %}
  10. Blocks:
  11. - page-header: Content displayed above the primary page content
  12. - breadcrumbs: Breadcrumb list items (HTML <li> elements)
  13. - object_identifier: Unique identifier for the object
  14. - title: Page title
  15. - subtitle: Additional context displayed below the title
  16. - controls: Control elements displayed between the header and content
  17. - control-buttons: Action buttons (add/edit/delete/etc.)
  18. - extra_controls: Any additional action buttons to display
  19. - tabs: Page tabs
  20. - content: Primary page content
  21. - modals: Any pre-loaded modals
  22. Context:
  23. - object: The object being viewed
  24. {% endcomment %}
  25. {% block page-header %}
  26. <div class="container-fluid">
  27. <div class="d-flex justify-content-between align-items-center mt-2">
  28. {# Breadcrumbs #}
  29. <ol class="breadcrumb" aria-label="breadcrumbs">
  30. {% block breadcrumbs %}
  31. <li class="breadcrumb-item">
  32. <a href="{% url object|viewname:'list' %}">{{ object|meta:'verbose_name_plural'|bettertitle }}</a>
  33. </li>
  34. {% endblock breadcrumbs %}
  35. </ol>
  36. {# Object identifier #}
  37. <code class="d-block text-muted bg-transparent px-0">
  38. {% block object_identifier %}
  39. {{ object|meta:"app_label" }}.{{ object|meta:"model_name" }}:{{ object.pk }}
  40. {% if object.slug %}({{ object.slug }}){% endif %}
  41. {% endblock object_identifier %}
  42. </code>
  43. </div>
  44. </div>
  45. {{ block.super }}
  46. {% endblock page-header %}
  47. {% block title %}{{ object }}{% endblock %}
  48. {% block subtitle %}
  49. <div class="text-secondary fs-5">
  50. {% trans "Created" %} {{ object.created|isodatetime:"minutes" }}
  51. {% if object.last_updated %}
  52. <span class="separator">&middot;</span>
  53. {% trans "Updated" %} {{ object.last_updated|isodatetime:"minutes" }}
  54. {% endif %}
  55. </div>
  56. {% endblock subtitle %}
  57. {% block controls %}
  58. <div class="btn-list justify-content-end mb-2">
  59. {% plugin_buttons object %}
  60. {# Add/edit/delete/etc. buttons #}
  61. {% block control-buttons %}
  62. {# Extra buttons #}
  63. {% block extra_controls %}{% endblock %}
  64. {# Default buttons #}
  65. {% if perms.extras.add_bookmark and object.bookmarks %}
  66. {% bookmark_button object %}
  67. {% endif %}
  68. {% if perms.extras.add_subscription and object.subscriptions %}
  69. {% subscribe_button object %}
  70. {% endif %}
  71. {% if request.user|can_add:object %}
  72. {% clone_button object %}
  73. {% endif %}
  74. {% if request.user|can_change:object %}
  75. {% edit_button object %}
  76. {% endif %}
  77. {% if request.user|can_delete:object %}
  78. {% delete_button object %}
  79. {% endif %}
  80. {% endblock control-buttons %}
  81. </div>
  82. {# Custom links #}
  83. <div class="d-flex justify-content-end">
  84. <div class="btn-list">
  85. {% block custom-links %}
  86. {% custom_links object %}
  87. {% endblock custom-links %}
  88. </div>
  89. </div>
  90. {% endblock controls %}
  91. {% block tabs %}
  92. <ul class="nav nav-tabs" role="presentation">
  93. {# Primary tab #}
  94. <li class="nav-item">
  95. <a class="nav-link{% if not tab %} active{% endif %}" href="{{ object.get_absolute_url }}">{{ object|meta:"verbose_name"|bettertitle }}</a>
  96. </li>
  97. {# Include tabs for registered model views #}
  98. {% model_view_tabs object %}
  99. </ul>
  100. {% endblock tabs %}
  101. {% block alerts %}
  102. {% plugin_alerts object %}
  103. {% endblock alerts %}
  104. {% block content %}{% endblock %}
  105. {% block modals %}
  106. {% include 'inc/htmx_modal.html' %}
  107. {% endblock modals %}