Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resume data entry (without form state) #364

Merged
merged 6 commits into from
Sep 24, 2024
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
142 changes: 107 additions & 35 deletions backend/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,75 @@
}
},
"/api/polling_stations/{polling_station_id}/data_entries/{entry_number}": {
"get": {
"tags": [
"polling_station"
],
"summary": "Get an in-progress (not finalised) data entry for a polling station",
"operationId": "polling_station_data_entry_get",
"parameters": [
{
"name": "polling_station_id",
"in": "path",
"description": "Polling station database id",
"required": true,
"schema": {
"type": "integer",
"format": "int32",
"minimum": 0
}
},
{
"name": "entry_number",
"in": "path",
"description": "Data entry number (first or second data entry)",
"required": true,
"schema": {
"type": "integer",
"format": "int32",
"minimum": 0
}
}
],
"responses": {
"200": {
"description": "Data entry retrieved successfully",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/GetDataEntryResponse"
}
}
}
},
"404": {
"description": "Not found",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
},
"500": {
"description": "Internal server error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorResponse"
}
}
}
}
}
},
"post": {
"tags": [
"polling_station"
],
"summary": "Save or update a data entry for a polling station",
"operationId": "polling_station_data_entry",
"operationId": "polling_station_data_entry_save",
"parameters": [
{
"name": "polling_station_id",
Expand Down Expand Up @@ -244,7 +307,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DataEntryRequest"
"$ref": "#/components/schemas/SaveDataEntryRequest"
}
}
},
Expand All @@ -256,7 +319,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DataEntryResponse"
"$ref": "#/components/schemas/SaveDataEntryResponse"
}
}
}
Expand Down Expand Up @@ -393,14 +456,7 @@
],
"responses": {
"200": {
"description": "Data entry finalised successfully",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DataEntryResponse"
}
}
}
"description": "Data entry finalised successfully"
},
"404": {
"description": "Not found",
Expand Down Expand Up @@ -522,30 +578,6 @@
}
}
},
"DataEntryRequest": {
"type": "object",
"description": "Request structure for data entry of polling station results",
"required": [
"data"
],
"properties": {
"data": {
"$ref": "#/components/schemas/PollingStationResults"
}
}
},
"DataEntryResponse": {
"type": "object",
"description": "Response structure for data entry of polling station results",
"required": [
"validation_results"
],
"properties": {
"validation_results": {
"$ref": "#/components/schemas/ValidationResults"
}
}
},
"DifferencesCounts": {
"type": "object",
"description": "Differences counts, part of the polling station results.",
Expand Down Expand Up @@ -720,6 +752,22 @@
}
}
},
"GetDataEntryResponse": {
"type": "object",
"description": "Response structure for getting data entry of polling station results",
"required": [
"data",
"validation_results"
],
"properties": {
"data": {
"$ref": "#/components/schemas/PollingStationResults"
},
"validation_results": {
"$ref": "#/components/schemas/ValidationResults"
}
}
},
"PoliticalGroup": {
"type": "object",
"description": "Political group with its candidates",
Expand Down Expand Up @@ -903,6 +951,30 @@
"Mobiel"
]
},
"SaveDataEntryRequest": {
"type": "object",
"description": "Request structure for saving data entry of polling station results",
"required": [
"data"
],
"properties": {
"data": {
"$ref": "#/components/schemas/PollingStationResults"
}
}
},
"SaveDataEntryResponse": {
"type": "object",
"description": "Response structure for saving data entry of polling station results",
"required": [
"validation_results"
],
"properties": {
"validation_results": {
"$ref": "#/components/schemas/ValidationResults"
}
}
},
"ValidationResult": {
"type": "object",
"required": [
Expand Down
14 changes: 10 additions & 4 deletions backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ pub fn router(pool: SqlitePool) -> Result<Router, Box<dyn Error>> {
let polling_station_routes = Router::new()
.route(
"/:polling_station_id/data_entries/:entry_number",
post(polling_station::polling_station_data_entry),
post(polling_station::polling_station_data_entry_save),
)
.route(
"/:polling_station_id/data_entries/:entry_number",
get(polling_station::polling_station_data_entry_get),
)
.route(
"/:polling_station_id/data_entries/:entry_number",
Expand Down Expand Up @@ -86,7 +90,8 @@ pub fn create_openapi() -> utoipa::openapi::OpenApi {
election::election_details,
election::election_status,
election::election_download_results,
polling_station::polling_station_data_entry,
polling_station::polling_station_data_entry_save,
polling_station::polling_station_data_entry_get,
polling_station::polling_station_data_entry_delete,
polling_station::polling_station_data_entry_finalise,
),
Expand All @@ -105,8 +110,9 @@ pub fn create_openapi() -> utoipa::openapi::OpenApi {
election::ElectionDetailsResponse,
election::ElectionStatusResponse,
polling_station::CandidateVotes,
polling_station::DataEntryRequest,
polling_station::DataEntryResponse,
polling_station::SaveDataEntryRequest,
polling_station::SaveDataEntryResponse,
polling_station::GetDataEntryResponse,
polling_station::DifferencesCounts,
polling_station::PoliticalGroupVotes,
polling_station::PollingStationResults,
Expand Down
Loading