Commit 9d5e04b0 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Setup mode: add "Delete (trustee)" button

parent 2219e9c7
......@@ -45,6 +45,7 @@ let election_setup_metadata = post_coservice ~fallback:election_setup ~post_para
let election_setup_questions = service ~path:["setup"; "questions"] ~get_params:(uuid "uuid") ()
let election_setup_questions_post = post_coservice ~fallback:election_setup_questions ~post_params:(string "questions") ()
let election_setup_trustee_add = post_coservice ~fallback:election_setup ~post_params:unit ()
let election_setup_trustee_del = post_coservice ~fallback:election_setup ~post_params:unit ()
let election_setup_credentials = service ~path:["setup"; "credentials"] ~get_params:(string "token") ()
let election_setup_credentials_download = service ~path:["setup"; "public_creds.txt"] ~get_params:(string "token") ()
let election_setup_credentials_post = post_coservice ~fallback:election_setup_credentials ~post_params:(string "public_creds") ()
......
......@@ -457,6 +457,29 @@ let () =
| None -> forbidden ()
)
let () =
Redirection.register
~service:election_setup_trustee_del
(fun uuid () ->
match_lwt Web_site_auth.get_user () with
| Some u ->
let uuid_s = Uuidm.to_string uuid in
Lwt_mutex.with_lock election_setup_mutex (fun () ->
lwt se = Ocsipersist.find election_stable uuid_s in
if se.se_owner = u
then (
match se.se_public_keys with
| (token, _) :: xs ->
se.se_public_keys <- xs;
Ocsipersist.add election_stable uuid_s se >>
Ocsipersist.remove election_pktokens token
| _ -> return ()
) else forbidden ()
) >>
return (preapply election_setup uuid)
| None -> forbidden ()
)
let () =
Html5.register
~service:election_setup_credentials
......
......@@ -292,20 +292,31 @@ let election_setup uuid se auth () =
[pcdata "Manage questions"]
uuid]
in
let form_trustees =
let form_trustees_add =
post_form
~service:election_setup_trustee_add
(fun () ->
[div
[h2 [pcdata "Trustees"];
ol
(List.rev_map
(fun (token, pk) ->
li
[a ~service:election_setup_trustee [pcdata token] token]
) se.se_public_keys
);
string_input ~input_type:`Submit ~value:"Add" ()]]) uuid
[string_input ~input_type:`Submit ~value:"Add" ()]) uuid
in
let form_trustees_del =
post_form
~service:election_setup_trustee_del
(fun () ->
[string_input ~input_type:`Submit ~value:"Delete" ()]) uuid
in
let div_trustees =
div [
h2 [pcdata "Trustees"];
ol
(List.rev_map
(fun (token, pk) ->
li
[a ~service:election_setup_trustee [pcdata token] token]
) se.se_public_keys
);
form_trustees_add;
form_trustees_del;
]
in
let div_credentials =
div
......@@ -325,7 +336,7 @@ let election_setup uuid se auth () =
) uuid
in
let content = [
form_trustees;
div_trustees;
div_credentials;
form_group;
form_metadata;
......
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