Simplify DB object management with Django CRUD helpers

This commit is contained in:
2022-10-29 12:43:13 +01:00
parent 8f705e2f25
commit c685b6d25f
26 changed files with 435 additions and 936 deletions

View File

@@ -10,7 +10,7 @@
<th>sandbox</th>
<th>actions</th>
</thead>
{% for item in items %}
{% for item in object_list %}
<tr>
<td>{{ item.id }}</td>
<td>{{ item.user }}</td>
@@ -32,7 +32,7 @@
<div class="buttons">
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'account_action' type=type account_id=item.id %}"
hx-get="{% url 'account_update' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
class="button is-info">
@@ -44,9 +44,10 @@
</button>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="{% url 'account_action' type=type account_id=item.id %}"
hx-delete="{% url 'account_delete' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#accounts-table"
hx-target="#modals-here"
hx-confirm="Are you sure you wish to delete {{ item.name }}?"
class="button is-danger">
<span class="icon-text">
<span class="icon">
@@ -55,7 +56,7 @@
</span>
</button>
{% if type == 'page' %}
<a href="{% url 'account_info' type=type account_id=item.id %}"><button
<a href="{% url 'account_info' type=type pk=item.id %}"><button
class="button is-success">
<span class="icon-text">
<span class="icon">
@@ -67,7 +68,7 @@
{% else %}
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'account_info' type=type account_id=item.id %}"
hx-get="{% url 'account_info' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
class="button is-success">

View File

@@ -0,0 +1,49 @@
{% include 'partials/notify.html' %}
<table class="table is-fullwidth is-hoverable" id="callbacks-table">
<thead>
<th>id</th>
<th>hook id</th>
<th>hook name</th>
<th>title</th>
<th>message</th>
<th>period</th>
<th>sent</th>
<th>trade</th>
<th>exchange</th>
<th>symbol</th>
<th>price</th>
<th>contract</th>
<th>actions</th>
</thead>
{% for item in object_list %}
<tr>
<td>{{ item.id }}</td>
<td>{{ item.hook.id }}</td>
<td>
<a
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'hook_update' type=type pk=item.hook.id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here">{{ item.hook.name }}
</a>
</td>
<td>{{ item.title }}</td>
<td>{{ item.message }}</td>
<td>{{ item.period }}</td>
<td>{{ item.sent }}</td>
<td>{{ item.trade }}</td>
<td>{{ item.exchange }}</td>
<td>{{ item.symbol }}</td>
<td>{{ item.price }}</td>
<td>{{ item.contract }}</td>
<td>
<div class="buttons">
</div>
</td>
</tr>
{% endfor %}
</table>

View File

@@ -10,7 +10,7 @@
<th>received hooks</th>
<th>actions</th>
</thead>
{% for item in items %}
{% for item in object_list %}
<tr>
<td>{{ item.id }}</td>
<td>{{ item.user }}</td>
@@ -22,7 +22,7 @@
<div class="buttons">
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'hook_action' type=type hook_id=item.id %}"
hx-get="{% url 'hook_update' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
class="button is-info">
@@ -34,9 +34,10 @@
</button>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="{% url 'hook_action' type=type hook_id=item.id %}"
hx-delete="{% url 'hook_delete' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#hooks-table"
hx-target="#modals-here"
hx-confirm="Are you sure you wish to delete {{ item.name }}?"
class="button is-danger">
<span class="icon-text">
<span class="icon">
@@ -45,7 +46,7 @@
</span>
</button>
{% if type == 'page' %}
<a href="{% url 'callbacks' type='page' hook_id=item.id %}"><button
<a href="{% url 'callbacks' type='page' pk=item.id %}"><button
class="button is-success">
<span class="icon-text">
<span class="icon">
@@ -57,7 +58,7 @@
{% else %}
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'callbacks' type=type hook_id=item.id %}"
hx-get="{% url 'callbacks' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
class="button is-success">

View File

@@ -41,7 +41,8 @@
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="#trade-close-confirm"
hx-trigger="click"
hx-target="#accounts-table"
hx-target="#positions-table"
hx-confirm="Are you sure you wish to close {{ item.symbol }}?"
class="button is-danger">
<span class="icon-text">
<span class="icon">

View File

@@ -11,7 +11,7 @@
<th>SL</th>
<th>actions</th>
</thead>
{% for item in items %}
{% for item in object_list %}
<tr>
<td>{{ item.id }}</td>
<td>{{ item.name }}</td>
@@ -34,7 +34,7 @@
<div class="buttons">
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'strategies_action' type=type strategy_id=item.id %}"
hx-get="{% url 'strategy_update' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
class="button is-info">
@@ -46,9 +46,10 @@
</button>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="{% url 'strategies_action' type=type strategy_id=item.id %}"
hx-delete="{% url 'strategy_delete' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#strategies-table"
hx-target="#modals-here"
hx-confirm="Are you sure you wish to delete {{ item.name }}?"
class="button is-danger">
<span class="icon-text">
<span class="icon">
@@ -57,7 +58,7 @@
</span>
</button>
{% if type == 'page' %}
<a href="{% url 'strategies_action' type=type strategy_id=item.id %}"><button
<a href="#"><button
class="button is-success">
<span class="icon-text">
<span class="icon">
@@ -69,7 +70,7 @@
{% else %}
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'strategies_action' type=type strategy_id=item.id %}"
hx-get="#"
hx-trigger="click"
hx-target="#{{ type }}s-here"
class="button is-success">

View File

@@ -13,7 +13,7 @@
<th>TL</th>
<th>actions</th>
</thead>
{% for item in items %}
{% for item in object_list %}
<tr>
<td>{{ item.id }}</td>
<td>{{ item.status }}</td>
@@ -28,7 +28,7 @@
<div class="buttons">
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'trade_action' type=type trade_id=item.id %}"
hx-get="{% url 'trade_update' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
class="button is-info">
@@ -40,9 +40,9 @@
</button>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="{% url 'trade_action' type=type trade_id=item.id %}"
hx-delete="{% url 'trade_delete' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#trades-table"
hx-target="#modals-here"
class="button is-danger">
<span class="icon-text">
<span class="icon">