Commit 39406edd authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Remove dead code related to main and featured elections

parent 79cf2abd
...@@ -59,11 +59,6 @@ let () = ...@@ -59,11 +59,6 @@ let () =
spool_dir := Some dir spool_dir := Some dir
| Element ("rewrite-prefix", ["src", src; "dst", dst], []) -> | Element ("rewrite-prefix", ["src", src; "dst", dst], []) ->
set_rewrite_prefix ~src ~dst set_rewrite_prefix ~src ~dst
| Element ("main-election", ["uuid", uuid], []) ->
(match Uuidm.of_string uuid with
| Some u -> main_election_uuid := Some (Uuidm.to_string u)
| None -> failwith "Incorrect UUID in configuration <main-election> tag"
)
| Element ("auth", ["name", auth_instance], | Element ("auth", ["name", auth_instance],
[Element (auth_system, auth_config, [])]) -> [Element (auth_system, auth_config, [])]) ->
let i = {auth_system; auth_instance; auth_config} in let i = {auth_system; auth_instance; auth_config} in
...@@ -90,13 +85,13 @@ let read_election_dir dir = ...@@ -90,13 +85,13 @@ let read_election_dir dir =
wrap1 datadir_index_of_string >>= wrap1 datadir_index_of_string >>=
Lwt_list.map_p (fun item -> Lwt_list.map_p (fun item ->
let path = dir/item.datadir_dir in let path = dir/item.datadir_dir in
return ({ return {
f_election = path/"election.json"; f_election = path/"election.json";
f_metadata = path/"metadata.json"; f_metadata = path/"metadata.json";
f_public_keys = path/"public_keys.jsons"; f_public_keys = path/"public_keys.jsons";
f_public_creds = path/"public_creds.txt"; f_public_creds = path/"public_creds.txt";
f_voters = path/"voters.txt"; f_voters = path/"voters.txt";
}, item.datadir_featured) }
) )
lwt source_file = lwt source_file =
...@@ -124,7 +119,7 @@ let () = Web_site_auth.configure (List.rev !auth_instances) ...@@ -124,7 +119,7 @@ let () = Web_site_auth.configure (List.rev !auth_instances)
lwt () = lwt () =
Lwt_list.iter_s (fun dir -> Lwt_list.iter_s (fun dir ->
read_election_dir dir >>= read_election_dir dir >>=
Lwt_list.iter_s (fun (f, featured) -> Lwt_list.iter_s (fun f ->
match_lwt Web_site.import_election f with match_lwt Web_site.import_election f with
| None -> | None ->
Ocsigen_messages.debug (fun () -> Ocsigen_messages.debug (fun () ->
...@@ -133,15 +128,6 @@ lwt () = ...@@ -133,15 +128,6 @@ lwt () =
| Some w -> | Some w ->
let module W = (val w : REGISTRABLE_ELECTION) in let module W = (val w : REGISTRABLE_ELECTION) in
lwt w = W.register () in lwt w = W.register () in
let module W = (val w : WEB_ELECTION) in return ()
if featured then (
let uuid = Uuidm.to_string W.election.e_params.e_uuid in
Web_persist.add_featured_election uuid
) else return ()
) )
) !import_dirs ) !import_dirs
lwt () =
match !main_election_uuid with
| Some uuid -> Web_persist.set_main_election uuid
| _ -> return ()
...@@ -51,46 +51,6 @@ let get_election_date x = ...@@ -51,46 +51,6 @@ let get_election_date x =
let set_election_date x d = let set_election_date x d =
Ocsipersist.add election_dates x d Ocsipersist.add election_dates x d
let store = Ocsipersist.open_store "site"
lwt main_election =
Ocsipersist.make_persistent store "main_election" None
lwt featured =
Ocsipersist.make_persistent store "featured_elections" []
let add_featured_election x =
lwt the_featured = Ocsipersist.get featured in
if List.mem x the_featured then (
return ()
) else (
Ocsipersist.set featured (x :: the_featured)
)
let rec list_remove x = function
| [] -> []
| y :: ys -> if x = y then ys else y :: (list_remove x ys)
let remove_featured_election x =
lwt the_featured = Ocsipersist.get featured in
Ocsipersist.set featured (list_remove x the_featured)
let is_featured_election x =
lwt the_featured = Ocsipersist.get featured in
return (List.mem x the_featured)
let get_featured_elections () =
Ocsipersist.get featured
let get_main_election () =
Ocsipersist.get main_election
let set_main_election x =
Ocsipersist.set main_election (Some x)
let unset_main_election () =
Ocsipersist.set main_election None
let election_pds = Ocsipersist.open_table "election_pds" let election_pds = Ocsipersist.open_table "election_pds"
let get_partial_decryptions x = let get_partial_decryptions x =
......
...@@ -33,15 +33,6 @@ val set_election_state : string -> election_state -> unit Lwt.t ...@@ -33,15 +33,6 @@ val set_election_state : string -> election_state -> unit Lwt.t
val get_election_date : string -> datetime Lwt.t val get_election_date : string -> datetime Lwt.t
val set_election_date : string -> datetime -> unit Lwt.t val set_election_date : string -> datetime -> unit Lwt.t
val get_main_election : unit -> string option Lwt.t
val set_main_election : string -> unit Lwt.t
val unset_main_election : unit -> unit Lwt.t
val add_featured_election : string -> unit Lwt.t
val remove_featured_election : string -> unit Lwt.t
val is_featured_election : string -> bool Lwt.t
val get_featured_elections : unit -> string list Lwt.t
val get_partial_decryptions : string -> (int * string) list Lwt.t val get_partial_decryptions : string -> (int * string) list Lwt.t
val set_partial_decryptions : string -> (int * string) list -> unit Lwt.t val set_partial_decryptions : string -> (int * string) list -> unit Lwt.t
......
...@@ -53,7 +53,6 @@ type metadata = { ...@@ -53,7 +53,6 @@ type metadata = {
type datadir_item = { type datadir_item = {
dir : string; dir : string;
featured : bool;
} <ocaml field_prefix="datadir_"> } <ocaml field_prefix="datadir_">
type datadir_index = datadir_item list type datadir_index = datadir_item list
......
...@@ -249,17 +249,7 @@ lwt () = ...@@ -249,17 +249,7 @@ lwt () =
let () = Any.register ~service:home let () = Any.register ~service:home
(fun () () -> (fun () () ->
Eliom_reference.unset Web_auth_state.cont >> Eliom_reference.unset Web_auth_state.cont >>
match_lwt Web_persist.get_main_election () with T.home () >>= Html5.send
| None ->
lwt featured =
Web_persist.get_featured_elections () >>=
Lwt_list.map_p (fun x -> return @@ SMap.find x !election_table)
in
T.home ~featured () >>= Html5.send
| Some x ->
let module W = (val SMap.find x !election_table : WEB_ELECTION) in
Redirection.send
(preapply election_home (W.election.e_params.e_uuid, ()))
) )
let () = Html5.register ~service:admin let () = Html5.register ~service:admin
...@@ -1016,13 +1006,12 @@ let () = ...@@ -1016,13 +1006,12 @@ let () =
let uuid_s = Uuidm.to_string uuid in let uuid_s = Uuidm.to_string uuid in
let w = SMap.find uuid_s !election_table in let w = SMap.find uuid_s !election_table in
lwt site_user = Web_auth_state.get_site_user () in lwt site_user = Web_auth_state.get_site_user () in
lwt is_featured = Web_persist.is_featured_election uuid_s in
let module W = (val w : WEB_ELECTION) in let module W = (val w : WEB_ELECTION) in
let uuid = Uuidm.to_string W.election.e_params.e_uuid in let uuid = Uuidm.to_string W.election.e_params.e_uuid in
match site_user with match site_user with
| Some u when W.metadata.e_owner = Some u -> | Some u when W.metadata.e_owner = Some u ->
lwt state = Web_persist.get_election_state uuid in lwt state = Web_persist.get_election_state uuid in
T.election_admin (module W) ~is_featured state () >>= Html5.send T.election_admin (module W) state () >>= Html5.send
| _ -> forbidden () | _ -> forbidden ()
) )
......
...@@ -149,7 +149,7 @@ let format_election kind election = ...@@ -149,7 +149,7 @@ let format_election kind election =
p [pcdata e.e_description]; p [pcdata e.e_description];
] ]
let home ~featured () = let home () =
let loria = Eliom_service.Http.external_service let loria = Eliom_service.Http.external_service
~prefix:"http://www.loria.fr" ~prefix:"http://www.loria.fr"
~path:[] ~path:[]
...@@ -869,7 +869,7 @@ let election_home w state () = ...@@ -869,7 +869,7 @@ let election_home w state () =
lwt login_box = election_login_box w () in lwt login_box = election_login_box w () in
base ~title:params.e_name ~login_box ~content ~footer () base ~title:params.e_name ~login_box ~content ~footer ()
let election_admin w ~is_featured state () = let election_admin w state () =
let module W = (val w : WEB_ELECTION) in let module W = (val w : WEB_ELECTION) in
let title = W.election.e_params.e_name ^ " — Administration" in let title = W.election.e_params.e_name ^ " — Administration" in
let uuid_s = Uuidm.to_string W.election.e_params.e_uuid in let uuid_s = Uuidm.to_string W.election.e_params.e_uuid in
......
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
open Web_signatures open Web_signatures
val home : featured:(module WEB_ELECTION) list -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t val home : unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val admin : elections:((module WEB_ELECTION) list * (module WEB_ELECTION) list * (Uuidm.t * string) list) option -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t val admin : elections:((module WEB_ELECTION) list * (module WEB_ELECTION) list * (Uuidm.t * string) list) option -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val new_election_failure : [ `Exists | `Exception of exn ] -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t val new_election_failure : [ `Exists | `Exception of exn ] -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
...@@ -37,7 +37,7 @@ val election_setup_trustees : Uuidm.t -> Web_common.setup_election -> unit -> [> ...@@ -37,7 +37,7 @@ val election_setup_trustees : Uuidm.t -> Web_common.setup_election -> unit -> [>
val election_setup_trustee : string -> string -> 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 val election_home : (module WEB_ELECTION) -> Web_persist.election_state -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val election_admin : (module WEB_ELECTION) -> is_featured:bool -> Web_persist.election_state -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t val election_admin : (module WEB_ELECTION) -> Web_persist.election_state -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val update_credential : (module WEB_ELECTION) -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t val update_credential : (module WEB_ELECTION) -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val cast_raw : (module WEB_ELECTION) -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t val cast_raw : (module WEB_ELECTION) -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val cast_confirmation : (module WEB_ELECTION) -> string -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t val cast_confirmation : (module WEB_ELECTION) -> string -> 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