Commit f57b24a1 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Move trustee edition to a new page

parent 6429a497
......@@ -52,6 +52,7 @@ let election_setup_credentials_post = post_coservice ~fallback:election_setup_cr
let election_setup_credentials_post_file = post_coservice ~fallback:election_setup_credentials ~post_params:(file "public_creds") ()
let election_setup_credentials_server = post_coservice ~fallback:election_setup ~post_params:unit ()
let election_setup_trustees = service ~path:["setup"; "trustees"] ~get_params:(uuid "uuid") ()
let election_setup_trustee = service ~path:["setup"; "trustee"] ~get_params:(string "token") ()
let election_setup_trustee_post = post_coservice ~fallback:election_setup_trustee ~post_params:(string "public_key") ()
let election_setup_create = post_coservice ~csrf_safe:true ~fallback:election_setup ~post_params:unit ()
......
......@@ -353,6 +353,17 @@ let () = Html5.register ~service:election_setup
| None -> forbidden ()
)
let () = Html5.register ~service:election_setup_trustees
(fun uuid () ->
match_lwt Web_auth_state.get_site_user () with
| Some u ->
let uuid_s = Uuidm.to_string uuid in
lwt se = Ocsipersist.find election_stable uuid_s in
if se.se_owner = u
then T.election_setup_trustees uuid se ()
else forbidden ()
| None -> forbidden ())
let election_setup_mutex = Lwt_mutex.create ()
let handle_setup f cont uuid x =
......@@ -566,7 +577,7 @@ let () =
Ocsipersist.add election_pktokens token uuid_s
) else forbidden ()
) >>
return (preapply election_setup uuid)
return (preapply election_setup_trustees uuid)
| None -> forbidden ()
)
......@@ -589,7 +600,7 @@ let () =
| _ -> return ()
) else forbidden ()
) >>
return (preapply election_setup uuid)
return (preapply election_setup_trustees uuid)
| None -> forbidden ()
)
......
......@@ -390,18 +390,6 @@ let election_setup uuid se () =
]
]
in
let form_trustees_add =
post_form
~service:election_setup_trustee_add
(fun () ->
[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_voters =
div [
h2 [
......@@ -418,31 +406,12 @@ let election_setup uuid se () =
let div_trustees =
div [
h2 [pcdata "Trustees"];
div [pcdata "By default, the election server manages the keys of the election. If you do not wish the server to store any keys, click here."];
div [pcdata "If you do not wish the server to store any keys, you may nominate trustees. In that case, each trustee will create her own secret key. Be careful, once the election is over, you will need the contribution of each trustee to compute the result!"];
br ();
ol
(List.rev_map
(fun (token, pk) ->
li [
a ~service:election_setup_trustee [
pcdata @@ rewrite_prefix @@ Eliom_uri.make_string_uri
~absolute:true
~service:election_setup_trustee
token
] token
];
) se.se_public_keys
);
(if se.se_public_keys <> [] then
div [
pcdata "There is one link per trustee. Send each trustee her link.";
br ();
br ();
]
else pcdata "");
form_trustees_add;
form_trustees_del;
div [
pcdata "By default, the election server manages the keys of the ";
pcdata "election. If you do not wish the server to store any keys, ";
pcdata "click ";
a ~service:election_setup_trustees [pcdata "here"] uuid;
pcdata "."];
]
in
let div_credentials =
......@@ -510,6 +479,52 @@ let election_setup uuid se () =
lwt login_box = site_login_box () in
base ~title ~login_box ~content ()
let election_setup_trustees uuid se () =
let title = "Trustees for election " ^ se.se_questions.t_name in
let form_trustees_add =
post_form
~service:election_setup_trustee_add
(fun () ->
[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_content =
div [
div [pcdata "If you do not wish the server to store any keys, you may nominate trustees. In that case, each trustee will create her own secret key. Be careful, once the election is over, you will need the contribution of each trustee to compute the result!"];
br ();
ol
(List.rev_map
(fun (token, pk) ->
li [
a ~service:election_setup_trustee [
pcdata @@ rewrite_prefix @@ Eliom_uri.make_string_uri
~absolute:true
~service:election_setup_trustee
token
] token
];
) se.se_public_keys
);
(if se.se_public_keys <> [] then
div [
pcdata "There is one link per trustee. Send each trustee her link.";
br ();
br ();
]
else pcdata "");
form_trustees_add;
form_trustees_del;
]
in
let content = [div_content] in
lwt login_box = site_login_box () in
base ~title ~login_box ~content ()
let election_setup_questions uuid se () =
let title = "Questions for election " ^ se.se_questions.t_name in
let form =
......
......@@ -32,6 +32,7 @@ val election_setup : Uuidm.t -> Web_common.setup_election -> unit -> [> `Html ]
val election_setup_voters : Uuidm.t -> Web_common.setup_election -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val election_setup_questions : Uuidm.t -> Web_common.setup_election -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val election_setup_credentials : string -> string -> Web_common.setup_election -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val election_setup_trustees : Uuidm.t -> Web_common.setup_election -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val election_setup_trustee : string -> string -> Web_common.setup_election -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val election_home : (module WEB_ELECTION) -> Web_persist.election_state -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
......
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