add guarantee filed to product varient and add timeout for nobitex api

This commit is contained in:
Parsa Nazer
2026-05-28 10:33:39 +03:30
parent 2b1c2b72c1
commit cc98dc4ccf
+5 -1
View File
@@ -147,7 +147,7 @@ class DollorModel(models.Model):
def get_usd_price(self):
try:
api_usd = "https://api.nobitex.ir/v2/orderbook/USDTIRT"
response = requests.get(api_usd)
response = requests.get(api_usd, timeout=5)
data = response.json()
price = int(data["lastTradePrice"])
price_in_usd = price / 10.0
@@ -403,6 +403,10 @@ class ProductVariant(DirtyFieldsMixin, models.Model):
discount = models.SmallIntegerField(default=0, verbose_name='درصد تخفیف', help_text='این درصد از قیمت نهایی محصول کسر میگردد')
color = models.CharField(
verbose_name='رنگ', max_length=7, blank=True, null=True)
guarantee = models.CharField(
max_length=200, default='گرانتی اصالت و سلامت کالا',
verbose_name='گارانتی',
help_text='این مقدار به ترب ارسال می‌شود تا محصول به‌عنوان نو طبقه‌بندی شود')
images = models.ManyToManyField(ProductImageModel, verbose_name='عکس ها')
video = models.FileField(upload_to='product_videos/',
blank=True, null=True, verbose_name='ویدیو')