Move django.conf settings import to module top in quotas
This commit is contained in:
@@ -6,6 +6,7 @@ from dataclasses import dataclass
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
from django.db.models import Count, Q, Sum
|
from django.db.models import Count, Q, Sum
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
|
||||||
@@ -165,8 +166,6 @@ def get_usage_snapshot(user) -> UsageSnapshot:
|
|||||||
|
|
||||||
|
|
||||||
def assert_feature_allowed(user, feature: str) -> None:
|
def assert_feature_allowed(user, feature: str) -> None:
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
if not getattr(settings, "ENFORCE_SUBSCRIPTION_GATES", True):
|
if not getattr(settings, "ENFORCE_SUBSCRIPTION_GATES", True):
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -249,8 +248,6 @@ def assert_within_quotas(user) -> UsageSnapshot:
|
|||||||
|
|
||||||
def check_generation_allowed(user, *, feature: str = "text_generation") -> UsageSnapshot:
|
def check_generation_allowed(user, *, feature: str = "text_generation") -> UsageSnapshot:
|
||||||
"""Combined feature + quota gate for a chat turn."""
|
"""Combined feature + quota gate for a chat turn."""
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
if not getattr(settings, "ENFORCE_SUBSCRIPTION_GATES", True):
|
if not getattr(settings, "ENFORCE_SUBSCRIPTION_GATES", True):
|
||||||
return get_usage_snapshot(user)
|
return get_usage_snapshot(user)
|
||||||
assert_feature_allowed(user, feature)
|
assert_feature_allowed(user, feature)
|
||||||
|
|||||||
Reference in New Issue
Block a user