Une MAJ de sécurité est nécessaire sur notre version actuelle. Elle sera effectuée lundi 02/08 entre 12h30 et 13h. L'interruption de service devrait durer quelques minutes (probablement moins de 5 minutes).

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

Being featured is not an intrinsic property of an election

Drop the property from WEB_PARAMS and import_election arguments. It is
up to the caller of import_election to call add_featured_election
afterwards.
parent 75ca657d
......@@ -131,12 +131,17 @@ lwt () =
Lwt_list.iter_s (fun dir ->
read_election_dir dir >>=
Lwt_list.iter_s (fun (f, featured) ->
match_lwt Site.import_election ~featured f with
match_lwt Site.import_election f with
| None ->
Ocsigen_messages.debug (fun () ->
Printf.sprintf "Ignored: %s" f.f_election
); return ()
| Some _ -> return ()
| Some w ->
if featured then (
let module W = (val w : WEB_ELECTION) in
let uuid = Uuidm.to_string W.election.e_params.e_uuid in
Site.add_featured_election uuid
) else return ()
)
) !import_dirs
......
......@@ -249,7 +249,6 @@ end
module type WEB_PARAMS = sig
val metadata : metadata
val featured : bool
val dir : string
end
......@@ -282,7 +281,7 @@ module type SITE = sig
include SITE_SERVICES
include AUTH_HANDLERS_PUBLIC
val import_election :
featured:bool -> election_files -> (module WEB_ELECTION) option Lwt.t
election_files -> (module WEB_ELECTION) 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
......
......@@ -118,7 +118,7 @@ module Make (C : CONFIG) : SITE = struct
let cont = Eliom_reference.eref ~scope
(fun () () -> Eliom_registration.Redirection.send home)
let import_election ~featured f = !import_election_ref featured f
let import_election f = !import_election_ref f
let add_featured_election x =
lwt the_featured = Ocsipersist.get featured in
......@@ -169,7 +169,7 @@ module Make (C : CONFIG) : SITE = struct
election_table := SMap.add uuid election !election_table;
return election
let () = import_election_ref := fun featured f ->
let () = import_election_ref := fun f ->
lwt raw_election =
Lwt_io.lines_of_file f.f_election |>
get_single_line >>=
......@@ -211,17 +211,12 @@ module Make (C : CONFIG) : SITE = struct
in
let module X = struct
let metadata = metadata
let featured = featured
let dir = dir
end in
let web_params = (module X : WEB_PARAMS) in
Ocsipersist.add election_ptable uuid (raw_election, web_params) >>
lwt election = register_election params web_params in
let module W = (val election : WEB_ELECTION) in
lwt () =
if W.featured then S.add_featured_election uuid
else return ()
in
begin try_lwt
let () =
Ocsigen_messages.debug (fun () ->
......
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