# Generated by Django 5.2.6 on 2025-10-08 19:13 from django.db import migrations def create_assistant_permissions(apps, schema_editor): """Crear automáticamente permisos para todos los asistentes existentes""" UserProfile = apps.get_model('authentication', 'UserProfile') Asistente = apps.get_model('authentication', 'Asistente') # Obtener todos los UserProfile de tipo 'assistant' assistants = UserProfile.objects.filter(user_type='assistant') # Crear registro de Asistente para cada uno si no existe for assistant in assistants: Asistente.objects.get_or_create( user_profile=assistant, defaults={'can_manage_events': True} ) def reverse_migration(apps, schema_editor): """No hacer nada al revertir - mantener los permisos creados""" pass class Migration(migrations.Migration): dependencies = [ ('authentication', '0010_merge_20251003_2150'), ] operations = [ migrations.RunPython(create_assistant_permissions, reverse_migration), ]