fix: Улучшения системы ценообразования комплектов
Исправлены 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>
This commit is contained in:
86
test_superuser_creation.py
Normal file
86
test_superuser_creation.py
Normal file
@@ -0,0 +1,86 @@
|
||||
import os
|
||||
import sys
|
||||
import django
|
||||
import logging
|
||||
|
||||
# Настройка логирования
|
||||
logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s')
|
||||
|
||||
# Добавляем путь к проекту
|
||||
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
|
||||
|
||||
# Создаём новую заявку
|
||||
registration = TenantRegistration.objects.create(
|
||||
shop_name='Test Shop 5',
|
||||
schema_name='shop5',
|
||||
owner_email='shop5@example.com',
|
||||
owner_name='Jane Doe',
|
||||
phone='+375291234567',
|
||||
status=TenantRegistration.STATUS_PENDING
|
||||
)
|
||||
|
||||
print(f"\n=== Testing Superuser Creation ===")
|
||||
print(f"Created registration: {registration.id} for {registration.schema_name}\n")
|
||||
|
||||
# Одобряем заявку
|
||||
admin = TenantRegistrationAdmin(TenantRegistration, None)
|
||||
User = get_user_model()
|
||||
|
||||
# Получаем системного пользователя
|
||||
public_tenant = Client.objects.get(schema_name='public')
|
||||
connection.set_tenant(public_tenant)
|
||||
|
||||
try:
|
||||
admin_user = User.objects.get(email='admin@localhost')
|
||||
except User.DoesNotExist:
|
||||
admin_user = User.objects.create_superuser(
|
||||
email='admin@localhost',
|
||||
name='Admin',
|
||||
password='admin'
|
||||
)
|
||||
|
||||
try:
|
||||
print("Approving registration...")
|
||||
admin._approve_registration(registration, admin_user)
|
||||
print("\nApproval completed!\n")
|
||||
|
||||
# Проверяем, был ли создан суперпользователь в новом тенанте
|
||||
registration.refresh_from_db()
|
||||
tenant = registration.tenant
|
||||
|
||||
print(f"Tenant created: {tenant.name} ({tenant.schema_name})")
|
||||
|
||||
# Переключаемся на новый тенант и проверяем пользователей
|
||||
connection.set_tenant(tenant)
|
||||
|
||||
superusers = User.objects.filter(is_superuser=True)
|
||||
print(f"\nSuperusers in {tenant.schema_name} schema:")
|
||||
|
||||
if superusers.exists():
|
||||
for su in superusers:
|
||||
print(f" OK: {su.email} ({su.name})")
|
||||
else:
|
||||
print(" FAIL: No superusers found!")
|
||||
|
||||
# Проверим ВСЕ пользователей
|
||||
all_users = User.objects.all()
|
||||
print(f"\nAll users in {tenant.schema_name} schema:")
|
||||
if all_users.exists():
|
||||
for u in all_users:
|
||||
print(f" - {u.email} (superuser={u.is_superuser})")
|
||||
else:
|
||||
print(" - No users found at all!")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error during approval: {str(e)}")
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
Reference in New Issue
Block a user