fix: Exclude public schema from platform businesses listing
This commit is contained in:
@@ -804,8 +804,10 @@ class TenantViewSet(viewsets.ModelViewSet):
|
|||||||
http_method_names = ['get', 'post', 'patch', 'delete', 'head', 'options']
|
http_method_names = ['get', 'post', 'patch', 'delete', 'head', 'options']
|
||||||
|
|
||||||
def get_queryset(self):
|
def get_queryset(self):
|
||||||
"""Optionally filter by active status"""
|
"""Filter out public schema and optionally filter by active status"""
|
||||||
queryset = super().get_queryset()
|
queryset = super().get_queryset()
|
||||||
|
# Exclude the public schema (it's the platform, not a business)
|
||||||
|
queryset = queryset.exclude(schema_name='public')
|
||||||
is_active = self.request.query_params.get('is_active')
|
is_active = self.request.query_params.get('is_active')
|
||||||
if is_active is not None:
|
if is_active is not None:
|
||||||
queryset = queryset.filter(is_active=is_active.lower() == 'true')
|
queryset = queryset.filter(is_active=is_active.lower() == 'true')
|
||||||
@@ -872,8 +874,9 @@ class TenantViewSet(viewsets.ModelViewSet):
|
|||||||
@action(detail=False, methods=['get'])
|
@action(detail=False, methods=['get'])
|
||||||
def metrics(self, request):
|
def metrics(self, request):
|
||||||
"""Get platform-wide tenant metrics"""
|
"""Get platform-wide tenant metrics"""
|
||||||
total_tenants = Tenant.objects.count()
|
# Exclude public schema from counts (it's the platform, not a business)
|
||||||
active_tenants = Tenant.objects.filter(is_active=True).count()
|
total_tenants = Tenant.objects.exclude(schema_name='public').count()
|
||||||
|
active_tenants = Tenant.objects.exclude(schema_name='public').filter(is_active=True).count()
|
||||||
|
|
||||||
metrics = {
|
metrics = {
|
||||||
'total_tenants': total_tenants,
|
'total_tenants': total_tenants,
|
||||||
|
|||||||
@@ -0,0 +1,109 @@
|
|||||||
|
# Generated by Django 5.2.8 on 2025-12-08 16:17
|
||||||
|
|
||||||
|
import django.db.models.deletion
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
initial = True
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='BusinessSite',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('site_name', models.CharField(help_text='Site title (defaults to business name)', max_length=200)),
|
||||||
|
('tagline', models.CharField(blank=True, max_length=300)),
|
||||||
|
('custom_css', models.TextField(blank=True, help_text='Custom CSS (Professional tier and above)')),
|
||||||
|
('logo_url', models.URLField(blank=True)),
|
||||||
|
('favicon_url', models.URLField(blank=True)),
|
||||||
|
('primary_color', models.CharField(blank=True, help_text='Hex color (e.g., #3B82F6)', max_length=7)),
|
||||||
|
('secondary_color', models.CharField(blank=True, help_text='Hex color', max_length=7)),
|
||||||
|
('seo_title', models.CharField(blank=True, help_text='Page title for search engines (max 60 chars)', max_length=60)),
|
||||||
|
('seo_description', models.CharField(blank=True, help_text='Meta description for search engines (max 160 chars)', max_length=160)),
|
||||||
|
('og_image_url', models.URLField(blank=True, help_text='Open Graph image for social sharing')),
|
||||||
|
('custom_domain', models.CharField(blank=True, help_text='Custom domain (Enterprise tier only)', max_length=253)),
|
||||||
|
('custom_domain_verified', models.BooleanField(default=False)),
|
||||||
|
('is_published', models.BooleanField(default=False)),
|
||||||
|
('published_at', models.DateTimeField(blank=True, null=True)),
|
||||||
|
('google_analytics_id', models.CharField(blank=True, help_text='Google Analytics measurement ID (e.g., G-XXXXXXXXXX)', max_length=50)),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('updated_at', models.DateTimeField(auto_now=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'verbose_name': 'Business Site',
|
||||||
|
'verbose_name_plural': 'Business Sites',
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='Theme',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('name', models.CharField(max_length=100)),
|
||||||
|
('slug', models.SlugField(unique=True)),
|
||||||
|
('description', models.TextField(blank=True)),
|
||||||
|
('preview_image', models.URLField(blank=True)),
|
||||||
|
('css_variables', models.JSONField(default=dict, help_text='CSS custom properties for theming')),
|
||||||
|
('component_styles', models.JSONField(default=dict, help_text='Component-specific style overrides')),
|
||||||
|
('tier_required', models.CharField(choices=[('FREE', 'Free'), ('STARTER', 'Starter'), ('PROFESSIONAL', 'Professional'), ('ENTERPRISE', 'Enterprise')], default='FREE', max_length=20)),
|
||||||
|
('is_default', models.BooleanField(default=False)),
|
||||||
|
('is_active', models.BooleanField(default=True)),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('updated_at', models.DateTimeField(auto_now=True)),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'ordering': ['name'],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='SitePage',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('title', models.CharField(max_length=200)),
|
||||||
|
('slug', models.SlugField(help_text="URL path (e.g., 'about' for /about)", max_length=100)),
|
||||||
|
('page_type', models.CharField(choices=[('HOME', 'Home Page'), ('SERVICES', 'Services'), ('ABOUT', 'About Us'), ('CONTACT', 'Contact'), ('BOOKING', 'Booking'), ('CUSTOM', 'Custom Page')], default='CUSTOM', max_length=20)),
|
||||||
|
('seo_title', models.CharField(blank=True, help_text='Override site SEO title for this page', max_length=60)),
|
||||||
|
('seo_description', models.CharField(blank=True, help_text='Override site SEO description for this page', max_length=160)),
|
||||||
|
('show_in_nav', models.BooleanField(default=True, help_text='Show this page in the navigation menu')),
|
||||||
|
('nav_title', models.CharField(blank=True, help_text='Navigation menu title (defaults to page title)', max_length=50)),
|
||||||
|
('display_order', models.PositiveIntegerField(default=0)),
|
||||||
|
('is_published', models.BooleanField(default=True)),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('updated_at', models.DateTimeField(auto_now=True)),
|
||||||
|
('site', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='pages', to='site_builder.businesssite')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'ordering': ['display_order', 'title'],
|
||||||
|
'unique_together': {('site', 'slug')},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='PageSection',
|
||||||
|
fields=[
|
||||||
|
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('section_type', models.CharField(choices=[('HERO', 'Hero Banner'), ('TEXT', 'Text Block'), ('IMAGE', 'Image'), ('GALLERY', 'Image Gallery'), ('SERVICES_LIST', 'Services List'), ('BOOKING_WIDGET', 'Booking Widget'), ('CONTACT_FORM', 'Contact Form'), ('MAP', 'Map'), ('TESTIMONIALS', 'Testimonials'), ('FAQ', 'FAQ'), ('CUSTOM_HTML', 'Custom HTML'), ('SPACER', 'Spacer'), ('DIVIDER', 'Divider')], max_length=30)),
|
||||||
|
('content', models.JSONField(default=dict, help_text='Section content (structure depends on section_type)')),
|
||||||
|
('display_order', models.PositiveIntegerField(default=0)),
|
||||||
|
('is_visible', models.BooleanField(default=True)),
|
||||||
|
('custom_css', models.TextField(blank=True, help_text='Section-specific CSS (Professional tier and above)')),
|
||||||
|
('css_classes', models.CharField(blank=True, help_text='Additional CSS classes to apply', max_length=200)),
|
||||||
|
('hide_on_mobile', models.BooleanField(default=False)),
|
||||||
|
('hide_on_desktop', models.BooleanField(default=False)),
|
||||||
|
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||||
|
('updated_at', models.DateTimeField(auto_now=True)),
|
||||||
|
('page', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='sections', to='site_builder.sitepage')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'ordering': ['display_order'],
|
||||||
|
},
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='businesssite',
|
||||||
|
name='theme',
|
||||||
|
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='sites', to='site_builder.theme'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.2.8 on 2025-12-08 17:07
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('site_builder', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='sitepage',
|
||||||
|
name='puck_data',
|
||||||
|
field=models.JSONField(blank=True, default=dict, help_text='Puck editor data (JSON format) - stores full page layout including content array and root props'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.2.8 on 2025-12-08 21:50
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('site_builder', '0002_sitepage_puck_data'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='sitepage',
|
||||||
|
name='slug',
|
||||||
|
field=models.CharField(blank=True, default='', help_text="URL path (e.g., 'about' for /about). Leave empty for the home page at /", max_length=100),
|
||||||
|
),
|
||||||
|
]
|
||||||
Reference in New Issue
Block a user