Commit 1b86df92 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Add election_missing_voters

parent 65338624
...@@ -76,6 +76,8 @@ let election_cast_confirm = post_coservice ~csrf_safe:true ~fallback:election_ca ...@@ -76,6 +76,8 @@ let election_cast_confirm = post_coservice ~csrf_safe:true ~fallback:election_ca
let election_pretty_ballots = service ~path:["elections"] ~get_params:(suffix_prod (uuid "uuid" ** suffix_const "ballots") (int "start")) () let election_pretty_ballots = service ~path:["elections"] ~get_params:(suffix_prod (uuid "uuid" ** suffix_const "ballots") (int "start")) ()
let election_pretty_ballot = service ~path:["elections"] ~get_params:(suffix_prod (uuid "uuid" ** suffix_const "ballot") (string "hash")) () let election_pretty_ballot = service ~path:["elections"] ~get_params:(suffix_prod (uuid "uuid" ** suffix_const "ballot") (string "hash")) ()
let election_missing_voters = service ~path:["elections"] ~get_params:(suffix (uuid "uuid" ** suffix_const "missing")) ()
let election_compute_encrypted_tally = post_coservice ~csrf_safe:true ~fallback:election_admin ~post_params:unit () let election_compute_encrypted_tally = post_coservice ~csrf_safe:true ~fallback:election_admin ~post_params:unit ()
let election_tally_trustees = service ~path:["elections"] ~get_params:(suffix (uuid "uuid" ** suffix_const "trustees" ** int "trustee_id")) () let election_tally_trustees = service ~path:["elections"] ~get_params:(suffix (uuid "uuid" ** suffix_const "trustees" ** int "trustee_id")) ()
let election_tally_trustees_post = post_service ~fallback:election_tally_trustees ~post_params:(string "partial_decryption") () let election_tally_trustees_post = post_service ~fallback:election_tally_trustees ~post_params:(string "partial_decryption") ()
......
...@@ -1198,6 +1198,41 @@ let () = ...@@ -1198,6 +1198,41 @@ let () =
String.send (b, "application/json") >>= String.send (b, "application/json") >>=
(fun x -> return @@ cast_unknown_content_kind x)) (fun x -> return @@ cast_unknown_content_kind x))
let () =
let rex = Pcre.regexp "\".*\" \".*:(.*)\"" in
Any.register
~service:election_missing_voters
(fun (uuid, ()) () ->
let uuid_s = Uuidm.to_string uuid in
let w = SMap.find uuid_s !election_table in
let module W = (val w : WEB_ELECTION) in
lwt () =
match_lwt Web_auth_state.get_site_user () with
| Some u when W.metadata.e_owner = Some u -> return ()
| _ -> forbidden ()
in
let voters = Lwt_io.lines_of_file
(W.dir / string_of_election_file ESVoters)
in
let module S = Set.Make (PString) in
lwt voters = Lwt_stream.fold (fun v accu ->
S.add v accu
) voters S.empty in
let records = Lwt_io.lines_of_file
(W.dir / string_of_election_file ESRecords)
in
lwt voters = Lwt_stream.fold (fun r accu ->
let s = Pcre.exec ~rex r in
let v = Pcre.get_substring s 1 in
S.remove v accu
) records voters in
let buf = Buffer.create 128 in
S.iter (fun v ->
Buffer.add_string buf v;
Buffer.add_char buf '\n'
) voters;
String.send (Buffer.contents buf, "text/plain"))
let () = let () =
Any.register Any.register
~service:election_tally_trustees ~service:election_tally_trustees
......
...@@ -981,6 +981,9 @@ let election_admin w ~is_featured state () = ...@@ -981,6 +981,9 @@ let election_admin w ~is_featured state () =
div [ div [
a ~service:election_dir [pcdata "Voting records"] (uuid, ESRecords); a ~service:election_dir [pcdata "Voting records"] (uuid, ESRecords);
]; ];
div [
a ~service:election_missing_voters [pcdata "Missing voters"] (uuid, ());
];
div [state_div]; div [state_div];
] in ] in
lwt login_box = site_login_box () in lwt login_box = site_login_box () in
......
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