initial commit

This commit is contained in:
Herculino Trotta
2024-09-26 11:00:40 -03:00
parent 830e821a17
commit 50b0c6ce01
138 changed files with 13566 additions and 46 deletions

View File

6
app/apps/common/apps.py Normal file
View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class CommonConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "apps.common"

View File

View File

@@ -0,0 +1,13 @@
from decimal import Decimal, ROUND_DOWN
def truncate_decimal(value, decimal_places):
"""
Truncate a Decimal value to n decimal places without rounding.
:param value: The Decimal value to truncate
:param decimal_places: The number of decimal places to keep
:return: Truncated Decimal value
"""
multiplier = Decimal(10**decimal_places)
return (value * multiplier).to_integral_value(rounding=ROUND_DOWN) / multiplier

View File

View File

View File

@@ -0,0 +1,9 @@
import calendar
from django.template.loader_tags import register
from django.utils.translation import gettext_lazy as _
@register.filter
def month_name(month_number):
return _(calendar.month_name[month_number])

View File

@@ -0,0 +1,40 @@
from django import template
from django.utils.translation import gettext_lazy as _
register = template.Library()
@register.filter
def toast_bg(tags):
if "success" in tags:
return "success"
elif "warning" in tags:
return "warning"
elif "error" in tags:
return "danger"
elif "info" in tags:
return "info"
@register.filter
def toast_icon(tags):
if "success" in tags:
return "fa-solid fa-circle-check"
elif "warning" in tags:
return "fa-solid fa-circle-exclamation"
elif "error" in tags:
return "fa-solid fa-circle-xmark"
elif "info" in tags:
return "fa-solid fa-circle-info"
@register.filter
def toast_title(tags):
if "success" in tags:
return _("Success")
elif "warning" in tags:
return _("Warning")
elif "error" in tags:
return _("Error")
elif "info" in tags:
return _("Info")

11
app/apps/common/urls.py Normal file
View File

@@ -0,0 +1,11 @@
from django.urls import path
from . import views
urlpatterns = [
path(
"toasts/",
views.toasts,
name="toasts",
),
]

5
app/apps/common/views.py Normal file
View File

@@ -0,0 +1,5 @@
from django.shortcuts import render
def toasts(request):
return render(request, "common/toasts.html")

View File