Attention une mise à jour du serveur va être effectuée le vendredi 16 avril entre 12h et 12h30. Cette mise à jour va générer une interruption du service de quelques minutes.

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

Remove dead code related to main and featured elections

parent 79cf2abd
......@@ -59,11 +59,6 @@ let () =
spool_dir := Some dir
| Element ("rewrite-prefix", ["src", src; "dst", 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_system, auth_config, [])]) ->
let i = {auth_system; auth_instance; auth_config} in
......@@ -90,13 +85,13 @@ let read_election_dir dir =
wrap1 datadir_index_of_string >>=
Lwt_list.map_p (fun item ->
let path = dir/item.datadir_dir in
return ({
return {
f_election = path/"election.json";
f_metadata = path/"metadata.json";
f_public_keys = path/"public_keys.jsons";
f_public_creds = path/"public_creds.txt";
f_voters = path/"voters.txt";
}, item.datadir_featured)
}
)
lwt source_file =
......@@ -124,7 +119,7 @@ let () = Web_site_auth.configure (List.rev !auth_instances)
lwt () =
Lwt_list.iter_s (fun 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
| None ->
Ocsigen_messages.debug (fun () ->
......@@ -133,15 +128,6 @@ lwt () =
| Some w ->
let module W = (val w : REGISTRABLE_ELECTION) in
lwt w = W.register () in
let module W = (val w : WEB_ELECTION) in
if featured then (
let uuid = Uuidm.to_string W.election.e_params.e_uuid in
Web_persist.add_featured_election uuid
) else return ()
return ()
)
) !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 =
let set_election_date 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 get_partial_decryptions x =
......
......@@ -33,15 +33,6 @@ val set_election_state : string -> election_state -> unit Lwt.t
val get_election_date : string -> datetime 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 set_partial_decryptions : string -> (int * string) list -> unit Lwt.t
......
......@@ -53,7 +53,6 @@ type metadata = {
type datadir_item = {
dir : string;
featured : bool;
} <ocaml field_prefix="datadir_">
type datadir_index = datadir_item list
......
......@@ -249,17 +249,7 @@ lwt () =
let () = Any.register ~service:home
(fun () () ->
Eliom_reference.unset Web_auth_state.cont >>
match_lwt Web_persist.get_main_election () with
| 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, ()))
T.home () >>= Html5.send
)
let () = Html5.register ~service:admin
......@@ -1016,13 +1006,12 @@ let () =
let uuid_s = Uuidm.to_string uuid in
let w = SMap.find uuid_s !election_table 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 uuid = Uuidm.to_string W.election.e_params.e_uuid in
match site_user with
| Some u when W.metadata.e_owner = Some u ->
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 ()
)
......
......@@ -149,7 +149,7 @@ let format_election kind election =
p [pcdata e.e_description];
]
let home ~featured () =
let home () =
let loria = Eliom_service.Http.external_service
~prefix:"http://www.loria.fr"
~path:[]
......@@ -869,7 +869,7 @@ let election_home w state () =
lwt login_box = election_login_box w () in
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 title = W.election.e_params.e_name ^ " — Administration" in
let uuid_s = Uuidm.to_string W.election.e_params.e_uuid in
......
......@@ -21,7 +21,7 @@
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 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 -> [>
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_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 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
......
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