Commit f708a69e authored by Stephane Glondu's avatar Stephane Glondu
Browse files

Web_templates.admin can distinguish whether an admin is logged in

parent 06d7f146
...@@ -252,28 +252,26 @@ let () = Html5.register ~service:admin ...@@ -252,28 +252,26 @@ let () = Html5.register ~service:admin
lwt site_user = Web_auth_state.get_site_user () in lwt site_user = Web_auth_state.get_site_user () in
lwt elections = lwt elections =
match site_user with match site_user with
| None -> return [] | None -> return None
| Some u -> | Some u ->
SMap.fold (fun _ w accu -> lwt elections =
let module W = (val w : WEB_ELECTION) in SMap.fold (fun _ w accu ->
if W.metadata.e_owner = Some u then ( let module W = (val w : WEB_ELECTION) in
w :: accu if W.metadata.e_owner = Some u then (
) else ( w :: accu
accu ) else (
) accu
) !election_table [] |> List.rev |> return )
in ) !election_table [] |> List.rev |> return
lwt setup_elections = and setup_elections =
match site_user with Ocsipersist.fold_step (fun k v accu ->
| None -> return [] if v.se_owner = u
| Some u -> then return (uuid_of_string k :: accu)
Ocsipersist.fold_step (fun k v accu -> else return accu
if v.se_owner = u ) election_stable []
then return (uuid_of_string k :: accu) in return @@ Some (elections, setup_elections)
else return accu
) election_stable []
in in
T.admin ~elections ~setup_elections () T.admin ~elections ()
) )
let () = File.register let () = File.register
......
...@@ -176,8 +176,13 @@ let home ~featured () = ...@@ -176,8 +176,13 @@ let home ~featured () =
let login_box = pcdata "" in let login_box = pcdata "" in
base ~title:site_title ~login_box ~content () base ~title:site_title ~login_box ~content ()
let admin ~elections ~setup_elections () = let admin ~elections () =
let title = site_title ^ " — Administration" in let title = site_title ^ " — Administration" in
let elections, setup_elections =
match elections with
| None -> [], []
| Some (x, y) -> x, y
in
let elections = let elections =
match elections with match elections with
| [] -> p [pcdata "You own no such elections!"] | [] -> p [pcdata "You own no such elections!"]
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
open Web_signatures open Web_signatures
val home : featured:(module WEB_ELECTION) list -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t val home : featured:(module WEB_ELECTION) list -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val admin : elections:(module WEB_ELECTION) list -> setup_elections:(Uuidm.t list) -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t val admin : elections:((module WEB_ELECTION) list * Uuidm.t list) option -> unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t
val new_election : unit -> [> `Html ] Eliom_content.Html5.F.elt Lwt.t val new_election : 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 val new_election_failure : [ `Exists | `Exception of exn ] -> 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