Features: 1) Add icon attributes to Balance and OrderInline admin classes; 2) Introduce evibes_summernote_upload_to_func for custom attachment upload paths in Summernote config;

Fixes: 1) Add missing import for `os`, `uuid`, and `datetime` in `evibes.utils.__init__.py`;

Extra: None;
This commit is contained in:
Egor Pavlovich Gorbunov 2025-06-23 16:12:43 +03:00
parent fa54271e89
commit f9c6fe3424
3 changed files with 19 additions and 1 deletions

View file

@ -1,3 +1,5 @@
from evibes.utils import evibes_summernote_upload_to_func
SUMMERNOTE_THEME = "bs4" SUMMERNOTE_THEME = "bs4"
SUMMERNOTE_CONFIG = { SUMMERNOTE_CONFIG = {
"iframe": True, "iframe": True,
@ -14,6 +16,7 @@ SUMMERNOTE_CONFIG = {
["view", ["fullscreen", "codeview", "help"]], ["view", ["fullscreen", "codeview", "help"]],
], ],
}, },
"attachment_upload_to": evibes_summernote_upload_to_func(),
"attachment_require_authentication": True, "attachment_require_authentication": True,
"disable_attachment": False, "disable_attachment": False,
"attachment_absolute_uri": True, "attachment_absolute_uri": True,

View file

@ -1,4 +1,8 @@
from evibes.settings import LANGUAGE_CODE, LANGUAGES import os
import uuid
from datetime import datetime
from evibes.settings.base import LANGUAGE_CODE, LANGUAGES
def get_language_from_header(accept_language): def get_language_from_header(accept_language):
@ -23,3 +27,12 @@ def get_language_from_header(accept_language):
return language_codes[primary_lang].lower() return language_codes[primary_lang].lower()
return LANGUAGE_CODE.lower() return LANGUAGE_CODE.lower()
def evibes_summernote_upload_to_func(instance, filename: str) -> str:
ext = filename.split(".")[-1]
filename = f"{uuid.uuid4()}.{ext}"
today = datetime.now().strftime("%Y-%m-%d")
if instance:
return os.path.join('evibes-summernote', today, filename)
return os.path.join('evibes-summernote', today)

View file

@ -36,6 +36,7 @@ class BalanceInline(admin.TabularInline):
verbose_name = _("balance") verbose_name = _("balance")
verbose_name_plural = _("balance") verbose_name_plural = _("balance")
is_navtab = True is_navtab = True
icon = "fa-solid fa-wallet"
class OrderInline(admin.TabularInline): class OrderInline(admin.TabularInline):
@ -44,6 +45,7 @@ class OrderInline(admin.TabularInline):
verbose_name = _("order") verbose_name = _("order")
verbose_name_plural = _("orders") verbose_name_plural = _("orders")
is_navtab = True is_navtab = True
icon = "fa-solid fa-cart-shopping"
class UserAdmin(BaseUserAdmin, BasicModelAdmin): class UserAdmin(BaseUserAdmin, BasicModelAdmin):