- Создана структура marketplaces/ для маркетплейсов - Модели: MarketplaceIntegration, WooCommerceIntegration, RecommerceIntegration - Сервисы: MarketplaceService, WooCommerceService, RecommerceService - RecommerceService содержит методы для работы с API: - test_connection(), sync(), fetch_products() - push_product(), update_stock(), update_price() - IntegrationConfig обновлён с новой интеграцией Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
45 lines
2.0 KiB
Python
45 lines
2.0 KiB
Python
from django.contrib import admin
|
|
from system_settings.models import IntegrationConfig
|
|
|
|
|
|
@admin.register(IntegrationConfig)
|
|
class IntegrationConfigAdmin(admin.ModelAdmin):
|
|
"""Админка для настроек интеграций (тумблеров)"""
|
|
list_display = ['get_integration_id_display', 'is_enabled', 'last_sync_at', 'updated_at']
|
|
list_filter = ['is_enabled', 'integration_id']
|
|
search_fields = ['integration_id']
|
|
list_editable = ['is_enabled']
|
|
|
|
def has_add_permission(self, request):
|
|
"""Запретить добавление новых интеграций вручную"""
|
|
return False
|
|
|
|
def has_delete_permission(self, request, obj=None):
|
|
"""Запретить удаление интеграций"""
|
|
return False
|
|
|
|
|
|
# Регистрация конкретных интеграций (когда будут готовы):
|
|
#
|
|
# @admin.register(WooCommerceIntegration)
|
|
# class WooCommerceIntegrationAdmin(admin.ModelAdmin):
|
|
# list_display = ['name', 'store_url', 'is_active', 'is_configured', 'updated_at']
|
|
# list_filter = ['is_active', 'auto_sync_products']
|
|
# fieldsets = (
|
|
# ('Основное', {'fields': ('name', 'is_active')}),
|
|
# ('API настройки', {'fields': ('store_url', 'consumer_key', 'consumer_secret')}),
|
|
# ('Синхронизация', {'fields': ('auto_sync_products', 'import_orders')}),
|
|
# )
|
|
#
|
|
#
|
|
# @admin.register(RecommerceIntegration)
|
|
# class RecommerceIntegrationAdmin(admin.ModelAdmin):
|
|
# list_display = ['name', 'merchant_id', 'is_active', 'is_configured', 'updated_at']
|
|
# list_filter = ['is_active', 'sync_prices', 'sync_stock']
|
|
# fieldsets = (
|
|
# ('Основное', {'fields': ('name', 'is_active')}),
|
|
# ('API настройки', {'fields': ('store_url', 'api_endpoint', 'api_token', 'merchant_id')}),
|
|
# ('Синхронизация', {'fields': ('auto_sync_products', 'import_orders', 'sync_prices', 'sync_stock')}),
|
|
# )
|
|
|