From 98654800609c3d766f46fa4e48104f715d6c7d77 Mon Sep 17 00:00:00 2001 From: ITQ Date: Sun, 26 Jan 2025 15:52:14 +0300 Subject: [PATCH] fix: changed active status logic changed timezone for active status to utc+3 --- solution/apps/promo/models.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/solution/apps/promo/models.py b/solution/apps/promo/models.py index 7b8d9f7..9cb585a 100644 --- a/solution/apps/promo/models.py +++ b/solution/apps/promo/models.py @@ -1,3 +1,6 @@ +from datetime import datetime + +import pytz from django.core.exceptions import ValidationError from django.core.validators import ( MaxValueValidator, @@ -5,7 +8,6 @@ from django.core.validators import ( MinValueValidator, ) from django.db import models -from django.utils import timezone from django_countries.fields import CountryField from apps.business.models import Business @@ -163,7 +165,8 @@ class Promocode(BaseModel): @property def active(self) -> bool: - current_date = timezone.datetime.today().date() + timezone_utc3 = pytz.timezone("Europe/Moscow") + current_date = datetime.now(timezone_utc3).date() is_active_by_date = ( self.active_from is None or self.active_from <= current_date