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

Add some audit data

parent 49b40d20
......@@ -110,7 +110,9 @@ type question = {
}
type election_extradata = {
xelection : Helios_services.election_data;
election : Z.t Helios_datatypes_t.election;
(* FIXME: datatypes should be revisited, election is xelection.election! *)
election_admin : Helios_services.user;
election_trustees : string list;
election_state : [`Finished of question list | `Stopped | `Started];
......@@ -232,6 +234,30 @@ let dummy_login ~service =
~content:[div [form]]
let election_view ~election =
let audit_info = [
(* FIXME: unsafe_data *)
unsafe_data "<a href=\"#\" onclick=\"$('#auditbody').slideToggle(250);\">Audit Info</a>";
div ~a:[
a_id "auditbody";
a_style "display:none;";
] [
br ();
pcdata "Election URL:";
pre ~a:[a_style "font-size: 1.2em;"] [
let service = Eliom_service.preapply Helios_services.election_raw election.election.e_uuid in
a ~service [ pcdata (make_string_uri ~absolute:true ~service ()) ] ()
];
br ();
pcdata "Election Fingerprint:";
pre ~a:[a_style "font-size: 1.3em; font-weight: bold;"] [
pcdata election.xelection.Helios_services.fingerprint;
];
(* FIXME: Ballot Tracking Center *)
(* FIXME: Audited Ballots *)
(* FIXME: result *)
(* FIXME: voting booth *)
]
] in
let content = [
div ~a:[a_style "float: left; margin-right: 50px;"] [pcdata "FIXME"];
br ();
......@@ -297,12 +323,32 @@ let election_view ~election =
)
| `Stopped ->
[
(* FIXME *)
span ~a:[a_class ["highlight-box"; "round"]] [
pcdata "Election closed. Tally will be computed soon.";
];
br ();
]
| `Started ->
[
(* FIXME *)
span ~a:[
a_class ["highlight-box"; "round"];
a_style "font-size: 1.6em; margin-right: 10px;";
a_id "votelink";
] [
a ~service:(Eliom_service.preapply Helios_services.election_vote election.election.e_uuid) [
pcdata "Vote in this election";
] ()
];
br ();
(* if election.voting_extended_until ... *)
pcdata "This election ends at the administrator's discretion.";
br ();
]
)
in
) @ [
(* FIXME: privacity, eligibility, etc. *)
div ~a:[
a_style "background: lightyellow; padding:5px; padding-left: 10px; margin-top: 15px; border: 1px solid #aaa; width: 720px;";
a_class ["round"];
] audit_info
] in
base ~title:election.election.e_name ~header:[] ~content
......@@ -53,7 +53,7 @@ let elections = List.map load_election_data raw_elections
let get_raw_election_by_uuid x =
let open Helios_services in
(List.find (fun e -> Uuidm.equal e.election.e_uuid x) elections).election
List.find (fun e -> Uuidm.equal e.election.e_uuid x) elections
let test_uuid =
match Uuidm.of_string "94c1a03e-1c48-11e2-8866-3cd92b7981b8" with
......@@ -97,7 +97,7 @@ let format_election e =
) (r.result : int array array) |> (fun x -> `Finished (Array.to_list x))
| None -> `Started
in
{ election; election_admin; election_trustees; election_state }
{ election; xelection=e; election_admin; election_trustees; election_state }
let elections = List.map format_election elections
......@@ -161,6 +161,15 @@ let () = Eliom_registration.Redirection.register
Eliom_state.discard ~scope:Eliom_common.default_session_scope () >>
return Helios_services.home)
let () = Eliom_registration.String.register
~service:Helios_services.election_raw
(fun uuid () ->
try_lwt
lwt election = get_election_by_uuid uuid in
return (election.Helios_templates.xelection.Helios_services.raw, "application/json")
with Not_found ->
raise_lwt Eliom_common.Eliom_404)
let () = Eliom_registration.Html5.register
~service:Helios_services.election_view
(fun uuid () ->
......@@ -170,6 +179,15 @@ let () = Eliom_registration.Html5.register
with Not_found ->
raise_lwt Eliom_common.Eliom_404)
let () = Eliom_registration.Html5.register
~service:Helios_services.election_vote
(fun uuid () ->
try_lwt
lwt election = get_election_by_uuid uuid in
Helios_templates.not_implemented "Vote"
with Not_found ->
raise_lwt Eliom_common.Eliom_404)
let () = Eliom_registration.Html5.register
~service:Helios_services.election_questions
(fun uuid () ->
......
......@@ -66,11 +66,21 @@ let uuid = Eliom_parameter.user_type
Uuidm.to_string
"uuid"
let election_raw = service
~path:["elections"; ""]
~get_params:uuid
()
let election_view = service
~path:["elections"; "view"]
~get_params:uuid
()
let election_vote = service
~path:["elections"; "vote"]
~get_params:uuid
()
let election_questions = service
~path:["elections"; "questions"]
~get_params:uuid
......
Supports Markdown
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