Исправлены 4 проблемы: 1. Расчёт цены первого товара - улучшена валидация в getProductPrice и calculateFinalPrice 2. Отображение actual_price в Select2 вместо обычной цены 3. Количество по умолчанию = 1 для новых форм компонентов 4. Auto-select текста при клике на поле количества для удобства редактирования Изменённые файлы: - products/forms.py: добавлен __init__ в KitItemForm для quantity.initial = 1 - products/templates/includes/select2-product-init.html: обновлена formatSelectResult - products/templates/productkit_create.html: добавлен focus handler для auto-select - products/templates/productkit_edit.html: добавлен focus handler для auto-select 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
68 lines
2.0 KiB
Python
68 lines
2.0 KiB
Python
import os
|
|
import sys
|
|
import django
|
|
|
|
# Добавляем путь к проекту
|
|
sys.path.insert(0, 'C:/Users/team_/Desktop/test_qwen/myproject')
|
|
|
|
# Настройка Django
|
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'myproject.settings')
|
|
django.setup()
|
|
|
|
from tenants.models import TenantRegistration, Client
|
|
from django.contrib.auth import get_user_model
|
|
from django.db import connection
|
|
from tenants.admin import TenantRegistrationAdmin
|
|
import uuid
|
|
|
|
# Уникальное имя
|
|
unique_id = str(uuid.uuid4())[:8]
|
|
schema_name = f'test_{unique_id}'
|
|
|
|
# Создаём новую заявку
|
|
registration = TenantRegistration.objects.create(
|
|
shop_name='Fresh Test',
|
|
schema_name=schema_name,
|
|
owner_email='fresh@example.com',
|
|
owner_name='Fresh User',
|
|
phone='+375291234567',
|
|
status=TenantRegistration.STATUS_PENDING
|
|
)
|
|
|
|
print(f"\n=== Testing Fresh Superuser Creation ===")
|
|
print(f"Schema: {schema_name}\n")
|
|
|
|
# Получаем админа из public
|
|
public_tenant = Client.objects.get(schema_name='public')
|
|
connection.set_tenant(public_tenant)
|
|
|
|
User = get_user_model()
|
|
admin_user = User.objects.first()
|
|
|
|
# Одобряем заявку
|
|
admin = TenantRegistrationAdmin(TenantRegistration, None)
|
|
|
|
try:
|
|
print("Approving registration...")
|
|
client = admin._approve_registration(registration, admin_user)
|
|
print("Approval completed!\n")
|
|
|
|
# Переключаемся в новый тенант
|
|
connection.set_tenant(client)
|
|
|
|
# Проверим пользователей
|
|
all_users = User.objects.all().order_by('email')
|
|
print(f"All users in {client.schema_name} schema ({all_users.count()} total):")
|
|
|
|
for u in all_users:
|
|
status = "SUPERUSER" if u.is_superuser else "regular"
|
|
print(f" - {u.email} ({u.name}) [{status}]")
|
|
|
|
if not all_users.exists():
|
|
print(" NO USERS FOUND - THIS IS A PROBLEM!")
|
|
|
|
except Exception as e:
|
|
print(f"ERROR: {str(e)}")
|
|
import traceback
|
|
traceback.print_exc()
|