mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-04-23 17:18:44 +02:00
initial commit
This commit is contained in:
0
app/apps/common/__init__.py
Normal file
0
app/apps/common/__init__.py
Normal file
6
app/apps/common/apps.py
Normal file
6
app/apps/common/apps.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class CommonConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "apps.common"
|
||||
0
app/apps/common/functions/__init__.py
Normal file
0
app/apps/common/functions/__init__.py
Normal file
13
app/apps/common/functions/decimals.py
Normal file
13
app/apps/common/functions/decimals.py
Normal 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
|
||||
0
app/apps/common/migrations/__init__.py
Normal file
0
app/apps/common/migrations/__init__.py
Normal file
0
app/apps/common/templatetags/__init__.py
Normal file
0
app/apps/common/templatetags/__init__.py
Normal file
9
app/apps/common/templatetags/month_name.py
Normal file
9
app/apps/common/templatetags/month_name.py
Normal 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])
|
||||
40
app/apps/common/templatetags/toast_bg.py
Normal file
40
app/apps/common/templatetags/toast_bg.py
Normal 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
11
app/apps/common/urls.py
Normal 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
5
app/apps/common/views.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
|
||||
def toasts(request):
|
||||
return render(request, "common/toasts.html")
|
||||
0
app/apps/common/widgets/__init__.py
Normal file
0
app/apps/common/widgets/__init__.py
Normal file
Reference in New Issue
Block a user