custom_fields.html 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. {% load helpers %}
  2. {% with custom_fields=object.get_custom_fields %}
  3. {% if custom_fields %}
  4. <div class="card">
  5. <h5 class="card-header">
  6. Custom Fields
  7. </h5>
  8. <div class="card-body">
  9. <table class="table table-hover attr-table">
  10. {% for field, value in custom_fields.items %}
  11. <tr>
  12. <td><span title="{{ field.description }}">{{ field }}</span></td>
  13. <td>
  14. {% if field.type == 'longtext' and value %}
  15. {{ value|render_markdown }}
  16. {% elif field.type == 'boolean' and value == True %}
  17. <i class="mdi mdi-check-bold text-success" title="True"></i>
  18. {% elif field.type == 'boolean' and value == False %}
  19. <i class="mdi mdi-close-thick text-danger" title="False"></i>
  20. {% elif field.type == 'url' and value %}
  21. <a href="{{ value }}">{{ value|truncatechars:70 }}</a>
  22. {% elif field.type == 'multiselect' and value %}
  23. {{ value|join:", " }}
  24. {% elif value is not None %}
  25. {{ value }}
  26. {% elif field.required %}
  27. <span class="text-warning">Not defined</span>
  28. {% else %}
  29. <span class="text-muted">&mdash;</span>
  30. {% endif %}
  31. </td>
  32. </tr>
  33. {% endfor %}
  34. </table>
  35. </div>
  36. </div>
  37. {% endif %}
  38. {% endwith %}