Features: 1) Fallback to default avatar image in avatar_url method; 2) Added header component for admin dashboard template; 3) Improved layout sections in admin dashboard templates for consistent spacing;
Fixes: 1) Prevent `.initialized` file creation in debug mode; Extra: 1) Refactored and reorganized admin dashboard templates for better readability and maintainability.
This commit is contained in:
parent
76cea49c06
commit
625fe6e350
5 changed files with 103 additions and 84 deletions
|
|
@ -185,6 +185,7 @@ class Command(BaseCommand):
|
|||
(User.objects.filter(Q(language="") | ~Q(language__in=valid_codes)).update(language=settings.LANGUAGE_CODE))
|
||||
|
||||
try:
|
||||
if not settings.DEBUG:
|
||||
initialized_path.write_text(settings.RELEASE_DATE.isoformat(), encoding="utf-8")
|
||||
except Exception as exc:
|
||||
logger.error("Failed to update .initialized file: %s", exc)
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{% load i18n unfold %}
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<div class="font-semibold text-2xl text-font-important-light tracking-tight dark:text-font-important-dark{% if class %} {{ class }}{% endif %}">
|
||||
<a>{% trans "Dashboard" %}</a>
|
||||
{% with cur=tf|default:30 %}
|
||||
<a href="?tf=7"
|
||||
class="px-3 py-1 rounded-full text-sm border transition-colors {% if cur == 7 %} bg-gray-900 text-white dark:bg-white dark:text-gray-900 border-transparent {% else %} border-gray-300 dark:border-gray-700 hover:bg-gray-100 dark:hover:bg-gray-800 {% endif %}">7d</a>
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
{% load i18n unfold %}
|
||||
|
||||
{% component "unfold/components/card.html" %}
|
||||
<div class="mt-6 md:mt-8">
|
||||
{% component "unfold/components/card.html" %}
|
||||
{% component "unfold/components/title.html" %}
|
||||
{% trans "Most wished product" %}
|
||||
{% endcomponent %}
|
||||
|
|
@ -32,9 +33,10 @@
|
|||
{% trans "No data yet." %}
|
||||
{% endcomponent %}
|
||||
{% endif %}
|
||||
{% endcomponent %}
|
||||
|
||||
{% component "unfold/components/card.html" %}
|
||||
{% endcomponent %}
|
||||
</div>
|
||||
<div class="mt-6 md:mt-8">
|
||||
{% component "unfold/components/card.html" %}
|
||||
{% component "unfold/components/title.html" %}
|
||||
{% trans "Most popular product" %}
|
||||
{% endcomponent %}
|
||||
|
|
@ -66,4 +68,5 @@
|
|||
{% trans "No data yet." %}
|
||||
{% endcomponent %}
|
||||
{% endif %}
|
||||
{% endcomponent %}
|
||||
{% endcomponent %}
|
||||
</div>
|
||||
|
|
@ -17,33 +17,44 @@
|
|||
{% component "unfold/components/container.html" %}
|
||||
<div class="flex flex-col min-h-screen">
|
||||
{% component "unfold/components/title.html" %}
|
||||
{% trans "Dashboard" %}
|
||||
{% include "admin/dashboard/_filters.html" %}
|
||||
{% include "admin/dashboard/_header.html" %}
|
||||
{% endcomponent %}
|
||||
|
||||
<div class="mt-6 md:mt-8">
|
||||
{% include "admin/dashboard/_kpis.html" %}
|
||||
|
||||
<div class="grid grid-cols-1 xl:grid-cols-3 gap-6 items-start">
|
||||
{% include "admin/dashboard/_daily_sales.html" %}
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mt-6">
|
||||
<div class="mt-6 md:mt-8">
|
||||
{% include "admin/dashboard/_low_stock.html" %}
|
||||
</div>
|
||||
|
||||
<div class="mt-6 md:mt-8">
|
||||
{% include "admin/dashboard/_most_returned.html" %}
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mt-6">
|
||||
<div class="mt-6 md:mt-8">
|
||||
{% include "admin/dashboard/_customers_mix.html" %}
|
||||
{% if shipped_vs_digital.digital_qty|default:0 > 0 and shipped_vs_digital.shipped_qty|default:0 > 0 %}
|
||||
{% include "admin/dashboard/_shipped_vs_digital.html" %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% include "admin/dashboard/_top_categories.html" %}
|
||||
{% include "admin/dashboard/_product_lists.html" %}
|
||||
{% if shipped_vs_digital.digital_qty|default:0 > 0 and shipped_vs_digital.shipped_qty|default:0 > 0 %}
|
||||
<div class="mt-6 md:mt-8">
|
||||
{% include "admin/dashboard/_shipped_vs_digital.html" %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% component "unfold/components/separator.html" %}
|
||||
{% endcomponent %}
|
||||
<div class="mt-6 md:mt-8">
|
||||
{% include "admin/dashboard/_top_categories.html" %}
|
||||
</div>
|
||||
|
||||
<div class="mt-6 md:mt-8">
|
||||
{% include "admin/dashboard/_product_lists.html" %}
|
||||
</div>
|
||||
|
||||
<div class="mt-6 md:mt-8">
|
||||
{% include "admin/dashboard/_daily_sales.html" %}
|
||||
</div>
|
||||
|
||||
{% component "unfold/components/separator.html" %}{% endcomponent %}
|
||||
|
||||
<div class="mt-4 mt-auto">
|
||||
{% component "unfold/components/text.html" with class="text-center text-xs text-gray-500 dark:text-gray-400" %}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ from django.db.models import (
|
|||
TextField,
|
||||
UUIDField,
|
||||
)
|
||||
from django.templatetags.static import static
|
||||
from django.utils import timezone
|
||||
from django.utils.functional import cached_property
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
|
@ -100,8 +101,11 @@ class User(AbstractUser, NiceModel): # type: ignore [django-manager-missing]
|
|||
objects = UserManager() # type: ignore [misc, assignment]
|
||||
|
||||
@cached_property
|
||||
def avatar_url(self):
|
||||
def avatar_url(self) -> str:
|
||||
try:
|
||||
return self.avatar.url
|
||||
except ValueError:
|
||||
return static("person.png")
|
||||
|
||||
def add_to_recently_viewed(self, product_uuid):
|
||||
recently_viewed = self.recently_viewed
|
||||
|
|
|
|||
Loading…
Reference in a new issue