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