diff --git a/engine/core/management/commands/initialize.py b/engine/core/management/commands/initialize.py index f68bbba4..bdcda2f3 100644 --- a/engine/core/management/commands/initialize.py +++ b/engine/core/management/commands/initialize.py @@ -185,7 +185,8 @@ class Command(BaseCommand): (User.objects.filter(Q(language="") | ~Q(language__in=valid_codes)).update(language=settings.LANGUAGE_CODE)) try: - initialized_path.write_text(settings.RELEASE_DATE.isoformat(), encoding="utf-8") + 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) diff --git a/engine/core/templates/admin/dashboard/_filters.html b/engine/core/templates/admin/dashboard/_header.html similarity index 87% rename from engine/core/templates/admin/dashboard/_filters.html rename to engine/core/templates/admin/dashboard/_header.html index 4001bedd..e456cdb5 100644 --- a/engine/core/templates/admin/dashboard/_filters.html +++ b/engine/core/templates/admin/dashboard/_header.html @@ -1,6 +1,6 @@ {% load i18n unfold %} - -
+
+ {% trans "Dashboard" %} {% with cur=tf|default:30 %} 7d diff --git a/engine/core/templates/admin/dashboard/_product_lists.html b/engine/core/templates/admin/dashboard/_product_lists.html index 1c00b3cd..343b5df0 100644 --- a/engine/core/templates/admin/dashboard/_product_lists.html +++ b/engine/core/templates/admin/dashboard/_product_lists.html @@ -1,69 +1,72 @@ {% load i18n unfold %} -{% component "unfold/components/card.html" %} - {% component "unfold/components/title.html" %} - {% trans "Most wished product" %} - {% endcomponent %} - {% if most_wished_products %} - - {% elif most_wished_product %} - - {% if most_wished_product.image %} - {{ most_wished_product.name }} - {% endif %} - {{ most_wished_product.name }} - - {% else %} - {% component "unfold/components/text.html" %} - {% trans "No data yet." %} +
+ {% component "unfold/components/card.html" %} + {% component "unfold/components/title.html" %} + {% trans "Most wished product" %} {% endcomponent %} - {% endif %} -{% endcomponent %} - -{% component "unfold/components/card.html" %} - {% component "unfold/components/title.html" %} - {% trans "Most popular product" %} + {% if most_wished_products %} + + {% elif most_wished_product %} + + {% if most_wished_product.image %} + {{ most_wished_product.name }} + {% endif %} + {{ most_wished_product.name }} + + {% else %} + {% component "unfold/components/text.html" %} + {% trans "No data yet." %} + {% endcomponent %} + {% endif %} {% endcomponent %} - {% if most_popular_products %} - - {% elif most_popular_product %} - - {% if most_popular_product.image %} - {{ most_popular_product.name }} - {% endif %} - {{ most_popular_product.name }} - - {% else %} - {% component "unfold/components/text.html" %} - {% trans "No data yet." %} +
+
+ {% component "unfold/components/card.html" %} + {% component "unfold/components/title.html" %} + {% trans "Most popular product" %} {% endcomponent %} - {% endif %} -{% endcomponent %} + {% if most_popular_products %} + + {% elif most_popular_product %} + + {% if most_popular_product.image %} + {{ most_popular_product.name }} + {% endif %} + {{ most_popular_product.name }} + + {% else %} + {% component "unfold/components/text.html" %} + {% trans "No data yet." %} + {% endcomponent %} + {% endif %} + {% endcomponent %} +
\ No newline at end of file diff --git a/engine/core/templates/admin/index.html b/engine/core/templates/admin/index.html index 1a35dd74..7e98c630 100644 --- a/engine/core/templates/admin/index.html +++ b/engine/core/templates/admin/index.html @@ -17,33 +17,44 @@ {% component "unfold/components/container.html" %}
{% component "unfold/components/title.html" %} - {% trans "Dashboard" %} - {% include "admin/dashboard/_filters.html" %} + {% include "admin/dashboard/_header.html" %} {% endcomponent %} - {% include "admin/dashboard/_kpis.html" %} - -
- {% include "admin/dashboard/_daily_sales.html" %} +
+ {% include "admin/dashboard/_kpis.html" %}
-
+
{% include "admin/dashboard/_low_stock.html" %} +
+ +
{% include "admin/dashboard/_most_returned.html" %}
-
+
{% 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 %}
- {% 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 %} +
+ {% include "admin/dashboard/_shipped_vs_digital.html" %} +
+ {% endif %} - {% component "unfold/components/separator.html" %} - {% endcomponent %} +
+ {% include "admin/dashboard/_top_categories.html" %} +
+ +
+ {% include "admin/dashboard/_product_lists.html" %} +
+ +
+ {% include "admin/dashboard/_daily_sales.html" %} +
+ + {% component "unfold/components/separator.html" %}{% endcomponent %}
{% component "unfold/components/text.html" with class="text-center text-xs text-gray-500 dark:text-gray-400" %} diff --git a/engine/vibes_auth/models.py b/engine/vibes_auth/models.py index 86c191dd..315cbacd 100644 --- a/engine/vibes_auth/models.py +++ b/engine/vibes_auth/models.py @@ -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): - return self.avatar.url + 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