custom_fields.html 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. {% load helpers %}
  2. {% with custom_fields=object.get_custom_fields %}
  3. {% if custom_fields %}
  4. <div class="card">
  5. <h5 class="card-header">Custom Fields</h5>
  6. <div class="card-body">
  7. <table class="table table-hover attr-table">
  8. {% for field, value in custom_fields.items %}
  9. <tr>
  10. <td>
  11. <span title="{{ field.description|escape }}">{{ field }}</span>
  12. </td>
  13. <td>
  14. {% if field.type == 'integer' and value is not None %}
  15. {{ value }}
  16. {% elif field.type == 'longtext' and value %}
  17. {{ value|markdown }}
  18. {% elif field.type == 'boolean' and value == True %}
  19. {% checkmark value true="True" %}
  20. {% elif field.type == 'boolean' and value == False %}
  21. {% checkmark value false="False" %}
  22. {% elif field.type == 'url' and value %}
  23. <a href="{{ value }}">{{ value|truncatechars:70 }}</a>
  24. {% elif field.type == 'json' and value %}
  25. <pre>{{ value|json }}</pre>
  26. {% elif field.type == 'multiselect' and value %}
  27. {{ value|join:", " }}
  28. {% elif field.type == 'object' and value %}
  29. {{ value|linkify }}
  30. {% elif field.type == 'multiobject' and value %}
  31. {% for obj in value %}
  32. {{ obj|linkify }}{% if not forloop.last %}<br />{% endif %}
  33. {% endfor %}
  34. {% elif value %}
  35. {{ value }}
  36. {% elif field.required %}
  37. <span class="text-warning">Not defined</span>
  38. {% else %}
  39. {{ ''|placeholder }}
  40. {% endif %}
  41. </td>
  42. </tr>
  43. {% endfor %}
  44. </table>
  45. </div>
  46. </div>
  47. {% endif %}
  48. {% endwith %}