Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 168 additions & 0 deletions openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1626,6 +1626,174 @@ paths:
"422":
$ref: '#/components/responses/UnprocessableEntity'

/projects/bulk_status_change:
post:
tags: [Projects]
summary: Close or reopen many Projects at once
description: |
Closes or reopens several Projects in one request. This is **Close projects** and **Reopen
projects** for the projects ticked in the Rows view of the My Projects page. Each Project is
closed or reopened the same way as from its own settings menu, so its team is told.

A closed Project can't get new updates (Stories) or Contacts, and its existing updates can't
be edited, until it is reopened. Closed Projects are listed on the organisation's Closed
Projects page.

**Who may do it.** An Organisation Admin of the Project's organisation, or a Project Manager
(Project Editor) of the Project. If any listed Project is one the user may not change, nothing
is changed and the reply is `403` naming those Projects.

**Already closed or open.** `close` changes only the listed Projects that are open, and
`reopen` only those that are closed. The others are left as they are.

**Signup Pages.** Closing a Project that an active Signup Page uses would break that Signup
Page, so `close` needs `signup_pages`:
- `deactivate`: deactivate those Signup Pages, then close the Project. A Project whose Signup
Page the user may not deactivate is left open.
- `skip`: leave those Projects open and close the rest.

**In the background.** The reply is `202` straight away. The user is emailed when it has
finished: how many Projects were closed, with a link to the Closed Projects page, or which
Projects were reopened. Check the result with `GET /projects/{id}` (`is_closed`).
operationId: bulkChangeProjectStatus
security: [{tokenAuth: []}]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [status_action, project_ids]
properties:
status_action:
type: string
enum: [close, reopen]
description: Whether to close or reopen the Projects
project_ids:
type: array
minItems: 1
maxItems: 200
items: { type: integer }
description: The Projects to change, at most 200
signup_pages:
type: string
enum: [deactivate, skip]
description: Required with `close`. What to do with Projects that an active Signup Page uses.
example:
status_action: close
project_ids: [619, 620]
signup_pages: skip
responses:
"202":
description: The Projects are being closed or reopened in the background
content:
application/json:
schema:
type: object
properties:
status_action:
type: string
enum: [close, reopen]
project_ids:
type: array
items: { type: integer }
message:
type: string
example:
status_action: close
project_ids: [619, 620]
message: The projects are being changed in the background. You will be emailed when this is done.
"401":
$ref: '#/components/responses/Unauthorized'
"403":
description: The user may not close or reopen one of the listed Projects. Nothing is changed.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: "You don't have permission to close or reopen project 619."
"404":
$ref: '#/components/responses/NotFound'
"422":
$ref: '#/components/responses/UnprocessableEntity'

/projects/bulk_deletion:
post:
tags: [Projects]
summary: Delete many closed Projects at once
description: |
Permanently deletes several closed Projects in one request. This is **Delete projects** for
the projects ticked in the Rows view of the My Projects page. Each Project is deleted the
same way as with the Delete project button on the organisation's Closed Projects page: its
team is emailed, it is listed under Deleted Projects there, and its automations are turned
off. **Deletion is permanent and cannot be undone**, so confirm the list with the user first.

**Only closed Projects are deleted.** Open Projects in the list are kept and returned in
`kept_project_ids`; close them first (`POST /projects/bulk_status_change`) to delete them. A
list with no closed Project is refused with `422`.

**Who may do it.** An Organisation Admin of the Project's organisation, or a Project Manager
(Project Editor) of the Project. If any listed Project is one the user may not delete,
nothing is deleted and the reply is `403` naming those Projects.

**In the background.** The reply is `202` straight away and the Projects are deleted soon
after. `GET /projects/{id}` returns `404` for a Project once it has been deleted.
operationId: bulkDeleteProjects
security: [{tokenAuth: []}]
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [project_ids]
properties:
project_ids:
type: array
minItems: 1
maxItems: 200
items: { type: integer }
description: The Projects to delete, at most 200. Only the closed ones are deleted.
example:
project_ids: [619, 620]
responses:
"202":
description: The closed Projects are being deleted in the background
content:
application/json:
schema:
type: object
properties:
project_ids:
type: array
items: { type: integer }
description: The closed Projects that will be deleted
kept_project_ids:
type: array
items: { type: integer }
description: The open Projects in the list, which are kept
message:
type: string
example:
project_ids: [619]
kept_project_ids: [620]
message: The closed projects are being deleted in the background.
"401":
$ref: '#/components/responses/Unauthorized'
"403":
description: The user may not delete one of the listed Projects. Nothing is deleted.
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
example:
error: "You don't have permission to delete project 619."
"404":
$ref: '#/components/responses/NotFound'
"422":
$ref: '#/components/responses/UnprocessableEntity'

/beneficiaries:
get:
tags: [Beneficiaries]
Expand Down
20 changes: 20 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1298,6 +1298,26 @@ function buildDocsPage() {
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
{ code: "422", cls: "response-4xx", desc: "Validation failed" }
], "Grant one or more users a role on a Project. A user can hold Editor, Reporter, and Observer simultaneously. Pass user IDs in <code>role_data[].editor_ids</code>, <code>reporter_ids</code>, or <code>observer_ids</code>.")}
${endpointCard("POST", "/projects/bulk_status_change", "Close or reopen many Projects at once", true, [
{ name: "status_action", type: "string", required: true, desc: "<code>close</code> or <code>reopen</code>" },
{ name: "project_ids", type: "integer[]", required: true, desc: "The Projects to change, at most 200" },
{ name: "signup_pages", type: "string", required: false, desc: "Required with <code>close</code>. <code>deactivate</code>: deactivate the active Signup Pages that use a Project, then close it. <code>skip</code>: leave those Projects open and close the rest" }
], [
{ code: "202", cls: "response-2xx", desc: "Queued: <code>status_action</code>, <code>project_ids</code> and <code>message</code>. The user is emailed when it has finished" },
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
{ code: "403", cls: "response-4xx", desc: "You may not close or reopen one of the listed Projects; nothing changes" },
{ code: "404", cls: "response-4xx", desc: "One of the listed Projects doesn't exist" },
{ code: "422", cls: "response-4xx", desc: "Unknown <code>status_action</code>, missing <code>signup_pages</code> for <code>close</code>, or no Projects (or more than 200)" }
], "What <b>Close projects</b> and <b>Reopen projects</b> do for the projects ticked in the Rows view of My Projects. Organisation Admins and Project Managers (Project Editors) can use it. <code>close</code> changes only the open Projects listed and <code>reopen</code> only the closed ones; each is closed or reopened as from its own settings menu, so its team is told. Check the result with <code>GET /projects/{id}</code> (<code>is_closed</code>).")}
${endpointCard("POST", "/projects/bulk_deletion", "Delete many closed Projects at once", true, [
{ name: "project_ids", type: "integer[]", required: true, desc: "The Projects to delete, at most 200. Only the closed ones are deleted" }
], [
{ code: "202", cls: "response-2xx", desc: "Queued: <code>project_ids</code> (closed, to be deleted), <code>kept_project_ids</code> (open, kept) and <code>message</code>" },
{ code: "401", cls: "response-4xx", desc: "Not authenticated" },
{ code: "403", cls: "response-4xx", desc: "You may not delete one of the listed Projects; nothing is deleted" },
{ code: "404", cls: "response-4xx", desc: "One of the listed Projects doesn't exist" },
{ code: "422", cls: "response-4xx", desc: "None of the Projects is closed, or no Projects (or more than 200)" }
], "What <b>Delete projects</b> does for the projects ticked in the Rows view of My Projects. <b>Deletion is permanent.</b> Only closed Projects are deleted; close others first with <code>POST /projects/bulk_status_change</code>. Organisation Admins and Project Managers (Project Editors) can use it. Each Project is deleted as with the Delete project button on the Closed Projects page, so its team is emailed and it is listed under Deleted Projects. Runs in the background; <code>GET /projects/{id}</code> returns 404 once a Project has gone.")}
${endpointCard("GET", "/project_results", "Get Results Canvas figures for Projects", true, [
{ name: "project_ids", type: "integer[]", required: false, desc: "Projects to include, as <code>project_ids[]=619</code> or a JSON array string. Defaults to every Project you can view" },
{ name: "start_date", type: "string", required: false, desc: "First Story date to include, YYYY-MM-DD. Omit both dates for all time" },
Expand Down
Loading