Skip to content

Commit

Permalink
Improve tradero UX
Browse files Browse the repository at this point in the history
- Show update, jump and reset actions only if bots are off
  • Loading branch information
math-a3k committed Sep 12, 2023
1 parent 5807453 commit 3841dd3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
7 changes: 7 additions & 0 deletions base/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1547,6 +1547,13 @@ def __str__(self):
def get_absolute_url(self):
return reverse("base:botzinhos-group-detail", kwargs={"pk": self.pk})

@property
def are_all_off(self):
for bot in self.bots.all():
if bot.status != TraderoBot.Status.INACTIVE:
return False
return True

def on(self):
for bot in self.bots.all():
if bot.status == TraderoBot.Status.INACTIVE:
Expand Down
8 changes: 6 additions & 2 deletions base/templates/base/botzinhos_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ <h4 class="m-2">Actions</h4>

<div class="btn-group">
<a class="btn btn-warning" href="{% url "base:botzinhos-logs" bot.pk %}">View Logs</a>
{% if bot.status == bot.Status.INACTIVE %}
<a class="btn btn-warning" href="{% url "base:botzinhos-update" bot.pk %}">Update</a>
{% endif %}
</div>
<div class="btn-group">
{% if not bot.price_buying %}
Expand All @@ -111,17 +113,19 @@ <h4 class="m-2">Actions</h4>
{% action_button action_url "Turn ON" "btn-primary" %}
{% endif %}
</div>
{% if bot.status == bot.Status.INACTIVE %}
<div class="btn-group">
{% url "base:botzinhos-action" bot.pk "reset_soft" as action_url %}
{% action_button action_url "RESET (SOFT)" "btn-warning" %}
{% url "base:botzinhos-action" bot.pk "reset_hard" as action_url %}
{% action_button action_url "RESET (HARD)" "btn-danger" %}
</div>
{% endif %}
{% if not bot.price_buying and bot.status == bot.Status.INACTIVE %}
<div class="ul">
{% if not bot.price_buying %}
{% include "base/_jumping_form.html" with view="base:botzinhos-action" obj=bot %}
{% endif %}
</div>
{% endif %}
</div>

{% include "base/trades_section.html" with summary=summary trades=trades page_obj=page_obj %}
Expand Down
6 changes: 6 additions & 0 deletions base/templates/base/botzinhos_group_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ <h4 class="mt-1 mb-0 p-2">GROUP: {{ group.name|default:"(Sem Nome)" }}</h4>
<h4 class="m-2">Group Actions</h4>

<div class="btn-group">
{% if group.are_all_off %}
<a class="btn btn-warning" href="{% url "base:botzinhos-group-update" group.pk %}">Atualizar Grupo</a>
{% endif %}
<a class="btn btn-primary" href="{% url "base:botzinhos-create" %}?group={{group.pk}}">Novo(s) Botzinho(s)</a>
<a class="btn btn-warning" href="{% url "base:botzinhos-group-move" group.pk %}">Mover Botzinhos</a>
</div>
Expand All @@ -101,12 +103,16 @@ <h4 class="m-2">Group Actions</h4>
{% action_button action_url "Turn ON" "btn-primary" %}
{% url "base:botzinhos-group-action" group.pk "liquidate" as action_url %}
{% action_button action_url "LIQUIDATE (FORCE SELL and Turn OFF)" "btn-danger" %}
{% if group.are_all_off %}
{% url "base:botzinhos-group-action" group.pk "reset_soft" as action_url %}
{% action_button action_url "RESET (SOFT)" "btn-warning" %}
{% endif %}
</div>
{% if group.are_all_off %}
<div class="ul">
{% include "base/_jumping_form.html" with view="base:botzinhos-group-action" obj=group %}
</div>
{% endif %}
</div>

</div>
Expand Down

0 comments on commit 3841dd3

Please sign in to comment.