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 63e096c6 authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Add {add,remove}_featured_election

parent 93ba37a6
......@@ -265,6 +265,8 @@ module type SITE = sig
featured:bool -> 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
val remove_featured_election : string -> unit Lwt.t
val cont : (unit -> service_handler) Eliom_reference.eref
end
......
......@@ -34,6 +34,10 @@ module type CONFIG = sig
val auth_config : auth_config list
end
let rec list_remove x = function
| [] -> []
| y :: ys -> if x = y then ys else y :: (list_remove x ys)
let get_single_line x =
match_lwt Lwt_stream.get x with
| None -> return None
......@@ -105,6 +109,20 @@ module Make (C : CONFIG) : SITE = struct
let import_election ~featured f = !import_election_ref featured f
let add_featured_election x =
lwt the_featured = Ocsipersist.get featured in
if List.mem x the_featured then (
return ()
) else if SMap.mem x !election_table then (
Ocsipersist.set featured (x :: the_featured)
) else (
Lwt.fail Not_found
)
let remove_featured_election x =
lwt the_featured = Ocsipersist.get featured in
Ocsipersist.set featured (list_remove x the_featured)
let set_main_election x =
if SMap.mem x !election_table then (
Ocsipersist.set main_election (Some x)
......
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