mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-04-23 17:18:44 +02:00
Merge pull request #311
refactor(yearly): convert into a single page instead of two
This commit is contained in:
@@ -3,6 +3,7 @@ from django.urls import path
|
|||||||
from . import views
|
from . import views
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
|
path("yearly/", views.index, name="yearly_index"),
|
||||||
path("yearly/currency/", views.index_by_currency, name="yearly_index_currency"),
|
path("yearly/currency/", views.index_by_currency, name="yearly_index_currency"),
|
||||||
path("yearly/account/", views.index_by_account, name="yearly_index_account"),
|
path("yearly/account/", views.index_by_account, name="yearly_index_account"),
|
||||||
path(
|
path(
|
||||||
|
|||||||
@@ -16,6 +16,22 @@ from apps.transactions.utils.calculations import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@login_required
|
||||||
|
def index(request):
|
||||||
|
if "view_type" in request.GET:
|
||||||
|
view_type = request.GET["view_type"]
|
||||||
|
request.session["yearly_view_type"] = view_type
|
||||||
|
else:
|
||||||
|
view_type = request.session.get("yearly_view_type", "currency")
|
||||||
|
|
||||||
|
now = timezone.localdate(timezone.now())
|
||||||
|
|
||||||
|
if view_type == "currency":
|
||||||
|
return redirect(to="yearly_overview_currency", year=now.year)
|
||||||
|
else:
|
||||||
|
return redirect(to="yearly_overview_account", year=now.year)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def index_by_currency(request):
|
def index_by_currency(request):
|
||||||
now = timezone.localdate(timezone.now())
|
now = timezone.localdate(timezone.now())
|
||||||
@@ -32,6 +48,8 @@ def index_by_account(request):
|
|||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def index_yearly_overview_by_currency(request, year: int):
|
def index_yearly_overview_by_currency(request, year: int):
|
||||||
|
request.session["yearly_view_type"] = "currency"
|
||||||
|
|
||||||
next_year = year + 1
|
next_year = year + 1
|
||||||
previous_year = year - 1
|
previous_year = year - 1
|
||||||
|
|
||||||
@@ -49,6 +67,7 @@ def index_yearly_overview_by_currency(request, year: int):
|
|||||||
"previous_year": previous_year,
|
"previous_year": previous_year,
|
||||||
"months": month_options,
|
"months": month_options,
|
||||||
"currencies": currency_options,
|
"currencies": currency_options,
|
||||||
|
"type": "currency",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -95,6 +114,7 @@ def yearly_overview_by_currency(request, year: int):
|
|||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def index_yearly_overview_by_account(request, year: int):
|
def index_yearly_overview_by_account(request, year: int):
|
||||||
|
request.session["yearly_view_type"] = "account"
|
||||||
next_year = year + 1
|
next_year = year + 1
|
||||||
previous_year = year - 1
|
previous_year = year - 1
|
||||||
|
|
||||||
@@ -115,6 +135,7 @@ def index_yearly_overview_by_account(request, year: int):
|
|||||||
"previous_year": previous_year,
|
"previous_year": previous_year,
|
||||||
"months": month_options,
|
"months": month_options,
|
||||||
"accounts": account_options,
|
"accounts": account_options,
|
||||||
|
"type": "account",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,18 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container px-md-3 py-3 column-gap-5">
|
<div class="h-100 text-center mb-4 pt-2">
|
||||||
|
<div class="btn-group gap-3" role="group">
|
||||||
|
<a href="{% url 'yearly_overview_currency' year=year %}" class="btn {% if type != 'currency' %}btn-outline-primary{% else %}btn-primary{% endif %} rounded-5" hx-boost>
|
||||||
|
<i class="fa-solid fa-solid fa-coins fa-fw me-2"></i>{% trans 'Currency' %}
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a href="{% url 'yearly_overview_account' year=year %}" class="btn {% if type != 'account' %}btn-outline-primary{% else %}btn-primary{% endif %} rounded-5" hx-boost>
|
||||||
|
<i class="fa-solid fa-wallet fa-fw me-2"></i>{% trans 'Account' %}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="container px-md-3 py-3 column-gap-5" id="yearly-content">
|
||||||
<div class="row mb-3 gx-xl-4 gy-3 mb-4">
|
<div class="row mb-3 gx-xl-4 gy-3 mb-4">
|
||||||
{# Date picker#}
|
{# Date picker#}
|
||||||
<div class="col-12 col-xl-2 flex-row align-items-center d-flex">
|
<div class="col-12 col-xl-2 flex-row align-items-center d-flex">
|
||||||
@@ -113,7 +124,7 @@
|
|||||||
<div id="data-content"
|
<div id="data-content"
|
||||||
class="show-loading"
|
class="show-loading"
|
||||||
hx-get="{% url 'yearly_overview_account_data' year=year %}"
|
hx-get="{% url 'yearly_overview_account_data' year=year %}"
|
||||||
hx-trigger="load, every 10m"
|
hx-trigger="load, every 10m, updated from:window"
|
||||||
hx-include="[name='account'], [name='month']"
|
hx-include="[name='account'], [name='month']"
|
||||||
hx-swap="innerHTML">
|
hx-swap="innerHTML">
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -14,7 +14,18 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container px-md-3 py-3 column-gap-5">
|
<div class="h-100 text-center mb-4 pt-2">
|
||||||
|
<div class="btn-group gap-3" role="group">
|
||||||
|
<a href="{% url 'yearly_overview_currency' year=year %}" class="btn {% if type != 'currency' %}btn-outline-primary{% else %}btn-primary{% endif %} rounded-5" hx-boost>
|
||||||
|
<i class="fa-solid fa-solid fa-coins fa-fw me-2"></i>{% trans 'Currency' %}
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a href="{% url 'yearly_overview_account' year=year %}" class="btn {% if type != 'account' %}btn-outline-primary{% else %}btn-primary{% endif %} rounded-5" hx-boost>
|
||||||
|
<i class="fa-solid fa-wallet fa-fw me-2"></i>{% trans 'Account' %}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="container px-md-3 py-3 column-gap-5" id="yearly-content">
|
||||||
<div class="row mb-3 gx-xl-4 gy-3 mb-4">
|
<div class="row mb-3 gx-xl-4 gy-3 mb-4">
|
||||||
{# Date picker#}
|
{# Date picker#}
|
||||||
<div class="col-12 col-xl-2 flex-row align-items-center d-flex">
|
<div class="col-12 col-xl-2 flex-row align-items-center d-flex">
|
||||||
@@ -115,7 +126,7 @@
|
|||||||
<div id="data-content"
|
<div id="data-content"
|
||||||
class="show-loading"
|
class="show-loading"
|
||||||
hx-get="{% url 'yearly_overview_currency_data' year=year %}"
|
hx-get="{% url 'yearly_overview_currency_data' year=year %}"
|
||||||
hx-trigger="load, every 10m"
|
hx-trigger="load, every 10m, updated from:window"
|
||||||
hx-include="[name='currency'], [name='month']"
|
hx-include="[name='currency'], [name='month']"
|
||||||
hx-swap="innerHTML">
|
hx-swap="innerHTML">
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user