Commit 07edeee9 authored by Stephane Glondu's avatar Stephane Glondu Committed by Stéphane Glondu

Add a "Remove all" button to the voter edition page

parent 16e9e8d8
Pipeline #179635 passed with stage
in 32 minutes and 58 seconds
......@@ -1239,6 +1239,12 @@ let election_draft_voters uuid se maxvoters () =
]
) uuid
in
let remove_all_button =
post_form ~service:election_draft_voters_remove_all
(fun () ->
[input ~input_type:`Submit ~value:(s_ "Remove all") string]
) uuid
in
let has_passwords = match se.se_metadata.e_auth_config with
| Some [{auth_system = "password"; _}] -> true
| _ -> false
......@@ -1286,7 +1292,8 @@ let election_draft_voters uuid se maxvoters () =
[th [txt (s_ "Identity")]] @
(if has_passwords then [th [txt (s_ "Password sent?")]] else []) @
(if se.se_public_creds_received then [] else [th [txt (s_ "Remove")]])
) :: voters)
) :: voters);
remove_all_button;
]
in
let back = div [
......
......@@ -875,6 +875,19 @@ let () =
)
)
let () =
Any.register ~service:election_draft_voters_remove_all
(fun uuid () ->
with_draft_election uuid (fun se ->
if se.se_public_creds_received then
forbidden ()
else (
se.se_voters <- [];
redir_preapply election_draft_voters uuid ()
)
)
)
let () =
Any.register ~service:election_draft_voters_passwd
(fun uuid voter ->
......
......@@ -46,6 +46,7 @@ let election_draft_admin_name = create_attached_post ~fallback:election_draft ~p
let election_draft_voters = create ~path:(Path ["draft"; "voters"]) ~meth:(Get (uuid "uuid")) ()
let election_draft_voters_add = create_attached_post ~fallback:election_draft_voters ~post_params:(string "voters") ()
let election_draft_voters_remove = create_attached_post ~fallback:election_draft_voters ~post_params:(string "voter") ()
let election_draft_voters_remove_all = create_attached_post ~fallback:election_draft_voters ~post_params:unit ()
let election_draft_voters_passwd = create_attached_post ~fallback:election_draft_voters ~post_params:(string "voter") ()
let election_draft_trustee_add = create_attached_post ~fallback:election_draft ~post_params:(string "id" ** string "name") ()
let election_draft_trustee_del = create_attached_post ~fallback:election_draft ~post_params:(int "index") ()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment