Files
igny8/fix_content_types.py

89 lines
2.5 KiB
Python

#!/usr/bin/env python
import os
import django
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'igny8_core.settings')
django.setup()
from igny8_core.business.integration.models import SiteIntegration
from igny8_core.auth.models import Site
from django.utils import timezone
try:
# Get site 5
site = Site.objects.get(id=5)
print(f"✓ Site found: {site.name}")
# Get or create WordPress integration
integration, created = SiteIntegration.objects.get_or_create(
site=site,
platform='wordpress',
defaults={
'is_active': True,
'sync_enabled': True,
'config_json': {}
}
)
print(f"✓ Integration ID: {integration.id} (created: {created})")
# Add structure data
integration.config_json = {
'content_types': {
'post_types': {
'post': {
'label': 'Posts',
'count': 150,
'enabled': True,
'fetch_limit': 100
},
'page': {
'label': 'Pages',
'count': 25,
'enabled': True,
'fetch_limit': 100
},
'product': {
'label': 'Products',
'count': 89,
'enabled': True,
'fetch_limit': 100
}
},
'taxonomies': {
'category': {
'label': 'Categories',
'count': 15,
'enabled': True,
'fetch_limit': 100
},
'post_tag': {
'label': 'Tags',
'count': 234,
'enabled': True,
'fetch_limit': 100
},
'product_cat': {
'label': 'Product Categories',
'count': 12,
'enabled': True,
'fetch_limit': 100
}
},
'last_structure_fetch': timezone.now().isoformat()
},
'plugin_connection_enabled': True,
'two_way_sync_enabled': True
}
integration.save()
print("✓ Structure data saved successfully!")
print(f"✓ Integration ID: {integration.id}")
print("\n✅ READY: Refresh the page to see the content types!")
except Exception as e:
print(f"❌ ERROR: {str(e)}")
import traceback
traceback.print_exc()