Skip to content

Add v1 dashboard create endpoint via shared creation flow#653

Open
AnthonyMockler wants to merge 2 commits into
unicef-drp:mainfrom
AnthonyMockler:codex/dashboard-create-api-refactor
Open

Add v1 dashboard create endpoint via shared creation flow#653
AnthonyMockler wants to merge 2 commits into
unicef-drp:mainfrom
AnthonyMockler:codex/dashboard-create-api-refactor

Conversation

@AnthonyMockler
Copy link
Copy Markdown

@AnthonyMockler AnthonyMockler commented Apr 27, 2026

Is your feature request related to a problem? Please describe.
Yes. API v1 could list and retrieve dashboards, but could not create them, which blocked API-first workflows and forced UI-only creation.

Describe the solution you'd like
This PR adds POST /api/v1/dashboards/ in API v1 by reusing the existing dashboard creation flow rather than introducing a second create path.

Implemented behavior:

  • Create support in v1 dashboard endpoint (django_project/geosight/data/api/v1/dashboard.py).
  • Shared create service reused by both UI and API (django_project/geosight/data/services/dashboard_create.py, wired from django_project/frontend/views/admin/dashboard/create.py).
  • Supports both form/json-style payload parsing and multipart (including optional icon upload).
  • Permission behavior aligned with existing creator+ expectations; anonymous/non-creator creation denied.
  • Transaction-safe create flow (rollback on relation-save failures).
  • API docs/schema updated to reflect actual request/response contract for create.

Describe alternatives you've considered

  • Keep creation UI-only: rejected because it does not enable API automation.
  • Build separate API-only create flow: rejected to avoid drift from existing UI business logic.
  • Redesign payload model first: rejected to keep change surface small and ship endpoint now.

Additional context
Design/implementation alignment used from our plan:

  • Thin API layer; business logic in shared service.
  • Reuse over rewrite.
  • Contract/documentation updates in the same branch as behavior changes.
  • Real integration verification on a running local GeoSight instance.

Scope delivered in this PR:

  • Add create support to v1 dashboards endpoint.
  • Reuse dashboard creation flow used by UI.
  • Add targeted tests for success, permission denial, validation, multipart, and rollback.
  • Update create endpoint docs/schema.

Out of scope (unchanged):

  • Update/PATCH semantics.
  • Full payload redesign.
  • Unrelated dashboard permission/feature changes.
  • Generic map viewer save-as-URL workflow.

Implemented acceptance checklist:

  • POST /api/v1/dashboards/ is available in API v1.
  • Endpoint requires authentication and creator+ role.
  • Anonymous/public and non-creator requests are denied.
  • JSON and multipart create flows both work.
  • Failed relation save does not persist partial dashboard data.
  • API docs reflect real request and response behavior.
  • Tests cover happy path and failure cases.

Verification executed for this PR:

  • docker exec geosight_branch_dev python manage.py test geosight.data.tests.api.v1.dashboard.DashboardPermissionTest --keepdb --noinputOK (14 tests).
  • cd playwright/ci-test && npx playwright test tests/creator/project_creation/api_v1_create.ts tests/contributor/project_creation/api_v1_create_denied.ts --project=creator-chromium --project=contributor-chromiumPASS (7) FAIL (0).
  • Existing admin project creation suite was also run as a local regression signal and failed in this local seed baseline (tracked in issue comment), not in the targeted endpoint suites.

Closes #652

@AnthonyMockler AnthonyMockler force-pushed the codex/dashboard-create-api-refactor branch from 6f91742 to 83ae6b4 Compare April 27, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Add create endpoint for dashboards in API v1

1 participant