feat: add exchange rate config page

This commit is contained in:
Herculino Trotta
2024-10-16 14:30:32 -03:00
parent 31ca384ced
commit fde5101011
10 changed files with 258 additions and 3 deletions
@@ -0,0 +1,11 @@
{% extends 'extends/offcanvas.html' %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block title %}{% translate 'Add exchange rate' %}{% endblock %}
{% block body %}
<form hx-post="{% url 'exchange_rate_add' %}" hx-target="#generic-offcanvas" novalidate>
{% crispy form %}
</form>
{% endblock %}
@@ -0,0 +1,11 @@
{% extends 'extends/offcanvas.html' %}
{% load i18n %}
{% load crispy_forms_tags %}
{% block title %}{% translate 'Edit exchange rate' %}{% endblock %}
{% block body %}
<form hx-post="{% url 'exchange_rate_edit' pk=exchange_rate.id %}" hx-target="#generic-offcanvas" novalidate>
{% crispy form %}
</form>
{% endblock %}
@@ -0,0 +1,59 @@
{% load currency_display %}
{% load i18n %}
<div class="container px-md-3 py-3 column-gap-5">
<div class="tw-text-3xl fw-bold font-monospace tw-w-full mb-3">
{% spaceless %}
<div>{% translate 'Exchange Rates' %}<span>
<a class="text-decoration-none tw-text-2xl p-1 category-action"
role="button"
data-bs-toggle="tooltip"
data-bs-title="{% translate "Add" %}"
hx-get="{% url 'exchange_rate_add' %}"
hx-target="#generic-offcanvas"
_="">
<i class="fa-solid fa-circle-plus fa-fw"></i></a>
</span></div>
{% endspaceless %}
</div>
<div class="border p-3 rounded-3 table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th scope="col" class="col-auto"></th>
<th scope="col" class="col-auto">{% translate 'Date' %}</th>
<th scope="col" class="col">{% translate 'Pairing' %}</th>
<th scope="col" class="col">{% translate 'Rate' %}</th>
</tr>
</thead>
<tbody>
{% for exchange_rate in exchange_rates %}
<tr class="exchange-rate">
<td class="col-auto">
<a class="text-decoration-none tw-text-gray-400 p-1"
role="button"
data-bs-toggle="tooltip"
data-bs-title="{% translate "Edit" %}"
hx-get="{% url 'exchange_rate_edit' pk=exchange_rate.id %}"
hx-target="#generic-offcanvas">
<i class="fa-solid fa-pencil fa-fw"></i></a>
<a class="text-danger text-decoration-none p-1"
role="button"
data-bs-toggle="tooltip"
data-bs-title="{% translate "Delete" %}"
hx-delete="{% url 'exchange_rate_delete' pk=exchange_rate.id %}"
hx-trigger='confirmed'
data-bypass-on-ctrl="true"
data-title="{% translate "Are you sure?" %}"
data-text="{% translate "You won't be able to revert this!" %}"
data-confirm-text="{% translate "Yes, delete it!" %}"
_="install prompt_swal"><i class="fa-solid fa-trash fa-fw"></i></a></td>
<td class="col-auto">{{ exchange_rate.date|date:"SHORT_DATETIME_FORMAT" }}</td>
<td class="col"><span class="badge rounded-pill text-bg-secondary">{{ exchange_rate.from_currency.code }}</span> x <span class="badge rounded-pill text-bg-secondary">{{ exchange_rate.to_currency.code }}</span></td>
<td class="col">1 {{ exchange_rate.from_currency.code }} ≅ {% currency_display amount=exchange_rate.rate prefix=exchange_rate.to_currency.prefix suffix=exchange_rate.to_currency.suffix decimal_places=exchange_rate.to_currency.decimal_places%}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
@@ -0,0 +1,8 @@
{% extends "layouts/base.html" %}
{% load i18n %}
{% block title %}{% translate 'Exchange Rates' %}{% endblock %}
{% block content %}
<div hx-get="{% url 'exchange_rates_list' %}" hx-trigger="load, updated from:window" class="show-loading mx-5"></div>
{% endblock %}
+8 -2
View File
@@ -34,7 +34,7 @@
</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle {% active_link views='tags_index||categories_index||accounts_index||account_groups_index||currencies_index||installment_plans_index' %}"
<a class="nav-link dropdown-toggle {% active_link views='tags_index||categories_index||accounts_index||account_groups_index||currencies_index||exchange_rates_index||installment_plans_index' %}"
href="#" role="button"
data-bs-toggle="dropdown"
aria-expanded="false">
@@ -56,8 +56,14 @@
href="{% url 'accounts_index' %}">{% translate 'Accounts' %}</a></li>
<li><a class="dropdown-item {% active_link views='account_groups_index' %}"
href="{% url 'account_groups_index' %}">{% translate 'Account Groups' %}</a></li>
<li><a class="dropdown-item {% active_link views='currencies_index' %}"
<li>
<hr class="dropdown-divider">
</li>
<li><h6 class="dropdown-header">{% trans 'Currencies' %}</h6></li>
<li><a class="dropdown-item {% active_link views='currencies_index' %}"
href="{% url 'currencies_index' %}">{% translate 'Currencies' %}</a></li>
<li><a class="dropdown-item {% active_link views='exchange_rates_index' %}"
href="{% url 'exchange_rates_index' %}">{% translate 'Exchange Rates' %}</a></li>
<li>
<hr class="dropdown-divider">
</li>