fix: avoid MySQL timezone dependency in billing admin
This commit is contained in:
@@ -31,7 +31,6 @@ class PointsLedgerAdmin(ReadOnlyLedgerAdmin):
|
||||
list_filter = ("change_type", "created_at")
|
||||
search_fields = ("user__username", "user__email", "=ref_order_id", "reason")
|
||||
ordering = ("-created_at", "-id")
|
||||
date_hierarchy = "created_at"
|
||||
list_select_related = ("user", "ref_call")
|
||||
|
||||
|
||||
@@ -70,7 +69,6 @@ class ExchangeRateAdmin(admin.ModelAdmin):
|
||||
ordering = ("-effective_from", "-id")
|
||||
readonly_fields = ("created_at", "updated_at")
|
||||
list_editable = ("is_active",)
|
||||
date_hierarchy = "effective_from"
|
||||
|
||||
|
||||
@admin.register(RechargeOrder)
|
||||
@@ -95,7 +93,6 @@ class RechargeOrderAdmin(ReadOnlyLedgerAdmin):
|
||||
"payment_txn_no",
|
||||
)
|
||||
ordering = ("-created_at", "-id")
|
||||
date_hierarchy = "created_at"
|
||||
list_select_related = ("user",)
|
||||
|
||||
|
||||
@@ -125,5 +122,4 @@ class CallRecordAdmin(ReadOnlyLedgerAdmin):
|
||||
"result_summary",
|
||||
)
|
||||
ordering = ("-created_at", "-id")
|
||||
date_hierarchy = "created_at"
|
||||
list_select_related = ("user", "api_key")
|
||||
|
||||
@@ -10,6 +10,7 @@ from django.contrib.auth import get_user_model
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.db import IntegrityError, OperationalError, connections, transaction
|
||||
from django.test import TestCase, TransactionTestCase, override_settings
|
||||
from django.urls import reverse
|
||||
from django.utils import timezone
|
||||
|
||||
from apps.ai.models import AiModel, ModelAlias
|
||||
@@ -49,6 +50,30 @@ from apps.users.models import ApiKey, UserWallet
|
||||
TEST_ENCRYPTION_KEY = Fernet.generate_key().decode("ascii")
|
||||
|
||||
|
||||
class BillingAdminTests(TestCase):
|
||||
def setUp(self):
|
||||
user_model = get_user_model()
|
||||
self.admin_user = user_model.objects.create_superuser(
|
||||
username="billing-admin",
|
||||
email="billing-admin@example.com",
|
||||
password="test-password",
|
||||
)
|
||||
self.client.force_login(self.admin_user)
|
||||
|
||||
def test_exchange_rate_changelist_renders_when_rates_exist(self):
|
||||
ExchangeRate.objects.create(
|
||||
currency="CNY",
|
||||
points_per_unit=Decimal("10.0000"),
|
||||
effective_from=timezone.now(),
|
||||
is_active=True,
|
||||
)
|
||||
|
||||
response = self.client.get(reverse("admin:billing_exchangerate_changelist"))
|
||||
|
||||
self.assertEqual(response.status_code, 200)
|
||||
self.assertContains(response, "CNY")
|
||||
|
||||
|
||||
class BillingCoreModelTests(TestCase):
|
||||
def setUp(self):
|
||||
suffix = uuid.uuid4().hex[:8]
|
||||
|
||||
Reference in New Issue
Block a user