## Summary Implements epic [#42](#42) (children #43–#53) and advances [#11](#11). - **Entitlement:** `allows_rag` on plans (founders / backer / pro / business; not standard); exposed as `features.rag` - **Gates:** document REST + WS `PromptType.RAG` use `assert_feature_allowed(..., "rag")` - **Lifecycle:** dedupe ingest, delete vectors by `document_id`, honor `active`, fix document detail PATCH/DELETE - **Workspaces:** auto-create default company workspace; fail-closed scoping - **Drive:** personal + company Google/Microsoft connect (`link_drive` / `link_company_drive`), resource selection, sync, webhooks stubs, `sync_drive_connections` management command - **Docs/env:** README + `.env*.example` updated Companion FE: `chat_web_app` branch `feature/rag-epic-42-ui` (#81–#85). ## Test plan - [x] `SKIP_RAG_INIT=1 uv run python manage.py test` (457 OK) - [ ] Migrate finance `0004` + chat_backend `0028` on beta - [ ] Verify Standard user: Documents API 403 + no RAG retrieval - [ ] Verify Founders/Pro: upload + list + active toggle - [ ] Connect Google/Microsoft Drive (incremental scopes) and Sync - [ ] Company manager: `link_company_drive`; non-manager 403 - [ ] Run `manage.py sync_drive_connections`Reviewed-on: #54
This commit was merged in pull request #54.
This commit is contained in:
@@ -7,9 +7,113 @@ from django.db import migrations, models
|
||||
|
||||
|
||||
def seed_plans(apps, schema_editor):
|
||||
from finance.services.plans import seed_subscription_plans
|
||||
"""Seed the original 5-plan catalog frozen at this migration's schema.
|
||||
|
||||
seed_subscription_plans(update_existing=True)
|
||||
Deliberately does NOT import ``finance.services.plans`` — that module's
|
||||
``PLAN_SEED``/model class reflect the *current* code, so a later required
|
||||
field (e.g. ``allows_rag`` added in #43) would make this historical
|
||||
RunPython try to write a column that doesn't exist yet when a fresh
|
||||
database replays migrations in order. Live code re-seeds (and adds any
|
||||
new fields) via ``seed_subscription_plans()`` calls elsewhere (app
|
||||
startup, quota checks, test setUp), so this only needs to create the
|
||||
original rows.
|
||||
"""
|
||||
SubscriptionPlan = apps.get_model("finance", "SubscriptionPlan")
|
||||
seed = [
|
||||
{
|
||||
"slug": "founders",
|
||||
"name": "Founders",
|
||||
"description": (
|
||||
"Unlimited product access for early supporters: text plus all future "
|
||||
"capabilities as they ship. $10/mo."
|
||||
),
|
||||
"price_cents": 1000,
|
||||
"is_public": True,
|
||||
"is_selectable": True,
|
||||
"allows_text_generation": True,
|
||||
"allows_image_generation": True,
|
||||
"allows_all_future_features": True,
|
||||
"prompt_quota_per_window": 300,
|
||||
"prompt_window_hours": 6,
|
||||
"monthly_token_quota": None,
|
||||
"sort_order": 10,
|
||||
},
|
||||
{
|
||||
"slug": "standard",
|
||||
"name": "Standard",
|
||||
"description": (
|
||||
"Secure conversational chat and coding assistance for developers "
|
||||
"and privacy-conscious individuals."
|
||||
),
|
||||
"price_cents": 1500,
|
||||
"is_public": False,
|
||||
"is_selectable": False,
|
||||
"allows_text_generation": True,
|
||||
"allows_image_generation": False,
|
||||
"allows_all_future_features": False,
|
||||
"prompt_quota_per_window": 100,
|
||||
"prompt_window_hours": 6,
|
||||
"monthly_token_quota": 1_000_000,
|
||||
"sort_order": 20,
|
||||
},
|
||||
{
|
||||
"slug": "pro",
|
||||
"name": "Pro / Creator",
|
||||
"description": (
|
||||
"Higher message caps and multi-modal workflows for heavy users, "
|
||||
"including image generation when available."
|
||||
),
|
||||
"price_cents": 4000,
|
||||
"is_public": False,
|
||||
"is_selectable": False,
|
||||
"allows_text_generation": True,
|
||||
"allows_image_generation": True,
|
||||
"allows_all_future_features": False,
|
||||
"prompt_quota_per_window": 200,
|
||||
"prompt_window_hours": 6,
|
||||
"monthly_token_quota": 3_000_000,
|
||||
"sort_order": 30,
|
||||
},
|
||||
{
|
||||
"slug": "business",
|
||||
"name": "Business Team",
|
||||
"description": (
|
||||
"Team seats, centralized auth, priority support, and absolute data "
|
||||
"privacy for local companies handling sensitive data."
|
||||
),
|
||||
"price_cents": 9900,
|
||||
"is_public": False,
|
||||
"is_selectable": False,
|
||||
"allows_text_generation": True,
|
||||
"allows_image_generation": True,
|
||||
"allows_all_future_features": False,
|
||||
"prompt_quota_per_window": 300,
|
||||
"prompt_window_hours": 6,
|
||||
"monthly_token_quota": 5_000_000,
|
||||
"sort_order": 40,
|
||||
},
|
||||
{
|
||||
"slug": "backer",
|
||||
"name": "Backer",
|
||||
"description": (
|
||||
"Complimentary Founders-level access for pre-approved emails. "
|
||||
"Not shown at checkout."
|
||||
),
|
||||
"price_cents": 0,
|
||||
"is_public": False,
|
||||
"is_selectable": False,
|
||||
"allows_text_generation": True,
|
||||
"allows_image_generation": True,
|
||||
"allows_all_future_features": True,
|
||||
"prompt_quota_per_window": 300,
|
||||
"prompt_window_hours": 6,
|
||||
"monthly_token_quota": None,
|
||||
"sort_order": 5,
|
||||
},
|
||||
]
|
||||
for row in seed:
|
||||
slug = row.pop("slug")
|
||||
SubscriptionPlan.objects.get_or_create(slug=slug, defaults=row)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
# Generated by Django 6.0 on 2026-08-01 20:15
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("finance", "0003_subscription_cancel_period_fields"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="subscriptionplan",
|
||||
name="allows_rag",
|
||||
field=models.BooleanField(
|
||||
default=False,
|
||||
help_text="Drive/RAG document sync (Google Drive, OneDrive, SharePoint).",
|
||||
),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user