Use ObjectRead helper for all list and detail views
This commit is contained in:
72
core/templates/partials/generic-detail.html
Normal file
72
core/templates/partials/generic-detail.html
Normal file
@@ -0,0 +1,72 @@
|
||||
{% load pretty %}
|
||||
{% include 'partials/notify.html' %}
|
||||
|
||||
{% if live is not None %}
|
||||
<h1 class="title">Live {{ context_object_name_singular }} info</h1>
|
||||
<table class="table is-fullwidth is-hoverable">
|
||||
<thead>
|
||||
<th>attribute</th>
|
||||
<th>value</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% block live_tbody %}
|
||||
{% for key, item in live.items %}
|
||||
{% if key in pretty %}
|
||||
<tr>
|
||||
<th>{{ key }}</th>
|
||||
<td>
|
||||
{% if item is not None %}
|
||||
<pre>{{ item|pretty }}</pre>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<th>{{ key }}</th>
|
||||
<td>
|
||||
{% if item is not None %}
|
||||
{{ item }}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
|
||||
{% if object is not None %}
|
||||
<h1 class="title">{{ title_singular }} info</h1>
|
||||
<table class="table is-fullwidth is-hoverable">
|
||||
<thead>
|
||||
<th>attribute</th>
|
||||
<th>value</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% block tbody %}
|
||||
{% for key, item in object.items %}
|
||||
{% if key in pretty %}
|
||||
<tr>
|
||||
<th>{{ key }}</th>
|
||||
<td>
|
||||
{% if item is not None %}
|
||||
<pre>{{ item|pretty }}</pre>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<th>{{ key }}</th>
|
||||
<td>
|
||||
{% if item is not None %}
|
||||
{{ item }}
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endif %}
|
||||
33
core/templates/partials/position-detail.html
Normal file
33
core/templates/partials/position-detail.html
Normal file
@@ -0,0 +1,33 @@
|
||||
{% extends 'partials/generic-detail.html' %}
|
||||
|
||||
{% block tbody %}
|
||||
{% for key, item in object.items %}
|
||||
<tr>
|
||||
{% if key == 'trade_ids' %}
|
||||
<th>{{ key }}</th>
|
||||
<td>
|
||||
{% if item is not None %}
|
||||
{% for trade_id in item %}
|
||||
<button
|
||||
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
|
||||
hx-get="{% url 'trade_action' type=type trade_id=trade_id %}"
|
||||
hx-trigger="click"
|
||||
hx-target="#modals-here"
|
||||
hx-swap="innerHTML"
|
||||
class="button is-small {% if trade_id in valid_trade_ids %}is-primary{% else %}is-warning{% endif %}">
|
||||
{{ trade_id }}
|
||||
</button>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
</td>
|
||||
{% else %}
|
||||
<th>{{ key }}</th>
|
||||
<td>
|
||||
{% if item is not None %}
|
||||
{{ item }}
|
||||
{% endif %}
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user