Files
chat_backend/llm_be/chat_backend/urls.py
T
westfarn d54094f5e0
Unit Tests / test (push) Successful in 10s
Deploy Beta / unit-tests (push) Successful in 10s
Deploy Beta / docker (push) Successful in 21s
Deploy Beta / deploy-beta (push) Successful in 40s
Tier-gated RAG + Drive document sources (#42) (#54)
## 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
2026-08-01 14:02:36 -07:00

150 lines
4.6 KiB
Python

from django.urls import path
from rest_framework_simplejwt import views as jwt_views
from .views import (
AcknowledgeTermsOfService,
CustomObtainTokenView,
CustomUserCreate,
CustomUserInvite,
CustomUserSelfDeleteView,
LogoutAndBlacklistRefreshTokenForUserView,
CustomUserGet,
PublicSettingsView,
is_authenticated,
AnnouncmentView,
FeedbackView,
ConversationsView,
ConversationDetailView,
CompanyUsersView,
SetUserPassword,
ResetUserPassword,
ConversationPreferences,
UserPromptAnalytics,
UserConversationAnalytics,
CompanyUsageAnalytics,
AdminAnalytics,
DocumentWorkspaceView,
DocumentUploadView,
DocumentDetailView,
)
from .views_oauth import OAuthCallbackView, OAuthStartView
from .views_drive import (
DriveConnectionListView,
DriveConnectionDetailView,
DriveConnectionResourcesView,
DriveConnectionSyncView,
DriveWebhookGoogleView,
DriveWebhookMicrosoftView,
)
from rest_framework.routers import DefaultRouter
urlpatterns = [
path("token/obtain/", CustomObtainTokenView.as_view(), name="token_create"),
path("token/refresh/", jwt_views.TokenRefreshView.as_view(), name="token_refresh"),
path("user/create/", CustomUserCreate.as_view(), name="create_user"),
path("public/settings/", PublicSettingsView.as_view(), name="public_settings"),
path(
"auth/oauth/<str:provider>/start/",
OAuthStartView.as_view(),
name="oauth_start",
),
path(
"auth/oauth/<str:provider>/callback/",
OAuthCallbackView.as_view(),
name="oauth_callback",
),
path("user/invite/", CustomUserInvite.as_view(), name="invite_user"),
path(
"user/reset_password/", ResetUserPassword.as_view(), name="reset_password"
),
path(
"user/set_password/<slug:slug>/", SetUserPassword.as_view(), name="set_password"
),
path(
"blacklist/",
LogoutAndBlacklistRefreshTokenForUserView.as_view(),
name="blacklist",
),
path("user/get/", CustomUserGet.as_view(), name="get_user"),
path("user/", CustomUserSelfDeleteView.as_view(), name="delete_user"),
path(
"user/acknowledge_tos/",
AcknowledgeTermsOfService.as_view(),
name="acknowledge_tos",
),
path("company_users", CompanyUsersView.as_view(), name="company_users"),
path("user/is_authenticated/", is_authenticated, name="is_authenticated"),
path("announcment/get/", AnnouncmentView.as_view(), name="get_announcments"),
path("conversations", ConversationsView.as_view(), name="conversations"),
path("feedbacks/", FeedbackView.as_view(), name="feedbacks"),
path(
"conversation_details",
ConversationDetailView.as_view(),
name="conversation_details",
),
path(
"conversation_preferences",
ConversationPreferences.as_view(),
name="conversation_preferences",
),
path(
"analytics/user_prompts/",
UserPromptAnalytics.as_view(),
name="analytics_user_prompts",
),
path(
"analytics/user_conversations/",
UserConversationAnalytics.as_view(),
name="analytics_user_conversations",
),
path(
"analytics/company_usage/",
CompanyUsageAnalytics.as_view(),
name="analytics_company_usage",
),
path("analytics/admin/", AdminAnalytics.as_view(), name="analytics_admin"),
# document urls
path(
"document_workspaces/",
DocumentWorkspaceView.as_view(),
name="document_workspaces",
),
path("documents/", DocumentUploadView.as_view(), name="documents"),
path(
"documents_details/<int:document_id>",
DocumentDetailView.as_view(),
name="documents_details",
),
# drive urls (#47-#52)
path(
"drive/connections/",
DriveConnectionListView.as_view(),
name="drive_connections",
),
path(
"drive/connections/<int:connection_id>/",
DriveConnectionDetailView.as_view(),
name="drive_connection_detail",
),
path(
"drive/connections/<int:connection_id>/resources/",
DriveConnectionResourcesView.as_view(),
name="drive_connection_resources",
),
path(
"drive/connections/<int:connection_id>/sync/",
DriveConnectionSyncView.as_view(),
name="drive_connection_sync",
),
path(
"drive/webhooks/google/",
DriveWebhookGoogleView.as_view(),
name="drive_webhook_google",
),
path(
"drive/webhooks/microsoft/",
DriveWebhookMicrosoftView.as_view(),
name="drive_webhook_microsoft",
),
]