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 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
lwt site_user = Web_auth_state.get_site_user () in
lwt elections =
match site_user with
| None -> return []
| None -> return None
| Some u ->
SMap.fold (fun _ w accu ->
let module W = (val w : WEB_ELECTION) in
if W.metadata.e_owner = Some u then (
w :: accu
) else (
accu
)
) !election_table [] |> List.rev |> return
in
lwt setup_elections =
match site_user with
| None -> return []
| Some u ->
Ocsipersist.fold_step (fun k v accu ->
if v.se_owner = u
then return (uuid_of_string k :: accu)
else return accu
) election_stable []
lwt elections =
SMap.fold (fun _ w accu ->
let module W = (val w : WEB_ELECTION) in
if W.metadata.e_owner = Some u then (
w :: accu
) else (
accu
)
) !election_table [] |> List.rev |> return
and setup_elections =
Ocsipersist.fold_step (fun k v accu ->
if v.se_owner = u
then return (uuid_of_string k :: accu)
else return accu
) election_stable []
in return @@ Some (elections, setup_elections)
in
T.admin ~elections ~setup_elections ()
T.admin ~elections ()
)
let () = File.register
......
......@@ -176,8 +176,13 @@ let home ~featured () =
let login_box = pcdata "" in
base ~title:site_title ~login_box ~content ()
let admin ~elections ~setup_elections () =
let admin ~elections () =
let title = site_title ^ " — Administration" in
let elections, setup_elections =
match elections with
| None -> [], []
| Some (x, y) -> x, y
in
let elections =
match elections with
| [] -> p [pcdata "You own no such elections!"]
......
......@@ -22,7 +22,7 @@
open Web_signatures
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_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