This commit is contained in:
2026-09-04 13:05:54 +03:30
parent 463b812e3e
commit 17082a5ea9
43 changed files with 5663 additions and 285 deletions
+11 -3
View File
@@ -33,13 +33,21 @@ class FeaturePlanSerializer(serializers.ModelSerializer):
class Meta:
model = FeaturePlan
fields = ["key", "name", "tiers", "is_active", "expires_at"]
fields = ["key", "name", "tiers", "is_active", "is_free", "expires_at"]
def get_is_active(self, obj: FeaturePlan) -> bool:
return FeatureAccessService.is_active(self.context["request"].user, obj.key)
# مهمان (بدون حساب): فقط ابزارهای رایگان باز است — بدونِ این شاخه،
# AnonymousUser به is_active می‌رسید و خطا می‌داد.
user = self.context["request"].user
if not user.is_authenticated:
return obj.is_free
return FeatureAccessService.is_active(user, obj.key)
def get_expires_at(self, obj: FeaturePlan):
return FeatureAccessService.expires_at(self.context["request"].user, obj.key)
user = self.context["request"].user
if not user.is_authenticated:
return None
return FeatureAccessService.expires_at(user, obj.key)
class GemPackSerializer(serializers.ModelSerializer):