diff --git a/backend/product/admin.py b/backend/product/admin.py index af34d12..47e2a09 100644 --- a/backend/product/admin.py +++ b/backend/product/admin.py @@ -191,14 +191,14 @@ class ProductModelAdmin(ModelAdmin, ImportExportModelAdmin): inlines = [ProductVariantInLine] readonly_fields = ('slug', 'created_at') search_fields = ['name', 'description', ] - list_filter = ['show', 'category'] + list_filter = ['show', 'category', 'show_in_bot'] autocomplete_fields = ['related_products', 'shop'] # compressed_fields = True warn_unsaved_form = True actions_list = ['redirect_to_learn', 'update_products_price'] list_display = ['display_image', 'display_price', 'view', 'show', 'rating', 'category', 'created_at'] fieldsets = ( - ('فیلد های اصلی', {'fields': ('name', 'description', 'category', 'related_products', 'show', 'shop', 'show_in_bot'), "classes": ["tab"],}), + ('فیلد های اصلی', {'fields': ('name', 'description', 'category', 'related_products', 'show', 'shop', 'show_in_bot', 'bot_banner'), "classes": ["tab"],}), ('فیلد های سيو', {'fields': ('meta_description', 'meta_keywords', 'meta_rating', 'slug'), "classes": ["tab"],}), ('فیلد های مربوط به کاربر', {'fields': ('rating', 'view',), "classes": ["tab"],}), # ('فیلد های ایتم های پک', {'fields': ('in_pack_items', ), "classes": ["tab"],}) diff --git a/backend/product/migrations/0054_productmodel_bot_banner.py b/backend/product/migrations/0054_productmodel_bot_banner.py new file mode 100644 index 0000000..986becb --- /dev/null +++ b/backend/product/migrations/0054_productmodel_bot_banner.py @@ -0,0 +1,18 @@ +# Generated by Django 5.1.2 on 2025-08-04 20:41 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('product', '0053_productmodel_show_in_bot'), + ] + + operations = [ + migrations.AddField( + model_name='productmodel', + name='bot_banner', + field=models.TextField(blank=True, null=True, verbose_name='بنر ربات'), + ), + ] diff --git a/backend/product/models.py b/backend/product/models.py index 44ebf6e..9f6f817 100644 --- a/backend/product/models.py +++ b/backend/product/models.py @@ -124,7 +124,7 @@ class ProductModel(models.Model): related_products = models.ManyToManyField('self', blank=True, verbose_name='محصولات مرتبط') shop = models.ForeignKey('account.ShopModel', on_delete=models.CASCADE, related_name='products', verbose_name='فروشگاه', blank=True, null=True) show_in_bot = models.BooleanField(default=False, verbose_name='نمایش در ربات') - + bot_banner = models.TextField(null=True, blank=True, verbose_name='بنر ربات') def __str__(self): return self.name diff --git a/backend/product/urls.py b/backend/product/urls.py index 4b196a9..70ce765 100644 --- a/backend/product/urls.py +++ b/backend/product/urls.py @@ -1,9 +1,10 @@ from django.urls import path, re_path -from .views import AllCategories, ProductView, AllProductsView, CommentView, ShowCaseProductsView, ShowCaseCategoryListView, BotProductsView +from .views import AllCategories, ProductView, AllProductsView, CommentView, ShowCaseProductsView, ShowCaseCategoryListView, BotProductsView,BotProductDetailView urlpatterns = [ path('slider_category', ShowCaseProductsView.as_view(), name='category-products'), path('bot', BotProductsView.as_view(), name='bot-products'), + path('bot//', BotProductDetailView.as_view(), name='bot-product-detail'), path('categories', AllCategories.as_view(), name='all-categories'), path('slider_categories', ShowCaseCategoryListView.as_view(), name='all-categories'), re_path(r'^comments/(?P[\w\u0600-\u06FF\-]+)$', CommentView.as_view(), name='comment-views'), diff --git a/backend/product/views.py b/backend/product/views.py index 5848288..2d5950e 100644 --- a/backend/product/views.py +++ b/backend/product/views.py @@ -459,4 +459,14 @@ class BotProductsView(APIView): return Response({ "success": False, "products": [] - }) \ No newline at end of file + }) + + +class BotProductDetailView(APIView): + def get(self, request, pk): + product = get_object_or_404(ProductModel, pk=pk, show_in_bot=True) + + return Response({ + 'banner' : product.banner, + 'link': f'https://heymlz.com/product/{product.slug}' + }) \ No newline at end of file