From 4b055595b3360c1b7887baf191cd1f508d558df9 Mon Sep 17 00:00:00 2001 From: GareArc Date: Fri, 14 Mar 2025 04:25:31 -0400 Subject: [PATCH] fix: seperate education fields from billing --- api/.env.example | 5 ++++- api/configs/feature/__init__.py | 5 +++++ api/services/feature_service.py | 9 ++++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/api/.env.example b/api/.env.example index 39eb7ad766..9adaea00e3 100644 --- a/api/.env.example +++ b/api/.env.example @@ -445,4 +445,7 @@ CREATE_TIDB_SERVICE_JOB_ENABLED=false # Maximum number of submitted thread count in a ThreadPool for parallel node execution MAX_SUBMIT_COUNT=100 # Lockout duration in seconds -LOGIN_LOCKOUT_DURATION=86400 \ No newline at end of file +LOGIN_LOCKOUT_DURATION=86400 + +# Education Identity +EDUCATION_ENABLED=false \ No newline at end of file diff --git a/api/configs/feature/__init__.py b/api/configs/feature/__init__.py index 2af9729073..6c2f180d5b 100644 --- a/api/configs/feature/__init__.py +++ b/api/configs/feature/__init__.py @@ -844,6 +844,11 @@ class AccountConfig(BaseSettings): default=5, ) + EDUCATION_ENABLED: bool = Field( + description="whether to enable education identity", + default=False, + ) + class FeatureConfig( # place the configs in alphabet order diff --git a/api/services/feature_service.py b/api/services/feature_service.py index 331f9b2a72..b856c0867c 100644 --- a/api/services/feature_service.py +++ b/api/services/feature_service.py @@ -18,6 +18,11 @@ class BillingModel(BaseModel): subscription: SubscriptionModel = SubscriptionModel() +class EducationModel(BaseModel): + enabled: bool = False + is_activated: bool = False + + class LimitationModel(BaseModel): size: int = 0 limit: int = 0 @@ -39,6 +44,7 @@ class LicenseModel(BaseModel): class FeatureModel(BaseModel): billing: BillingModel = BillingModel() + education: EducationModel = EducationModel() members: LimitationModel = LimitationModel(size=0, limit=1) apps: LimitationModel = LimitationModel(size=0, limit=10) vector_space: LimitationModel = LimitationModel(size=0, limit=5) @@ -112,6 +118,7 @@ class FeatureService: features.can_replace_logo = dify_config.CAN_REPLACE_LOGO features.model_load_balancing_enabled = dify_config.MODEL_LB_ENABLED features.dataset_operator_enabled = dify_config.DATASET_OPERATOR_ENABLED + features.education.enabled = dify_config.EDUCATION_ENABLED @classmethod def _fulfill_params_from_billing_api(cls, features: FeatureModel, tenant_id: str): @@ -120,7 +127,7 @@ class FeatureService: features.billing.enabled = billing_info["enabled"] features.billing.subscription.plan = billing_info["subscription"]["plan"] features.billing.subscription.interval = billing_info["subscription"]["interval"] - features.billing.subscription.education = billing_info["subscription"].get("education", False) + features.education.is_activated = billing_info["subscription"].get("education", False) if "members" in billing_info: features.members.size = billing_info["members"]["size"]