Files
Andrey Smakotin 37394121e1 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>
2026-01-12 00:29:04 +03:00

37 lines
1.4 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from django.db import models
from .base import MarketplaceIntegration
from ...fields import EncryptedCharField
class RecommerceIntegration(MarketplaceIntegration):
"""
Интеграция с Recommerce.
Recommerce - платформа для управления интернет-магазином.
API документация: запросы отправляются на домен магазина с заголовком x-auth-token.
Обязательные настройки:
- store_url: URL магазина (домен для API запросов)
- api_token: токен авторизации (передаётся в заголовке x-auth-token)
"""
# API токен (x-auth-token) - ЗАШИФРОВАН
api_token = EncryptedCharField(
max_length=500,
blank=True,
verbose_name="API Токен (x-auth-token)",
help_text="Токен авторизации из панели управления Recommerce"
)
class Meta:
verbose_name = "Recommerce"
verbose_name_plural = "Recommerce"
def __str__(self):
return f"Recommerce: {self.name or self.store_url or 'не настроен'}"
@property
def is_configured(self) -> bool:
"""Recommerce требует store_url и api_token"""
return bool(self.store_url and self.api_token)