Paywall: first unit of each grade free; 1/3/6-month subscriptions; AI sold separately
- content: unit_is_free/has_unit_access; questions, node quiz, answer and lesson/node complete return 402 subscription_required outside the first unit without an active subscription. /api/home units carry requiresSubscription. - subscription.0013: monthly 498k, quarterly 798k, six-month 1,298k toman, unlimited hearts, 3 AI questions/day; packs stay on sale for more questions. - AI_DAILY_QUOTA_FREE default 3 -> 2. - /api/subscription/status adds planTitle, planDurationDays, aiDailyQuota. - tests: content/tests_paywall.py; existing unlock-order tests get a subscription. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -486,7 +486,7 @@ class YearlyPlanSeedTests(TestCase):
|
||||
self.assertTrue(plan.features)
|
||||
|
||||
def test_a_monthly_plan_is_created_next_to_it(self):
|
||||
plan = Plan.objects.get(duration_days=30)
|
||||
plan = Plan.objects.get(duration_days=30, on_sale=False)
|
||||
self.assertEqual((plan.price, plan.ai_daily_quota), (179_000, 10))
|
||||
|
||||
def test_repricing_leaves_an_admin_edited_yearly_plan_alone(self):
|
||||
@@ -498,16 +498,20 @@ class YearlyPlanSeedTests(TestCase):
|
||||
importlib.import_module('subscription.migrations.0008_paid_quota_ten_a_day').apply(global_apps, None)
|
||||
plan = Plan.objects.get(title='اشتراک یکساله')
|
||||
self.assertEqual((plan.price, plan.ai_daily_quota), (450_000, 9))
|
||||
self.assertEqual(Plan.objects.filter(duration_days=30).count(), 1)
|
||||
self.assertEqual(Plan.objects.filter(duration_days=30, on_sale=False).count(), 1)
|
||||
|
||||
def test_only_question_packs_are_on_sale(self):
|
||||
def test_packs_and_new_subscriptions_are_on_sale(self):
|
||||
from django.core.cache import cache
|
||||
cache.clear()
|
||||
data = self.client.get('/api/subscription/plans').json()
|
||||
self.assertEqual({p['kind'] for p in data['plans']}, {'pack'})
|
||||
self.assertEqual([p['questionCredits'] for p in data['plans']], [20, 60, 150])
|
||||
self.assertEqual([p['heartsDays'] for p in data['plans']], [7, 30, 60])
|
||||
self.assertEqual(data['freeAiDailyQuota'], 3)
|
||||
packs = [p for p in data['plans'] if p['kind'] == 'pack']
|
||||
subs = [p for p in data['plans'] if p['kind'] == 'subscription']
|
||||
self.assertEqual([p['questionCredits'] for p in packs], [20, 60, 150])
|
||||
self.assertEqual([p['heartsDays'] for p in packs], [7, 30, 60])
|
||||
# subscription.0013: یک/سه/ششماهه با سقفِ ۳ سوال در روز.
|
||||
self.assertEqual([(p['durationDays'], p['price'], p['aiDailyQuota']) for p in subs],
|
||||
[(30, 498_000, 3), (90, 798_000, 3), (180, 1_298_000, 3)])
|
||||
self.assertEqual(data['freeAiDailyQuota'], 2)
|
||||
# پلنهای اشتراکی پاک نشدهاند؛ فقط فروخته نمیشوند.
|
||||
self.assertFalse(Plan.objects.get(title='اشتراک یکساله').on_sale)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user