Major updates including: - Customizable dashboard with drag-and-drop widget grid layout - Plan-based feature locking for plugins and tasks - Comprehensive help documentation updates across all pages - Plugin seeding in deployment process for all tenants - Permission synchronization system for subscription plans - QuotaOverageModal component and enhanced UX flows 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
68 lines
2.4 KiB
Python
68 lines
2.4 KiB
Python
"""
|
|
Core App Signals
|
|
|
|
Handles automatic setup tasks when tenants are created.
|
|
"""
|
|
import logging
|
|
from django.db.models.signals import post_save
|
|
from django.dispatch import receiver
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
@receiver(post_save, sender='core.Tenant')
|
|
def seed_platform_plugins_on_tenant_create(sender, instance, created, **kwargs):
|
|
"""
|
|
Seed platform plugins when a new tenant is created.
|
|
|
|
This ensures new tenants have access to all marketplace plugins immediately.
|
|
"""
|
|
if not created:
|
|
return
|
|
|
|
# Skip public schema
|
|
if instance.schema_name == 'public':
|
|
return
|
|
|
|
# Defer the import to avoid circular imports
|
|
from django.db import connection
|
|
from django_tenants.utils import schema_context
|
|
from schedule.models import PluginTemplate
|
|
from django.utils import timezone
|
|
|
|
logger.info(f"Seeding platform plugins for new tenant: {instance.schema_name}")
|
|
|
|
try:
|
|
with schema_context(instance.schema_name):
|
|
# Import the plugin definitions from the seed command
|
|
from schedule.management.commands.seed_platform_plugins import get_platform_plugins
|
|
|
|
plugins_data = get_platform_plugins()
|
|
created_count = 0
|
|
|
|
for plugin_data in plugins_data:
|
|
# Check if plugin already exists by slug
|
|
if PluginTemplate.objects.filter(slug=plugin_data['slug']).exists():
|
|
continue
|
|
|
|
# Create the plugin
|
|
PluginTemplate.objects.create(
|
|
name=plugin_data['name'],
|
|
slug=plugin_data['slug'],
|
|
category=plugin_data['category'],
|
|
short_description=plugin_data['short_description'],
|
|
description=plugin_data['description'],
|
|
plugin_code=plugin_data['plugin_code'],
|
|
logo_url=plugin_data.get('logo_url', ''),
|
|
visibility=PluginTemplate.Visibility.PLATFORM,
|
|
is_approved=True,
|
|
approved_at=timezone.now(),
|
|
author_name='Smooth Schedule',
|
|
license_type='PLATFORM',
|
|
)
|
|
created_count += 1
|
|
|
|
logger.info(f"Created {created_count} platform plugins for tenant: {instance.schema_name}")
|
|
except Exception as e:
|
|
logger.error(f"Failed to seed plugins for tenant {instance.schema_name}: {e}")
|