feat(integrations): архитектура включения/выключения интеграций
- Удалена лишняя модель IntegrationConfig из system_settings - Singleton-паттерн: одна запись на интеграцию с is_active тумблером - Добавлено шифрование токенов (EncryptedCharField с Fernet AES-128) - UI: тумблеры слева, форма настроек справа - API endpoints: toggle, settings, form_data - Модель Recommerce: store_url + api_token (x-auth-token) - Модель WooCommerce: store_url + consumer_key/secret Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,21 +1,27 @@
|
||||
from django.db import models
|
||||
from .base import MarketplaceIntegration
|
||||
from ...fields import EncryptedCharField
|
||||
|
||||
|
||||
class WooCommerceIntegration(MarketplaceIntegration):
|
||||
"""Интеграция с WooCommerce"""
|
||||
"""
|
||||
Интеграция с WooCommerce.
|
||||
WooCommerce - плагин электронной коммерции для WordPress.
|
||||
"""
|
||||
|
||||
# WooCommerce-specific credentials
|
||||
consumer_key = models.CharField(
|
||||
# WooCommerce REST API credentials - ЗАШИФРОВАНЫ
|
||||
consumer_key = EncryptedCharField(
|
||||
max_length=255,
|
||||
blank=True,
|
||||
verbose_name="Consumer Key"
|
||||
verbose_name="Consumer Key",
|
||||
help_text="REST API Consumer Key (хранится зашифрованным)"
|
||||
)
|
||||
|
||||
consumer_secret = models.CharField(
|
||||
consumer_secret = EncryptedCharField(
|
||||
max_length=255,
|
||||
blank=True,
|
||||
verbose_name="Consumer Secret"
|
||||
verbose_name="Consumer Secret",
|
||||
help_text="REST API Consumer Secret (хранится зашифрованным)"
|
||||
)
|
||||
|
||||
# API версия (WooCommerce REST API v1, v2, v3)
|
||||
@@ -23,18 +29,18 @@ class WooCommerceIntegration(MarketplaceIntegration):
|
||||
max_length=10,
|
||||
default='v3',
|
||||
blank=True,
|
||||
verbose_name="Версия API"
|
||||
verbose_name="Версия API",
|
||||
help_text="Версия WooCommerce REST API"
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "WooCommerce"
|
||||
verbose_name_plural = "WooCommerce"
|
||||
managed = False # Пока заготовка - без создания таблицы
|
||||
|
||||
def __str__(self):
|
||||
return f"WooCommerce: {self.name or self.store_url}"
|
||||
return f"WooCommerce: {self.name or self.store_url or 'не настроен'}"
|
||||
|
||||
@property
|
||||
def is_configured(self) -> bool:
|
||||
"""WooCommerce требует consumer_key и consumer_secret"""
|
||||
return bool(self.consumer_key and self.consumer_secret)
|
||||
return bool(self.consumer_key and self.consumer_secret and self.store_url)
|
||||
|
||||
Reference in New Issue
Block a user