Commit 16b29f94 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Replace "election_index" with "election_dir (u, ESIndex)"

parent 05bc228a
......@@ -240,11 +240,6 @@ module S = struct
~get_params:unit
()
let election_index = service
~path:["election"; ""]
~get_params:uuid
()
let election_vote = service
~path:["election"; "vote"]
~get_params:uuid
......@@ -299,7 +294,7 @@ module S = struct
let to_service = function
| Home -> home
| Cast u -> Eliom_service.preapply election_cast u
| Election u -> Eliom_service.preapply election_index u
| Election u -> Eliom_service.preapply election_dir (u, ESIndex)
open Lwt
......@@ -332,7 +327,7 @@ let () =
(fun () () ->
Eliom_reference.unset Services.ballot >>
Eliom_reference.unset Services.saved_service >>
return (Eliom_service.preapply S.election_index uuid)
return (Eliom_service.preapply S.election_dir (uuid, Services.ESIndex))
)
let can_read x u = x.Web_election.can_read
......@@ -401,6 +396,11 @@ let f_records uuid election user () =
return (s, "text/plain")
| _ -> forbidden ()
let f_index uuid election user () =
Eliom_reference.unset Services.ballot >>
Eliom_reference.set Services.saved_service (Services.Election uuid) >>
T.election_view ~election ~user
let handle_pseudo_file u f =
let open Eliom_registration in
let open Services in
......@@ -413,6 +413,7 @@ let handle_pseudo_file u f =
(fun x -> return (cast_unknown_content_kind x))
in
match f with
| ESIndex -> if_eligible can_read f_index u () >>= Html5.send
| ESRaw -> file f_raw
| ESKeys -> file f_keys
| ESCreds -> stream f_creds
......@@ -444,16 +445,6 @@ let () = Eliom_registration.String.register
(fun x -> return (x, "application/json"))
)
let () = Eliom_registration.Html5.register
~service:S.election_index
(if_eligible can_read
(fun uuid election user () ->
Eliom_reference.unset Services.ballot >>
Eliom_reference.set Services.saved_service (Services.Election uuid) >>
T.election_view ~election ~user
)
)
let () = Eliom_registration.Redirection.register
~service:S.election_vote
(if_eligible can_read
......
......@@ -36,6 +36,7 @@ let uuid = Eliom_parameter.user_type
"uuid"
type election_file =
| ESIndex
| ESRaw
| ESKeys
| ESCreds
......@@ -43,6 +44,7 @@ type election_file =
| ESRecords
let election_file_of_string = function
| "" -> ESIndex
| "election.json" -> ESRaw
| "public_keys.jsons" -> ESKeys
| "public_creds.txt" -> ESCreds
......@@ -51,6 +53,7 @@ let election_file_of_string = function
| x -> invalid_arg ("election_dir_item: " ^ x)
let string_of_election_file = function
| ESIndex -> ""
| ESRaw -> "election.json"
| ESKeys -> "public_keys.jsons"
| ESCreds -> "public_creds.txt"
......
......@@ -89,7 +89,7 @@ let base ~title ~content =
let format_one_featured_election e =
li [
h3 [
a ~service:(Services.preapply_uuid S.election_index e)
a ~service:(S.election_file e Services.ESIndex)
[pcdata e.e_name] ();
];
p [pcdata e.e_description];
......@@ -330,7 +330,7 @@ let ballot_received ~election ~confirm ~user ~can_vote =
];
user_div;
p [
a ~service:(Services.preapply_uuid S.election_index params) [
a ~service:(S.election_file params Services.ESIndex) [
pcdata "Go back to election"
] ();
pcdata ".";
......@@ -352,7 +352,7 @@ let do_cast_ballot ~election ~result =
);
];
p [
a ~service:(Services.preapply_uuid S.election_index params) [
a ~service:(S.election_file params Services.ESIndex) [
pcdata "Go back to election"
] ();
pcdata ".";
......
......@@ -41,16 +41,6 @@ module type MAIN_SERVICES = sig
[< Eliom_service.registrable > `Registrable ], 'a)
Eliom_service.service
val election_index :
(Serializable_t.uuid, unit,
[> `Attached of
([> `Internal of [> `Service ] ], [> `Get ])
Eliom_service.a_s ],
[ `WithoutSuffix ],
[ `One of Serializable_t.uuid ] Eliom_parameter.param_name,
unit, [< Eliom_service.registrable > `Registrable ], 'a)
Eliom_service.service
val election_file :
'a Serializable_t.params ->
Services.election_file ->
......
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