Cache all object list templates

This commit is contained in:
Mark Veidemanis 2023-02-11 14:52:00 +00:00
parent 0acddb2048
commit a0c94b2097
Signed by: m
GPG Key ID: 5ACFCEED46C0904F
16 changed files with 1000 additions and 967 deletions

View File

@ -68,6 +68,9 @@ CACHES = {
}, },
} }
} }
# CACHE_MIDDLEWARE_ALIAS = 'default'
# CACHE_MIDDLEWARE_SECONDS = '600'
# CACHE_MIDDLEWARE_KEY_PREFIX = ''
CRISPY_TEMPLATE_PACK = "bulma" CRISPY_TEMPLATE_PACK = "bulma"
CRISPY_ALLOWED_TEMPLATE_PACKS = ("bulma",) CRISPY_ALLOWED_TEMPLATE_PACKS = ("bulma",)
@ -77,16 +80,15 @@ MIDDLEWARE = [
"debug_toolbar.middleware.DebugToolbarMiddleware", "debug_toolbar.middleware.DebugToolbarMiddleware",
"django.middleware.security.SecurityMiddleware", "django.middleware.security.SecurityMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware", "django.contrib.sessions.middleware.SessionMiddleware",
# 'django.middleware.cache.UpdateCacheMiddleware',
"django.middleware.common.CommonMiddleware", "django.middleware.common.CommonMiddleware",
# 'django.middleware.cache.FetchFromCacheMiddleware',
"django.middleware.csrf.CsrfViewMiddleware", "django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware",
"django_otp.middleware.OTPMiddleware", "django_otp.middleware.OTPMiddleware",
"django.contrib.messages.middleware.MessageMiddleware", "django.contrib.messages.middleware.MessageMiddleware",
"django.middleware.clickjacking.XFrameOptionsMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware",
"django_htmx.middleware.HtmxMiddleware", "django_htmx.middleware.HtmxMiddleware",
# 'django.middleware.cache.UpdateCacheMiddleware',
# 'django.middleware.common.CommonMiddleware',
# 'django.middleware.cache.FetchFromCacheMiddleware',
] ]
ROOT_URLCONF = "app.urls" ROOT_URLCONF = "app.urls"

View File

@ -1,112 +1,114 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_accounts request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
hx-swap="outerHTML" hx-swap="outerHTML"
hx-trigger="{{ context_object_name_singular }}Event from:body" hx-trigger="{{ context_object_name_singular }}Event from:body"
hx-get="{{ list_url }}"> hx-get="{{ list_url }}">
<thead> <thead>
<th>id</th> <th>id</th>
<th>user</th> <th>user</th>
<th>name</th> <th>name</th>
<th>exchange</th> <th>exchange</th>
<th>currency</th> <th>currency</th>
<th>initial</th> <th>initial</th>
<th>API key</th> <th>API key</th>
<th>sandbox</th> <th>sandbox</th>
<th>enabled</th> <th>enabled</th>
<th>actions</th> <th>actions</th>
</thead> </thead>
{% for item in object_list %} {% for item in object_list %}
<tr> <tr>
<td>{{ item.id }}</td> <td>{{ item.id }}</td>
<td>{{ item.user }}</td> <td>{{ item.user }}</td>
<td>{{ item.name }}</td> <td>{{ item.name }}</td>
<td>{{ item.exchange }}</td> <td>{{ item.exchange }}</td>
<td>{{ item.currency }}</td> <td>{{ item.currency }}</td>
<td>{{ item.initial_balance }}</td> <td>{{ item.initial_balance }}</td>
<td>{{ item.api_key }}</td> <td>{{ item.api_key }}</td>
<td> <td>
{% if item.sandbox %} {% if item.sandbox %}
<span class="icon"> <span class="icon">
<i class="fa-solid fa-check"></i> <i class="fa-solid fa-check"></i>
</span>
{% else %}
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
{% endif %}
</td>
<td>
{% if item.enabled %}
<span class="icon">
<i class="fa-solid fa-check"></i>
</span>
{% else %}
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
{% endif %}
</td>
<td>
<div class="buttons">
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'account_update' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
hx-swap="innerHTML"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-pencil"></i>
</span>
</span> </span>
</button>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="{% url 'account_delete' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#modals-here"
hx-swap="innerHTML"
hx-confirm="Are you sure you wish to delete {{ item.name }}?"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
</span>
</button>
{% if type == 'page' %}
<a href="{% url 'account_info' type=type pk=item.id %}"><button
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-eye"></i>
</span>
</span>
</button>
</a>
{% else %} {% else %}
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
{% endif %}
</td>
<td>
{% if item.enabled %}
<span class="icon">
<i class="fa-solid fa-check"></i>
</span>
{% else %}
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
{% endif %}
</td>
<td>
<div class="buttons">
<button <button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'account_info' type=type pk=item.id %}" hx-get="{% url 'account_update' type=type pk=item.id %}"
hx-trigger="click" hx-trigger="click"
hx-target="#{{ type }}s-here" hx-target="#{{ type }}s-here"
hx-swap="innerHTML" hx-swap="innerHTML"
class="button"> class="button">
<span class="icon-text"> <span class="icon-text">
<span class="icon"> <span class="icon">
<i class="fa-solid fa-eye"></i> <i class="fa-solid fa-pencil"></i>
</span> </span>
</span> </span>
</button> </button>
{% endif %} <button
</div> hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
</td> hx-delete="{% url 'account_delete' type=type pk=item.id %}"
</tr> hx-trigger="click"
{% endfor %} hx-target="#modals-here"
hx-swap="innerHTML"
hx-confirm="Are you sure you wish to delete {{ item.name }}?"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
</span>
</button>
{% if type == 'page' %}
<a href="{% url 'account_info' type=type pk=item.id %}"><button
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-eye"></i>
</span>
</span>
</button>
</a>
{% else %}
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'account_info' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
hx-swap="innerHTML"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-eye"></i>
</span>
</span>
</button>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,72 +1,74 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_assetgroups request.user.id object_list %}
<table
class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table"
id="{{ context_object_name }}-table"
hx-swap="outerHTML"
hx-trigger="{{ context_object_name_singular }}Event from:body"
hx-get="{{ list_url }}">
<thead>
<th>id</th>
<th>user</th>
<th>name</th>
<th>description</th>
<th>account</th>
<th>status</th>
<th>restrictions</th>
<th>actions</th>
</thead>
{% for item in object_list %}
<tr>
<td>{{ item.id }}</td>
<td>{{ item.user }}</td>
<td>{{ item.name }}</td>
<td>{{ item.description }}</td>
<td>{{ item.account }}</td>
<td>{{ item.matches }}</td>
<td>{{ item.restrictions }}</td>
<td>
<div class="buttons">
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'assetgroup_update' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
hx-swap="innerHTML"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-pencil"></i>
</span>
</span>
</button>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="{% url 'assetgroup_delete' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#modals-here"
hx-swap="innerHTML"
hx-confirm="Are you sure you wish to delete {{ item.name }}?"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
</span>
</button>
<a href="{% url 'assetrestrictions' type='page' group=item.id %}"><button
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-eye"></i>
</span>
</span>
</button>
</a>
</div>
</td>
</tr>
{% endfor %}
<table </table>
class="table is-fullwidth is-hoverable" {% endcache %}
hx-target="#{{ context_object_name }}-table"
id="{{ context_object_name }}-table"
hx-swap="outerHTML"
hx-trigger="{{ context_object_name_singular }}Event from:body"
hx-get="{{ list_url }}">
<thead>
<th>id</th>
<th>user</th>
<th>name</th>
<th>description</th>
<th>account</th>
<th>status</th>
<th>restrictions</th>
<th>actions</th>
</thead>
{% for item in object_list %}
<tr>
<td>{{ item.id }}</td>
<td>{{ item.user }}</td>
<td>{{ item.name }}</td>
<td>{{ item.description }}</td>
<td>{{ item.account }}</td>
<td>{{ item.matches }}</td>
<td>{{ item.restrictions }}</td>
<td>
<div class="buttons">
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'assetgroup_update' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
hx-swap="innerHTML"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-pencil"></i>
</span>
</span>
</button>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="{% url 'assetgroup_delete' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#modals-here"
hx-swap="innerHTML"
hx-confirm="Are you sure you wish to delete {{ item.name }}?"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
</span>
</button>
<a href="{% url 'assetrestrictions' type='page' group=item.id %}"><button
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-eye"></i>
</span>
</span>
</button>
</a>
</div>
</td>
</tr>
{% endfor %}
</table>

View File

@ -1,71 +1,73 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_assetrestrictions request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
hx-swap="outerHTML" hx-swap="outerHTML"
hx-trigger="{{ context_object_name_singular }}Event from:body" hx-trigger="{{ context_object_name_singular }}Event from:body"
hx-get="{{ list_url }}"> hx-get="{{ list_url }}">
<thead> <thead>
<th>id</th> <th>id</th>
<th>user</th> <th>user</th>
<th>name</th> <th>name</th>
<th>description</th> <th>description</th>
<th>pairs</th> <th>pairs</th>
<th>group</th> <th>group</th>
<th>hook</th> <th>hook</th>
<th>actions</th> <th>actions</th>
</thead> </thead>
{% for item in object_list %} {% for item in object_list %}
<tr> <tr>
<td>{{ item.id }}</td> <td>{{ item.id }}</td>
<td>{{ item.user }}</td> <td>{{ item.user }}</td>
<td>{{ item.name }}</td> <td>{{ item.name }}</td>
<td>{{ item.description }}</td> <td>{{ item.description }}</td>
<td>{{ item.pairs_parsed|length }}</td> <td>{{ item.pairs_parsed|length }}</td>
<td>{{ item.group }}</td> <td>{{ item.group }}</td>
<td> <td>
<a <a
class="has-text-grey" class="has-text-grey"
onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{settings.URL}}/{{settings.ASSET_PATH}}/{{ item.webhook_id }}/');"> onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{settings.URL}}/{{settings.ASSET_PATH}}/{{ item.webhook_id }}/');">
<span class="icon" data-tooltip="Copy to clipboard"> <span class="icon" data-tooltip="Copy to clipboard">
<i class="fa-solid fa-copy" aria-hidden="true"></i> <i class="fa-solid fa-copy" aria-hidden="true"></i>
</span>
</a>
</td>
<td>
<div class="buttons">
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'assetrestriction_update' type=type group=item.group.id pk=item.id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
hx-swap="innerHTML"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-pencil"></i>
</span>
</span> </span>
</button> </a>
<button </td>
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' <td>
hx-delete="{% url 'assetrestriction_delete' type=type group=item.group.id pk=item.id %}" <div class="buttons">
hx-trigger="click" <button
hx-target="#modals-here" hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-swap="innerHTML" hx-get="{% url 'assetrestriction_update' type=type group=item.group.id pk=item.id %}"
hx-confirm="Are you sure you wish to delete {{ item.name }}?" hx-trigger="click"
class="button"> hx-target="#{{ type }}s-here"
<span class="icon-text"> hx-swap="innerHTML"
<span class="icon"> class="button">
<i class="fa-solid fa-xmark"></i> <span class="icon-text">
<span class="icon">
<i class="fa-solid fa-pencil"></i>
</span>
</span> </span>
</span> </button>
</button> <button
</div> hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
</td> hx-delete="{% url 'assetrestriction_delete' type=type group=item.group.id pk=item.id %}"
</tr> hx-trigger="click"
{% endfor %} hx-target="#modals-here"
hx-swap="innerHTML"
hx-confirm="Are you sure you wish to delete {{ item.name }}?"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
</span>
</button>
</div>
</td>
</tr>
{% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,50 +1,52 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_callbacks request.user.id object_list %}
<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"
hx-swap="innerHTML">{{ 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>
<table class="table is-fullwidth is-hoverable" id="callbacks-table"> <td>
<thead> <div class="buttons">
<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"
hx-swap="innerHTML">{{ 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>
<div class="buttons"> </td>
</tr>
{% endfor %}
</div> </table>
</td> {% endcache %}
</tr>
{% endfor %}
</table>

View File

@ -1,92 +1,94 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_hooks request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
hx-swap="outerHTML" hx-swap="outerHTML"
hx-trigger="{{ context_object_name_singular }}Event from:body" hx-trigger="{{ context_object_name_singular }}Event from:body"
hx-get="{{ list_url }}"> hx-get="{{ list_url }}">
<thead> <thead>
<th>id</th> <th>id</th>
<th>user</th> <th>user</th>
<th>name</th> <th>name</th>
<th>hook</th> <th>hook</th>
<th>received hooks</th> <th>received hooks</th>
<th>actions</th> <th>actions</th>
</thead> </thead>
{% for item in object_list %} {% for item in object_list %}
<tr> <tr>
<td>{{ item.id }}</td> <td>{{ item.id }}</td>
<td>{{ item.user }}</td> <td>{{ item.user }}</td>
<td>{{ item.name }}</td> <td>{{ item.name }}</td>
<td> <td>
<a <a
class="has-text-grey" class="has-text-grey"
onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{settings.URL}}/{{settings.HOOK_PATH}}/{{ item.hook }}/');"> onclick="window.prompt('Copy to clipboard: Ctrl+C, Enter', '{{settings.URL}}/{{settings.HOOK_PATH}}/{{ item.hook }}/');">
<span class="icon" data-tooltip="Copy to clipboard"> <span class="icon" data-tooltip="Copy to clipboard">
<i class="fa-solid fa-copy" aria-hidden="true"></i> <i class="fa-solid fa-copy" aria-hidden="true"></i>
</span>
</a>
</td>
<td>{{ item.received }}</td>
<td>
<div class="buttons">
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'hook_update' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
hx-swap="innerHTML"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-pencil"></i>
</span>
</span> </span>
</button> </a>
<button </td>
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' <td>{{ item.received }}</td>
hx-delete="{% url 'hook_delete' type=type pk=item.id %}" <td>
hx-trigger="click" <div class="buttons">
hx-target="#modals-here"
hx-swap="innerHTML"
hx-confirm="Are you sure you wish to delete {{ item.name }}?"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
</span>
</button>
{% if type == 'page' %}
<a href="{% url 'callbacks' type='page' object_type='hook' object_id=item.id %}"><button
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-eye"></i>
</span>
</span>
</button>
</a>
{% else %}
<button <button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'callbacks' type=type object_type='hook' object_id=item.id %}" hx-get="{% url 'hook_update' type=type pk=item.id %}"
hx-trigger="click" hx-trigger="click"
hx-target="#{{ type }}s-here" hx-target="#{{ type }}s-here"
hx-swap="innerHTML" hx-swap="innerHTML"
class="button"> class="button">
<span class="icon-text"> <span class="icon-text">
<span class="icon"> <span class="icon">
<i class="fa-solid fa-eye"></i> <i class="fa-solid fa-pencil"></i>
</span> </span>
</span> </span>
</button> </button>
{% endif %} <button
</div> hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
</td> hx-delete="{% url 'hook_delete' type=type pk=item.id %}"
</tr> hx-trigger="click"
{% endfor %} hx-target="#modals-here"
hx-swap="innerHTML"
hx-confirm="Are you sure you wish to delete {{ item.name }}?"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
</span>
</button>
{% if type == 'page' %}
<a href="{% url 'callbacks' type='page' object_type='hook' object_id=item.id %}"><button
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-eye"></i>
</span>
</span>
</button>
</a>
{% else %}
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'callbacks' type=type object_type='hook' object_id=item.id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
hx-swap="innerHTML"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-eye"></i>
</span>
</span>
</button>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,33 +1,36 @@
{% extends 'partials/generic-detail.html' %} {% extends 'partials/generic-detail.html' %}
{% load cache %}
{% block tbody %} {% block tbody %}
{% for key, item in object.items %} {% cache 600 object_position_detail request.user.id object %}
<tr> {% for key, item in object.items %}
{% if key == 'trade_ids' %} <tr>
<th>{{ key }}</th> {% if key == 'trade_ids' %}
<td> <th>{{ key }}</th>
{% if item is not None %} <td>
{% for trade_id in item %} {% if item is not None %}
<button {% for trade_id in item %}
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' <button
hx-get="{% url 'trade_action' type=type account_id=object.account_id trade_id=trade_id %}" hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-trigger="click" hx-get="{% url 'trade_action' type=type account_id=object.account_id trade_id=trade_id %}"
hx-target="#modals-here" hx-trigger="click"
hx-swap="innerHTML" hx-target="#modals-here"
class="button is-small {% if trade_id in valid_trade_ids %}is-primary{% else %}is-warning{% endif %}"> hx-swap="innerHTML"
{{ trade_id }} class="button is-small {% if trade_id in valid_trade_ids %}is-primary{% else %}is-warning{% endif %}">
</button> {{ trade_id }}
{% endfor %} </button>
{% endif %} {% endfor %}
</td> {% endif %}
{% else %} </td>
<th>{{ key }}</th> {% else %}
<td> <th>{{ key }}</th>
{% if item is not None %} <td>
{{ item }} {% if item is not None %}
{% endif %} {{ item }}
</td> {% endif %}
{% endif %} </td>
</tr> {% endif %}
{% endfor %} </tr>
{% endfor %}
{% endcache %}
{% endblock %} {% endblock %}

View File

@ -1,76 +1,93 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
<table {% cache 600 objects_positions request.user.id object_list %}
class="table is-fullwidth is-hoverable" <table
hx-target="#{{ context_object_name }}-table" class="table is-fullwidth is-hoverable"
id="{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
hx-swap="outerHTML" id="{{ context_object_name }}-table"
hx-trigger="{{ context_object_name_singular }}Event from:body, every 5s" hx-swap="outerHTML"
hx-get="{{ list_url }}"> hx-trigger="{{ context_object_name_singular }}Event from:body, every 5s"
<thead> hx-get="{{ list_url }}">
<th>account</th> <thead>
<th>asset</th> <th>account</th>
<th>price</th> <th>asset</th>
<th>units</th> <th>price</th>
<th>quote</th> <th>units</th>
<th>P/L</th> <th>quote</th>
<th>side</th> <th>P/L</th>
<th>trades</th> <th>side</th>
<th>actions</th> <th>trades</th>
</thead> <th>actions</th>
{% for item in object_list %} </thead>
<tr class=" {% for item in object_list %}
{% if item.unrealized_pl > 0 %}has-background-success-light <tr class="
{% elif item.unrealized_pl < 0 %}has-background-danger-light {% if item.unrealized_pl > 0 %}has-background-success-light
{% endif %}"> {% elif item.unrealized_pl < 0 %}has-background-danger-light
<td>{{ item.account }}</td> {% endif %}">
<td>{{ item.symbol }}</td> <td>{{ item.account }}</td>
<td>{{ item.price }}</td> <td>{{ item.symbol }}</td>
<td>{{ item.units }}</td> <td>{{ item.price }}</td>
<td>{{ item.value }}</td> <td>{{ item.units }}</td>
<td>{{ item.unrealized_pl }}</td> <td>{{ item.value }}</td>
<td> <td>{{ item.unrealized_pl }}</td>
{% if item.side == 'long' %} <td>
<span class="icon has-text-success" data-tooltip="long"> {% if item.side == 'long' %}
<i class="fa-solid fa-up"></i> <span class="icon has-text-success" data-tooltip="long">
</span> <i class="fa-solid fa-up"></i>
{% elif item.side == 'short' %}
<span class="icon has-text-danger" data-tooltip="short">
<i class="fa-solid fa-down"></i>
</span>
{% endif %}
</td>
<td>{{ item.trade_ids|length }}</td>
<td>
<div class="buttons">
<!-- <button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#"
hx-trigger="click"
hx-target="#{{ type }}s-here"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-pencil"></i>
</span>
</span> </span>
</button> --> {% elif item.side == 'short' %}
<button <span class="icon has-text-danger" data-tooltip="short">
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' <i class="fa-solid fa-down"></i>
hx-delete="{% url 'position_action' side=item.side account_id=item.account_id symbol=item.symbol %}"
hx-trigger="click"
hx-target="#notification"
hx-swap="outerHTML"
hx-confirm="Are you sure you wish to close {{ item.symbol }}?"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
</span> </span>
</button> {% endif %}
{% if type == 'page' %} </td>
<a href="{% url 'position_action' type=type account_id=item.account_id symbol=item.symbol %}"> <td>{{ item.trade_ids|length }}</td>
<td>
<div class="buttons">
<!-- <button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="#"
hx-trigger="click"
hx-target="#{{ type }}s-here"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-pencil"></i>
</span>
</span>
</button> -->
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="{% url 'position_action' side=item.side account_id=item.account_id symbol=item.symbol %}"
hx-trigger="click"
hx-target="#notification"
hx-swap="outerHTML"
hx-confirm="Are you sure you wish to close {{ item.symbol }}?"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
</span>
</button>
{% if type == 'page' %}
<a href="{% url 'position_action' type=type account_id=item.account_id symbol=item.symbol %}">
<button
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-eye"></i>
</span>
</span>
</button>
</a>
{% else %}
<button <button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'position_action' type=type account_id=item.account_id symbol=item.symbol %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
hx-swap="innerHTML"
class="button"> class="button">
<span class="icon-text"> <span class="icon-text">
<span class="icon"> <span class="icon">
@ -78,25 +95,11 @@
</span> </span>
</span> </span>
</button> </button>
</a> {% endif %}
{% else %} </div>
<button </td>
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' </tr>
hx-get="{% url 'position_action' type=type account_id=item.account_id symbol=item.symbol %}" {% endfor %}
hx-trigger="click"
hx-target="#{{ type }}s-here"
hx-swap="innerHTML"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-eye"></i>
</span>
</span>
</button>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,48 +1,49 @@
{% load static %} {% load static %}
{% load cache %}
{% for plan in plans %} {% cache 600 objects_plans request.user.id plans %}
{% for plan in plans %}
<div class="box"> <div class="box">
<article class="media"> <article class="media">
<div class="media-left"> <div class="media-left">
<figure class="image is-64x64"> <figure class="image is-64x64">
<img src="{% static plan.image %}" alt="Image"> <img src="{% static plan.image %}" alt="Image">
</figure> </figure>
</div>
<div class="media-content">
<div class="content">
<p class="subtitle">
<strong>{{ plan.name }}</strong> <small>£{{ plan.cost }}</small>
{% if plan in user_plans %}
<i class="fas fa-check" aria-hidden="true"></i>
{% endif %}
<br>
{{ plan.description }}
</p>
</div> </div>
<nav class="level is-mobile"> <div class="media-content">
<div class="level-left"> <div class="content">
{% if plan not in user_plans %} <p class="subtitle">
<a class="level-item" href="/order/{{ plan.name }}"> <strong>{{ plan.name }}</strong> <small>£{{ plan.cost }}</small>
<span class="icon is-small has-text-success"> {% if plan in user_plans %}
<i class="fas fa-plus" aria-hidden="true"></i> <i class="fas fa-check" aria-hidden="true"></i>
</span> {% endif %}
</a> <br>
{% endif %} {{ plan.description }}
</p>
{% if plan in user_plans %}
<a class="level-item" href="/cancel_subscription/{{ plan.name }}">
<span class="icon is-small has-text-info">
<i class="fas fa-cancel" aria-hidden="true"></i>
</span>
</a>
{% endif %}
</div> </div>
</nav> <nav class="level is-mobile">
</div> <div class="level-left">
</article> {% if plan not in user_plans %}
</div> <a class="level-item" href="/order/{{ plan.name }}">
{% endfor %} <span class="icon is-small has-text-success">
<i class="fas fa-plus" aria-hidden="true"></i>
</span>
</a>
{% endif %}
{% if plan in user_plans %}
<a class="level-item" href="/cancel_subscription/{{ plan.name }}">
<span class="icon is-small has-text-info">
<i class="fas fa-cancel" aria-hidden="true"></i>
</span>
</a>
{% endif %}
</div>
</nav>
</div>
</article>
</div>
{% endfor %}
{% endcache %}

View File

@ -1,32 +1,34 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_profit request.user.id object_list %}
<table
class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table"
id="{{ context_object_name }}-table"
hx-swap="outerHTML"
hx-trigger="{{ context_object_name_singular }}Event from:body, every 3s"
hx-get="{{ list_url }}">
<thead>
<th>id</th>
<th>name</th>
<th>P/L</th>
<th>trade</th>
<th>balance</th>
<th>currency</th>
</thead>
{% for item in object_list %}
<tr class="
{% if item.pl > 0 %}has-background-success-light
{% elif item.pl < 0 %}has-background-danger-light
{% endif %}">
<td>{{ item.account.id }}</td>
<td>{{ item.account.name }}</td>
<td>{{ item.pl }}</td>
<td>{{ item.unrealizedPL }}</td>
<td>{{ item.balance }}</td>
<td>{{ item.currency }}</td>
</tr>
{% endfor %}
<table </table>
class="table is-fullwidth is-hoverable" {% endcache %}
hx-target="#{{ context_object_name }}-table"
id="{{ context_object_name }}-table"
hx-swap="outerHTML"
hx-trigger="{{ context_object_name_singular }}Event from:body, every 3s"
hx-get="{{ list_url }}">
<thead>
<th>id</th>
<th>name</th>
<th>P/L</th>
<th>trade</th>
<th>balance</th>
<th>currency</th>
</thead>
{% for item in object_list %}
<tr class="
{% if item.pl > 0 %}has-background-success-light
{% elif item.pl < 0 %}has-background-danger-light
{% endif %}">
<td>{{ item.account.id }}</td>
<td>{{ item.account.name }}</td>
<td>{{ item.pl }}</td>
<td>{{ item.unrealizedPL }}</td>
<td>{{ item.balance }}</td>
<td>{{ item.currency }}</td>
</tr>
{% endfor %}
</table>

View File

@ -1,65 +1,67 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_risk request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
hx-swap="outerHTML" hx-swap="outerHTML"
hx-trigger="{{ context_object_name_singular }}Event from:body" hx-trigger="{{ context_object_name_singular }}Event from:body"
hx-get="{{ list_url }}"> hx-get="{{ list_url }}">
<thead> <thead>
<th>id</th> <th>id</th>
<th>user</th> <th>user</th>
<th>name</th> <th>name</th>
<th>description</th> <th>description</th>
<th>max loss percent</th> <th>max loss percent</th>
<th>max risk percent</th> <th>max risk percent</th>
<th>max open trades</th> <th>max open trades</th>
<th>max open trades per symbol</th> <th>max open trades per symbol</th>
<th>actions</th> <th>actions</th>
</thead> </thead>
{% for item in object_list %} {% for item in object_list %}
<tr> <tr>
<td>{{ item.id }}</td> <td>{{ item.id }}</td>
<td>{{ item.user }}</td> <td>{{ item.user }}</td>
<td>{{ item.name }}</td> <td>{{ item.name }}</td>
<td>{{ item.description }}</td> <td>{{ item.description }}</td>
<td>{{ item.max_loss_percent }}</td> <td>{{ item.max_loss_percent }}</td>
<td>{{ item.max_risk_percent }}</td> <td>{{ item.max_risk_percent }}</td>
<td>{{ item.max_open_trades }}</td> <td>{{ item.max_open_trades }}</td>
<td>{{ item.max_open_trades_per_symbol }}</td> <td>{{ item.max_open_trades_per_symbol }}</td>
<td> <td>
<div class="buttons"> <div class="buttons">
<button <button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'risk_update' type=type pk=item.id %}" hx-get="{% url 'risk_update' type=type pk=item.id %}"
hx-trigger="click" hx-trigger="click"
hx-target="#{{ type }}s-here" hx-target="#{{ type }}s-here"
hx-swap="innerHTML" hx-swap="innerHTML"
class="button"> class="button">
<span class="icon-text"> <span class="icon-text">
<span class="icon"> <span class="icon">
<i class="fa-solid fa-pencil"></i> <i class="fa-solid fa-pencil"></i>
</span>
</span> </span>
</span> </button>
</button> <button
<button hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-delete="{% url 'risk_delete' type=type pk=item.id %}"
hx-delete="{% url 'risk_delete' type=type pk=item.id %}" hx-trigger="click"
hx-trigger="click" hx-target="#modals-here"
hx-target="#modals-here" hx-swap="innerHTML"
hx-swap="innerHTML" hx-confirm="Are you sure you wish to delete {{ item.name }}?"
hx-confirm="Are you sure you wish to delete {{ item.name }}?" class="button">
class="button"> <span class="icon-text">
<span class="icon-text"> <span class="icon">
<span class="icon"> <i class="fa-solid fa-xmark"></i>
<i class="fa-solid fa-xmark"></i> </span>
</span> </span>
</span> </button>
</button> </div>
</div> </td>
</td> </tr>
</tr> {% endfor %}
{% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,99 +1,101 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_signals request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
hx-swap="outerHTML" hx-swap="outerHTML"
hx-trigger="{{ context_object_name_singular }}Event from:body" hx-trigger="{{ context_object_name_singular }}Event from:body"
hx-get="{{ list_url }}"> hx-get="{{ list_url }}">
<thead> <thead>
<th>id</th> <th>id</th>
<th>user</th> <th>user</th>
<th>name</th> <th>name</th>
<th>signal</th> <th>signal</th>
<th>hook</th> <th>hook</th>
<th>direction</th> <th>direction</th>
<th>received hooks</th> <th>received hooks</th>
<th>actions</th> <th>actions</th>
</thead> </thead>
{% for item in object_list %} {% for item in object_list %}
<tr class=" <tr class="
{% if item.direction == 'buy' %}has-background-success-light {% if item.direction == 'buy' %}has-background-success-light
{% elif item.direction == 'sell' %}has-background-danger-light {% elif item.direction == 'sell' %}has-background-danger-light
{% endif %}"> {% endif %}">
<td>{{ item.id }}</td> <td>{{ item.id }}</td>
<td>{{ item.user }}</td> <td>{{ item.user }}</td>
<td>{{ item.name }}</td> <td>{{ item.name }}</td>
<td>{{ item.signal }}</td> <td>{{ item.signal }}</td>
<td> <td>
<a <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"
hx-swap="innerHTML">{{ item.hook.name }}
</a>
</td>
<td>{{ item.direction }}</td>
<td>{{ item.received }}</td>
<td>
<div class="buttons">
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'signal_update' type=type pk=item.id %}" hx-get="{% url 'hook_update' type=type pk=item.hook.id %}"
hx-trigger="click" hx-trigger="click"
hx-target="#{{ type }}s-here" hx-target="#{{ type }}s-here"
hx-swap="innerHTML" hx-swap="innerHTML">{{ item.hook.name }}
class="button"> </a>
<span class="icon-text"> </td>
<span class="icon"> <td>{{ item.direction }}</td>
<i class="fa-solid fa-pencil"></i> <td>{{ item.received }}</td>
</span> <td>
</span> <div class="buttons">
</button>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="{% url 'signal_delete' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#modals-here"
hx-swap="innerHTML"
hx-confirm="Are you sure you wish to delete {{ item.name }}?"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
</span>
</button>
{% if type == 'page' %}
<a href="{% url 'callbacks' type='page' object_type='signal' object_id=item.id %}"><button
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-eye"></i>
</span>
</span>
</button>
</a>
{% else %}
<button <button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'callbacks' type=type object_type='signal' object_id=item.id %}" hx-get="{% url 'signal_update' type=type pk=item.id %}"
hx-trigger="click" hx-trigger="click"
hx-target="#{{ type }}s-here" hx-target="#{{ type }}s-here"
hx-swap="innerHTML" hx-swap="innerHTML"
class="button"> class="button">
<span class="icon-text"> <span class="icon-text">
<span class="icon"> <span class="icon">
<i class="fa-solid fa-eye"></i> <i class="fa-solid fa-pencil"></i>
</span> </span>
</span> </span>
</button> </button>
{% endif %} <button
</div> hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
</td> hx-delete="{% url 'signal_delete' type=type pk=item.id %}"
</tr> hx-trigger="click"
{% endfor %} hx-target="#modals-here"
hx-swap="innerHTML"
hx-confirm="Are you sure you wish to delete {{ item.name }}?"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
</span>
</button>
{% if type == 'page' %}
<a href="{% url 'callbacks' type='page' object_type='signal' object_id=item.id %}"><button
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-eye"></i>
</span>
</span>
</button>
</a>
{% else %}
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'callbacks' type=type object_type='signal' object_id=item.id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
hx-swap="innerHTML"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-eye"></i>
</span>
</span>
</button>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,98 +1,100 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_strategies request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
hx-swap="outerHTML" hx-swap="outerHTML"
hx-trigger="{{ context_object_name_singular }}Event from:body" hx-trigger="{{ context_object_name_singular }}Event from:body"
hx-get="{{ list_url }}"> hx-get="{{ list_url }}">
<thead> <thead>
<th>id</th> <th>id</th>
<th>name</th> <th>name</th>
<th>description</th> <th>description</th>
<th>account</th> <th>account</th>
<th>enabled</th> <th>enabled</th>
<th>TP</th> <th>TP</th>
<th>SL</th> <th>SL</th>
<th>actions</th> <th>actions</th>
</thead> </thead>
{% for item in object_list %} {% for item in object_list %}
<tr> <tr>
<td>{{ item.id }}</td> <td>{{ item.id }}</td>
<td>{{ item.name }}</td> <td>{{ item.name }}</td>
<td>{{ item.description|truncatechars:80 }}</td> <td>{{ item.description|truncatechars:80 }}</td>
<td>{{ item.account }}</td> <td>{{ item.account }}</td>
<td> <td>
{% if item.enabled %} {% if item.enabled %}
<span class="icon"> <span class="icon">
<i class="fa-solid fa-check"></i> <i class="fa-solid fa-check"></i>
</span>
{% else %}
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
{% endif %}
</td>
<td>{{ item.take_profit_percent }}</td>
<td>{{ item.stop_loss_percent }}</td>
<td>
<div class="buttons">
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'strategy_update' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
hx-swap="innerHTML"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-pencil"></i>
</span>
</span> </span>
</button>
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-delete="{% url 'strategy_delete' type=type pk=item.id %}"
hx-trigger="click"
hx-target="#modals-here"
hx-swap="innerHTML"
hx-confirm="Are you sure you wish to delete {{ item.name }}?"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
</span>
</button>
{% if type == 'page' %}
<a href="{% url 'trenddirections' type=type strategy_id=item.id %}"><button
class="button">
<span class="icon-text">
<span class="icon" data-tooltip="View trends">
<i class="fa-solid fa-arrows-up-down"></i>
</span>
</span>
</button>
</a>
{% else %} {% else %}
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
{% endif %}
</td>
<td>{{ item.take_profit_percent }}</td>
<td>{{ item.stop_loss_percent }}</td>
<td>
<div class="buttons">
<button <button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'trenddirections' type=type strategy_id=item.id %}" hx-get="{% url 'strategy_update' type=type pk=item.id %}"
hx-trigger="click" hx-trigger="click"
hx-target="#{{ type }}s-here" hx-target="#{{ type }}s-here"
hx-swap="innerHTML" hx-swap="innerHTML"
class="button"> class="button">
<span class="icon-text"> <span class="icon-text">
<span class="icon" data-tooltip="View trends"> <span class="icon">
<i class="fa-solid fa-arrows-up-down"></i> <i class="fa-solid fa-pencil"></i>
</span> </span>
</span> </span>
</button> </button>
{% endif %} <button
</div> hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
</td> hx-delete="{% url 'strategy_delete' type=type pk=item.id %}"
</tr> hx-trigger="click"
{% endfor %} hx-target="#modals-here"
hx-swap="innerHTML"
hx-confirm="Are you sure you wish to delete {{ item.name }}?"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-xmark"></i>
</span>
</span>
</button>
{% if type == 'page' %}
<a href="{% url 'trenddirections' type=type strategy_id=item.id %}"><button
class="button">
<span class="icon-text">
<span class="icon" data-tooltip="View trends">
<i class="fa-solid fa-arrows-up-down"></i>
</span>
</span>
</button>
</a>
{% else %}
<button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'trenddirections' type=type strategy_id=item.id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
hx-swap="innerHTML"
class="button">
<span class="icon-text">
<span class="icon" data-tooltip="View trends">
<i class="fa-solid fa-arrows-up-down"></i>
</span>
</span>
</button>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,66 +1,82 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_trades request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
hx-swap="outerHTML" hx-swap="outerHTML"
hx-trigger="{{ context_object_name_singular }}Event from:body" hx-trigger="{{ context_object_name_singular }}Event from:body"
hx-get="{{ list_url }}"> hx-get="{{ list_url }}">
<thead> <thead>
<th>id</th> <th>id</th>
<th>status</th> <th>status</th>
<th>account id</th> <th>account id</th>
<th>symbol</th> <th>symbol</th>
<th>type</th> <th>type</th>
<th>amount</th> <th>amount</th>
<th>price</th> <th>price</th>
<th>SL</th> <th>SL</th>
<th>TL</th> <th>TL</th>
<th>actions</th> <th>actions</th>
</thead> </thead>
{% for item in object_list %} {% for item in object_list %}
<tr> <tr>
<td>{{ item.id }}</td> <td>{{ item.id }}</td>
<td>{{ item.status }}</td> <td>{{ item.status }}</td>
<td>{{ item.account.id }}</td> <td>{{ item.account.id }}</td>
<td>{{ item.symbol }}</td> <td>{{ item.symbol }}</td>
<td>{{ item.type }}</td> <td>{{ item.type }}</td>
<td>{{ item.amount }}</td> <td>{{ item.amount }}</td>
<td>{{ item.price }}</td> <td>{{ item.price }}</td>
<td>{{ item.stop_loss }}</td> <td>{{ item.stop_loss }}</td>
<td>{{ item.take_profit }}</td> <td>{{ item.take_profit }}</td>
<td> <td>
<div class="buttons"> <div class="buttons">
<button <button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'trade_update' type=type pk=item.id %}" hx-get="{% url 'trade_update' type=type pk=item.id %}"
hx-trigger="click" hx-trigger="click"
hx-target="#{{ type }}s-here" hx-target="#{{ type }}s-here"
hx-swap="innerHTML" hx-swap="innerHTML"
class="button"> class="button">
<span class="icon-text"> <span class="icon-text">
<span class="icon"> <span class="icon">
<i class="fa-solid fa-pencil"></i> <i class="fa-solid fa-pencil"></i>
</span>
</span> </span>
</span> </button>
</button> <button
<button hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-delete="{% url 'trade_delete' type=type pk=item.id %}"
hx-delete="{% url 'trade_delete' type=type pk=item.id %}" hx-trigger="click"
hx-trigger="click" hx-target="#modals-here"
hx-target="#modals-here" hx-swap="innerHTML"
hx-swap="innerHTML" class="button">
class="button"> <span class="icon-text">
<span class="icon-text"> <span class="icon">
<span class="icon"> <i class="fa-solid fa-xmark"></i>
<i class="fa-solid fa-xmark"></i> </span>
</span> </span>
</span> </button>
</button> {% if type == 'page' %}
{% if type == 'page' %} <a href="{% url 'trade_action' type=type trade_id=item.id %}">
<a href="{% url 'trade_action' type=type trade_id=item.id %}"> <button
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-eye"></i>
</span>
</span>
</button>
</a>
{% else %}
<button <button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'trade_action' type=type account_id=item.account.id trade_id=item.id %}"
hx-trigger="click"
hx-target="#{{ type }}s-here"
hx-swap="innerHTML"
class="button"> class="button">
<span class="icon-text"> <span class="icon-text">
<span class="icon"> <span class="icon">
@ -68,25 +84,11 @@
</span> </span>
</span> </span>
</button> </button>
</a> {% endif %}
{% else %} </div>
<button </td>
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' </tr>
hx-get="{% url 'trade_action' type=type account_id=item.account.id trade_id=item.id %}" {% endfor %}
hx-trigger="click"
hx-target="#{{ type }}s-here"
hx-swap="innerHTML"
class="button">
<span class="icon-text">
<span class="icon">
<i class="fa-solid fa-eye"></i>
</span>
</span>
</button>
{% endif %}
</div>
</td>
</tr>
{% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,61 +1,63 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_tradingtimes request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
hx-swap="outerHTML" hx-swap="outerHTML"
hx-trigger="{{ context_object_name_singular }}Event from:body" hx-trigger="{{ context_object_name_singular }}Event from:body"
hx-get="{{ list_url }}"> hx-get="{{ list_url }}">
<thead> <thead>
<th>id</th> <th>id</th>
<th>user</th> <th>user</th>
<th>name</th> <th>name</th>
<th>description</th> <th>description</th>
<th>start</th> <th>start</th>
<th>end</th> <th>end</th>
<th>actions</th> <th>actions</th>
</thead> </thead>
{% for item in object_list %} {% for item in object_list %}
<tr> <tr>
<td>{{ item.id }}</td> <td>{{ item.id }}</td>
<td>{{ item.user }}</td> <td>{{ item.user }}</td>
<td>{{ item.name }}</td> <td>{{ item.name }}</td>
<td>{{ item.description }}</td> <td>{{ item.description }}</td>
<td>{{ item.get_start_day_display }} at {{ item.start_time }}</td> <td>{{ item.get_start_day_display }} at {{ item.start_time }}</td>
<td>{{ item.get_end_day_display }} at {{ item.end_time }}</td> <td>{{ item.get_end_day_display }} at {{ item.end_time }}</td>
<td> <td>
<div class="buttons"> <div class="buttons">
<button <button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'tradingtime_update' type=type pk=item.id %}" hx-get="{% url 'tradingtime_update' type=type pk=item.id %}"
hx-trigger="click" hx-trigger="click"
hx-target="#{{ type }}s-here" hx-target="#{{ type }}s-here"
hx-swap="innerHTML" hx-swap="innerHTML"
class="button"> class="button">
<span class="icon-text"> <span class="icon-text">
<span class="icon"> <span class="icon">
<i class="fa-solid fa-pencil"></i> <i class="fa-solid fa-pencil"></i>
</span>
</span> </span>
</span> </button>
</button> <button
<button hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-delete="{% url 'tradingtime_delete' type=type pk=item.id %}"
hx-delete="{% url 'tradingtime_delete' type=type pk=item.id %}" hx-trigger="click"
hx-trigger="click" hx-target="#modals-here"
hx-target="#modals-here" hx-swap="innerHTML"
hx-swap="innerHTML" hx-confirm="Are you sure you wish to delete {{ item.name }}?"
hx-confirm="Are you sure you wish to delete {{ item.name }}?" class="button">
class="button"> <span class="icon-text">
<span class="icon-text"> <span class="icon">
<span class="icon"> <i class="fa-solid fa-xmark"></i>
<i class="fa-solid fa-xmark"></i> </span>
</span> </span>
</span> </button>
</button> </div>
</div> </td>
</td> </tr>
</tr> {% endfor %}
{% endfor %}
</table> </table>
{% endcache %}

View File

@ -1,55 +1,57 @@
{% load cache %}
{% include 'mixins/partials/notify.html' %} {% include 'mixins/partials/notify.html' %}
{% cache 600 objects_trenddirections request.user.id object_list %}
<table <table
class="table is-fullwidth is-hoverable" class="table is-fullwidth is-hoverable"
hx-target="#{{ context_object_name }}-table" hx-target="#{{ context_object_name }}-table"
id="{{ context_object_name }}-table" id="{{ context_object_name }}-table"
hx-swap="outerHTML" hx-swap="outerHTML"
hx-trigger="{{ context_object_name_singular }}Event from:body" hx-trigger="{{ context_object_name_singular }}Event from:body"
hx-get="{{ list_url }}"> hx-get="{{ list_url }}">
<thead> <thead>
<th>symbol</th> <th>symbol</th>
<th>direction</th> <th>direction</th>
<th>actions</th> <th>actions</th>
</thead> </thead>
{% for key, item in object_list.items %} {% for key, item in object_list.items %}
<tr class=" <tr class="
{% if item == 'buy' %}has-background-success-light {% if item == 'buy' %}has-background-success-light
{% elif item == 'sell' %}has-background-danger-light {% elif item == 'sell' %}has-background-danger-light
{% endif %}"> {% endif %}">
<td>{{ key }}</td> <td>{{ key }}</td>
<td>{{ item }}</td> <td>{{ item }}</td>
<td> <td>
<div class="buttons"> <div class="buttons">
<button <button
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-get="{% url 'trenddirection_flip' strategy_id=strategy_id symbol=key %}" hx-get="{% url 'trenddirection_flip' strategy_id=strategy_id symbol=key %}"
hx-trigger="click" hx-trigger="click"
hx-target="#modals-here" hx-target="#modals-here"
hx-swap="innerHTML" hx-swap="innerHTML"
class="button"> class="button">
<span class="icon-text"> <span class="icon-text">
<span class="icon" data-tooltip="Flip direction"> <span class="icon" data-tooltip="Flip direction">
<i class="fa-solid fa-arrows-repeat"></i> <i class="fa-solid fa-arrows-repeat"></i>
</span>
</span> </span>
</span> </button>
</button> <button
<button hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'
hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-delete="{% url 'trenddirection_delete' strategy_id=strategy_id symbol=key %}"
hx-delete="{% url 'trenddirection_delete' strategy_id=strategy_id symbol=key %}" hx-trigger="click"
hx-trigger="click" hx-target="#modals-here"
hx-target="#modals-here" hx-swap="innerHTML"
hx-swap="innerHTML" class="button">
class="button"> <span class="icon-text">
<span class="icon-text"> <span class="icon">
<span class="icon"> <i class="fa-solid fa-xmark"></i>
<i class="fa-solid fa-xmark"></i> </span>
</span> </span>
</span> </button>
</button> </div>
</div> </td>
</td> </tr>
</tr> {% endfor %}
{% endfor %}
</table> </table>
{% endcache %}