diff --git a/backend/account/migrations/0035_shopmodel_customer_pickup_description_and_more.py b/backend/account/migrations/0035_shopmodel_customer_pickup_description_and_more.py new file mode 100644 index 0000000..5dff006 --- /dev/null +++ b/backend/account/migrations/0035_shopmodel_customer_pickup_description_and_more.py @@ -0,0 +1,23 @@ +# Generated by Django 5.1.2 on 2026-02-24 13:14 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('account', '0034_add_telegram_chat_id_to_shop'), + ] + + operations = [ + migrations.AddField( + model_name='shopmodel', + name='customer_pickup_description', + field=models.CharField(blank=True, max_length=500, null=True, verbose_name='توضیحات دریافت حضوری'), + ), + migrations.AddField( + model_name='shopmodel', + name='customer_pickup_title', + field=models.CharField(blank=True, max_length=40, null=True, verbose_name='عنوان دریافت حضوری'), + ), + ] diff --git a/backend/account/models.py b/backend/account/models.py index 95f1022..3863b82 100644 --- a/backend/account/models.py +++ b/backend/account/models.py @@ -145,6 +145,10 @@ class ShopModel(models.Model): commission_percent = models.DecimalField(max_digits=5, decimal_places=2, verbose_name='درصد کمیسیون') telegram_chat_id = models.CharField(max_length=100, blank=True, null=True, verbose_name='شناسه چت تلگرام', help_text='برای ارسال خودکار فاکتورها به تلگرام') + customer_pickup_title = models.CharField(max_length=40, verbose_name='عنوان دریافت حضوری', blank=True, null=True) + customer_pickup_description = models.CharField(max_length=500, verbose_name='توضیحات دریافت حضوری', blank=True, null=True) + + def __str__(self): return f"{self.user.phone} - {self.shop_name}" diff --git a/backend/product/serializers.py b/backend/product/serializers.py index a9ca9dc..5de5971 100644 --- a/backend/product/serializers.py +++ b/backend/product/serializers.py @@ -157,6 +157,8 @@ class DynamicProductSerializer(serializers.ModelSerializer): best_deal_price_after_discount = serializers.SerializerMethodField() best_deal_discount = serializers.SerializerMethodField() main_image = serializers.SerializerMethodField() + customer_pickup_title = serializers.SerializerMethodField() + customer_pickup_description = serializers.SerializerMethodField() def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) view_type = self.context.get('view_type', 'all') @@ -174,7 +176,7 @@ class DynamicProductSerializer(serializers.ModelSerializer): view_type = { 'list': ['id', 'name', 'rating', 'slug', 'category', 'colors', 'image', 'best_deal_price_before_discount', 'best_deal_price_after_discount', 'best_deal_discount', 'main_image'], 'slider': ['id', 'name', 'rating', 'slug', 'category', 'variants', 'colors', 'image', 'best_deal_price_before_discount', 'best_deal_price_after_discount', 'best_deal_discount', ], - 'instance': ['id', 'name', 'description', 'rating', 'slug', 'meta_description', 'meta_keywords', 'meta_rating', 'category', 'related_products', 'in_pack_items', 'variants', 'colors', 'added_to_favorites', 'image'], + 'instance': ['id', 'name', 'description', 'rating', 'slug', 'meta_description', 'meta_keywords', 'meta_rating', 'category', 'related_products', 'in_pack_items', 'variants', 'colors', 'added_to_favorites', 'image', 'customer_pickup_title', 'customer_pickup_description'], 'chat': ['id', 'name', 'description', 'variants', 'image'] } @@ -203,6 +205,16 @@ class DynamicProductSerializer(serializers.ModelSerializer): return 0 + def get_customer_pickup_title(self, obj): + if obj.shop: + return obj.shop.customer_pickup_title + return None + + def get_customer_pickup_description(self, obj): + if obj.shop: + return obj.shop.customer_pickup_description + return None + def get_added_to_favorites(self, obj): from account.models import UserFavorites request = self.context.get('request')