Skip to content

Feat/add insight generation route#85

Merged
AAdewunmi merged 7 commits into
mainfrom
feat/add-insight-generation-route
May 18, 2026
Merged

Feat/add insight generation route#85
AAdewunmi merged 7 commits into
mainfrom
feat/add-insight-generation-route

Conversation

@AAdewunmi

Copy link
Copy Markdown
Owner

Summary

Adds the authenticated insight generation route for study sessions.

Changes

  • Added apps.insights.urls with the insights:generate route.
  • Mounted insight routes under /insights/ in config/urls.py.
  • Added GenerateInsightView for generating or reusing a session insight.
  • Added permission tests for owner access, cross-user access, anonymous access, and POST-only behaviour.

Behaviour

  • Route: /insights/sessions/<session_id>/generate/
  • Named URL: insights:generate
  • Only authenticated users can access it.
  • Only the session owner can generate an insight.
  • The route accepts POST only.
  • GET returns 405.
  • Cross-user access returns 404.
  • Anonymous access redirects to login.
  • Successful generation redirects back to the session detail page.

Why

This gives the UI a safe route for triggering insight generation while keeping permission checks and workflow logic behind the view/service boundary.

Validation

  • python -m black . --check
  • python -m ruff check .
  • python -m pytest apps/insights/tests/test_insight_permissions.py -q
  • python manage.py check --settings=config.settings.test

Result

Focused insight permission tests pass: 5 passed.

Notes

The route delegates generation to the insight service; the view does not import or run NLP helpers directly.

fix(views): add missing newline at end of file in views.py
@codecov

codecov Bot commented May 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@AAdewunmi AAdewunmi merged commit 5280166 into main May 18, 2026
2 checks passed
@AAdewunmi AAdewunmi deleted the feat/add-insight-generation-route branch May 18, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sprint-3-ai-views-permissions Add insight generation route

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

Add insight generation route

1 participant