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

Clearer form for featuring an election

parent 33cb654b
......@@ -392,7 +392,8 @@ module Make (D : ELECTION_DATA) (P : WEB_PARAMS) : REGISTRABLE = struct
) in Redirection.send W.S.admin
)
in
T.admin ~set_featured ()
lwt is_featured = S.is_featured_election uuid in
T.admin ~set_featured ~is_featured ()
| _ -> forbidden ()
)
......
......@@ -262,6 +262,7 @@ module type ELECTION_TEMPLATES = sig
[ `One of bool ] Eliom_parameter.param_name,
[< Eliom_service.registrable ], 'c)
Eliom_service.service ->
is_featured:bool ->
unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val update_credential :
......@@ -330,6 +331,7 @@ module type SITE = sig
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 cont : (unit -> service_handler) Eliom_reference.eref
end
......
......@@ -153,6 +153,10 @@ module Make (C : CONFIG) : SITE = struct
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 set_main_election x =
if SMap.mem x !election_table then (
Ocsipersist.set main_election (Some x)
......
......@@ -438,12 +438,13 @@ module Make (S : SITE_SERVICES) : TEMPLATES = struct
lwt login_box = election_login_box () in
base ~title:params.e_name ~login_box ~content
let admin ~set_featured () =
let admin ~set_featured ~is_featured () =
let title = W.election.e_params.e_name ^ " — Administration" in
let feature_form = post_form ~service:set_featured
(fun featured -> [
bool_checkbox ~name:featured ();
string_input ~input_type:`Submit ~value:"(Un)feature" ();
bool_checkbox ~name:featured ~checked:is_featured ();
pcdata "Feature this election ";
string_input ~input_type:`Submit ~value:"Apply" ();
]) ()
in
let content = [
......
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