Skip to content

Commit f15b200

Browse files
authored
Resume data entry (without form state) (#364)
1 parent 80a678b commit f15b200

File tree

18 files changed

+591
-271
lines changed

18 files changed

+591
-271
lines changed

backend/openapi.json

Lines changed: 107 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,75 @@
210210
}
211211
},
212212
"/api/polling_stations/{polling_station_id}/data_entries/{entry_number}": {
213+
"get": {
214+
"tags": [
215+
"polling_station"
216+
],
217+
"summary": "Get an in-progress (not finalised) data entry for a polling station",
218+
"operationId": "polling_station_data_entry_get",
219+
"parameters": [
220+
{
221+
"name": "polling_station_id",
222+
"in": "path",
223+
"description": "Polling station database id",
224+
"required": true,
225+
"schema": {
226+
"type": "integer",
227+
"format": "int32",
228+
"minimum": 0
229+
}
230+
},
231+
{
232+
"name": "entry_number",
233+
"in": "path",
234+
"description": "Data entry number (first or second data entry)",
235+
"required": true,
236+
"schema": {
237+
"type": "integer",
238+
"format": "int32",
239+
"minimum": 0
240+
}
241+
}
242+
],
243+
"responses": {
244+
"200": {
245+
"description": "Data entry retrieved successfully",
246+
"content": {
247+
"application/json": {
248+
"schema": {
249+
"$ref": "#/components/schemas/GetDataEntryResponse"
250+
}
251+
}
252+
}
253+
},
254+
"404": {
255+
"description": "Not found",
256+
"content": {
257+
"application/json": {
258+
"schema": {
259+
"$ref": "#/components/schemas/ErrorResponse"
260+
}
261+
}
262+
}
263+
},
264+
"500": {
265+
"description": "Internal server error",
266+
"content": {
267+
"application/json": {
268+
"schema": {
269+
"$ref": "#/components/schemas/ErrorResponse"
270+
}
271+
}
272+
}
273+
}
274+
}
275+
},
213276
"post": {
214277
"tags": [
215278
"polling_station"
216279
],
217280
"summary": "Save or update a data entry for a polling station",
218-
"operationId": "polling_station_data_entry",
281+
"operationId": "polling_station_data_entry_save",
219282
"parameters": [
220283
{
221284
"name": "polling_station_id",
@@ -244,7 +307,7 @@
244307
"content": {
245308
"application/json": {
246309
"schema": {
247-
"$ref": "#/components/schemas/DataEntryRequest"
310+
"$ref": "#/components/schemas/SaveDataEntryRequest"
248311
}
249312
}
250313
},
@@ -256,7 +319,7 @@
256319
"content": {
257320
"application/json": {
258321
"schema": {
259-
"$ref": "#/components/schemas/DataEntryResponse"
322+
"$ref": "#/components/schemas/SaveDataEntryResponse"
260323
}
261324
}
262325
}
@@ -393,14 +456,7 @@
393456
],
394457
"responses": {
395458
"200": {
396-
"description": "Data entry finalised successfully",
397-
"content": {
398-
"application/json": {
399-
"schema": {
400-
"$ref": "#/components/schemas/DataEntryResponse"
401-
}
402-
}
403-
}
459+
"description": "Data entry finalised successfully"
404460
},
405461
"404": {
406462
"description": "Not found",
@@ -522,30 +578,6 @@
522578
}
523579
}
524580
},
525-
"DataEntryRequest": {
526-
"type": "object",
527-
"description": "Request structure for data entry of polling station results",
528-
"required": [
529-
"data"
530-
],
531-
"properties": {
532-
"data": {
533-
"$ref": "#/components/schemas/PollingStationResults"
534-
}
535-
}
536-
},
537-
"DataEntryResponse": {
538-
"type": "object",
539-
"description": "Response structure for data entry of polling station results",
540-
"required": [
541-
"validation_results"
542-
],
543-
"properties": {
544-
"validation_results": {
545-
"$ref": "#/components/schemas/ValidationResults"
546-
}
547-
}
548-
},
549581
"DifferencesCounts": {
550582
"type": "object",
551583
"description": "Differences counts, part of the polling station results.",
@@ -720,6 +752,22 @@
720752
}
721753
}
722754
},
755+
"GetDataEntryResponse": {
756+
"type": "object",
757+
"description": "Response structure for getting data entry of polling station results",
758+
"required": [
759+
"data",
760+
"validation_results"
761+
],
762+
"properties": {
763+
"data": {
764+
"$ref": "#/components/schemas/PollingStationResults"
765+
},
766+
"validation_results": {
767+
"$ref": "#/components/schemas/ValidationResults"
768+
}
769+
}
770+
},
723771
"PoliticalGroup": {
724772
"type": "object",
725773
"description": "Political group with its candidates",
@@ -903,6 +951,30 @@
903951
"Mobiel"
904952
]
905953
},
954+
"SaveDataEntryRequest": {
955+
"type": "object",
956+
"description": "Request structure for saving data entry of polling station results",
957+
"required": [
958+
"data"
959+
],
960+
"properties": {
961+
"data": {
962+
"$ref": "#/components/schemas/PollingStationResults"
963+
}
964+
}
965+
},
966+
"SaveDataEntryResponse": {
967+
"type": "object",
968+
"description": "Response structure for saving data entry of polling station results",
969+
"required": [
970+
"validation_results"
971+
],
972+
"properties": {
973+
"validation_results": {
974+
"$ref": "#/components/schemas/ValidationResults"
975+
}
976+
}
977+
},
906978
"ValidationResult": {
907979
"type": "object",
908980
"required": [

backend/src/lib.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ pub fn router(pool: SqlitePool) -> Result<Router, Box<dyn Error>> {
3333
let polling_station_routes = Router::new()
3434
.route(
3535
"/:polling_station_id/data_entries/:entry_number",
36-
post(polling_station::polling_station_data_entry),
36+
post(polling_station::polling_station_data_entry_save),
37+
)
38+
.route(
39+
"/:polling_station_id/data_entries/:entry_number",
40+
get(polling_station::polling_station_data_entry_get),
3741
)
3842
.route(
3943
"/:polling_station_id/data_entries/:entry_number",
@@ -86,7 +90,8 @@ pub fn create_openapi() -> utoipa::openapi::OpenApi {
8690
election::election_details,
8791
election::election_status,
8892
election::election_download_results,
89-
polling_station::polling_station_data_entry,
93+
polling_station::polling_station_data_entry_save,
94+
polling_station::polling_station_data_entry_get,
9095
polling_station::polling_station_data_entry_delete,
9196
polling_station::polling_station_data_entry_finalise,
9297
),
@@ -105,8 +110,9 @@ pub fn create_openapi() -> utoipa::openapi::OpenApi {
105110
election::ElectionDetailsResponse,
106111
election::ElectionStatusResponse,
107112
polling_station::CandidateVotes,
108-
polling_station::DataEntryRequest,
109-
polling_station::DataEntryResponse,
113+
polling_station::SaveDataEntryRequest,
114+
polling_station::SaveDataEntryResponse,
115+
polling_station::GetDataEntryResponse,
110116
polling_station::DifferencesCounts,
111117
polling_station::PoliticalGroupVotes,
112118
polling_station::PollingStationResults,

0 commit comments

Comments
 (0)