From ab15546979727db26dc0d017be098b221a18edf9 Mon Sep 17 00:00:00 2001 From: alorig <220087330+alorig@users.noreply.github.com> Date: Sat, 22 Nov 2025 09:23:22 +0500 Subject: [PATCH] 1 --- QUICK-FIX-NOW.md | 130 ++++++++++++++++++++++++++++++++++++ backend/inject_test_data.py | 87 ++++++++++++++++++++++++ 2 files changed, 217 insertions(+) create mode 100644 QUICK-FIX-NOW.md create mode 100644 backend/inject_test_data.py diff --git a/QUICK-FIX-NOW.md b/QUICK-FIX-NOW.md new file mode 100644 index 00000000..b1e3852f --- /dev/null +++ b/QUICK-FIX-NOW.md @@ -0,0 +1,130 @@ +# QUICK FIX - INJECT TEST DATA NOW + +## 🚨 IMMEDIATE ACTION TO FIX THE PAGE + +The page is empty because WordPress hasn't pushed data yet. Here's how to fix it RIGHT NOW: + +--- + +## ✅ SOLUTION: Run This Command + +Open your terminal where Docker is available and run: + +```bash +docker exec -it igny8_backend python manage.py shell +``` + +Then paste this code: + +```python +from igny8_core.business.integration.models import SiteIntegration +from igny8_core.auth.models import Site +from django.utils import timezone + +# Get site 5 +site = Site.objects.get(id=5) +print(f"Site: {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!") +print(f"Integration ID: {integration.id}") +exit() +``` + +--- + +## 🔄 THEN: Refresh the Page + +After running that command, go to your browser and refresh: + +**https://app.igny8.com/sites/5/settings?tab=content-types** + +You should now see: +- ✅ Post Types (Posts, Pages, Products) +- ✅ Taxonomies (Categories, Tags, Product Categories) +- ✅ Last structure fetch timestamp + +--- + +## 📝 WHAT THIS DOES + +This manually adds the WordPress structure data to the backend database, simulating what the WordPress plugin would do. This lets you verify the fix works without deploying WordPress plugin files first. + +--- + +## ⚠️ ALTERNATIVE: If Docker Not Available + +If you can't run Docker commands, you need to: + +1. Deploy the WordPress plugin files to your WordPress site +2. Go to WordPress Admin → Settings → IGNY8 API +3. Click "Connect to IGNY8" +4. Wait for structure sync +5. Refresh frontend page + +--- + +**TL;DR**: Run the Django shell command above, then refresh the browser page. It will work! + diff --git a/backend/inject_test_data.py b/backend/inject_test_data.py new file mode 100644 index 00000000..65df41e3 --- /dev/null +++ b/backend/inject_test_data.py @@ -0,0 +1,87 @@ +""" +Django Management Command to Manually Add WordPress Structure Data +Run this in Django shell or as a management command +""" + +from igny8_core.business.integration.models import SiteIntegration +from igny8_core.auth.models import Site +from django.utils import timezone + +# Get site 5 +site = Site.objects.get(id=5) +print(f"Site: {site.name}") + +# Get or create WordPress integration for this site +integration, created = SiteIntegration.objects.get_or_create( + site=site, + platform='wordpress', + defaults={ + 'is_active': True, + 'sync_enabled': True, + 'config_json': {} + } +) + +print(f"Integration: {integration.id} (created: {created})") + +# Add structure data +integration.config_json = { + 'content_types': { + 'post_types': { + 'post': { + 'label': 'Posts', + 'count': 150, + 'enabled': True, + 'fetch_limit': 100, + 'synced_count': 0 + }, + 'page': { + 'label': 'Pages', + 'count': 25, + 'enabled': True, + 'fetch_limit': 100, + 'synced_count': 0 + }, + 'product': { + 'label': 'Products', + 'count': 89, + 'enabled': True, + 'fetch_limit': 100, + 'synced_count': 0 + } + }, + 'taxonomies': { + 'category': { + 'label': 'Categories', + 'count': 15, + 'enabled': True, + 'fetch_limit': 100, + 'synced_count': 0 + }, + 'post_tag': { + 'label': 'Tags', + 'count': 234, + 'enabled': True, + 'fetch_limit': 100, + 'synced_count': 0 + }, + 'product_cat': { + 'label': 'Product Categories', + 'count': 12, + 'enabled': True, + 'fetch_limit': 100, + 'synced_count': 0 + } + }, + 'last_structure_fetch': timezone.now().isoformat() + }, + 'plugin_connection_enabled': True, + 'two_way_sync_enabled': True +} + +integration.save() +print("✓ Structure data saved!") +print(f"Integration ID: {integration.id}") +print(f"Content Types: {len(integration.config_json['content_types']['post_types'])} post types, {len(integration.config_json['content_types']['taxonomies'])} taxonomies") +print("\nNow refresh: https://app.igny8.com/sites/5/settings?tab=content-types") +