Commit c4f68c66 authored by Stephane Glondu's avatar Stephane Glondu

Merge Services into Web_common

parent 842d7edc
......@@ -235,7 +235,6 @@ module SAuth = Auth_common.Make (struct end)
module SSite = struct
open Eliom_service
open Services
module Services : SITE_SERVICES = struct
open Eliom_parameter
......@@ -257,7 +256,7 @@ module SSite = struct
let election_update_credential = service
~path:["update-cred"]
~get_params:uuid
~get_params:(uuid "uuid")
()
let election_update_credential_post = post_service
......@@ -365,7 +364,6 @@ end
module SElection = struct
open Eliom_service
open Eliom_parameter
open Services
let election_file = Eliom_parameter.user_type
election_file_of_string
......@@ -376,7 +374,7 @@ module SElection = struct
let election_dir = service
~path:["elections"]
~get_params:(suffix (uuid ** election_file))
~get_params:(suffix (uuid "uuid" ** election_file))
()
let election_file e f = preapply election_dir (e.e_uuid, f)
......@@ -480,19 +478,18 @@ end
module SVoting = struct
open Eliom_service
open Services
module Services : VOTING_SERVICES = struct
open Eliom_parameter
let election_vote = service
~path:["election"; "vote"]
~get_params:uuid
~get_params:(uuid "uuid")
()
let election_cast = service
~path:["election"; "cast"]
~get_params:uuid
~get_params:(uuid "uuid")
()
let create_confirm () = post_coservice
......@@ -611,8 +608,6 @@ end
module S = struct
open Lwt
open Eliom_service
open Services
include SAuth.Services
include SSite.Services
......
......@@ -9,6 +9,5 @@ Auth_password
Auth_cas
Web_election
Election
Services
Templates
Registration
(**************************************************************************)
(* BELENIOS *)
(* *)
(* Copyright © 2012-2014 Inria *)
(* *)
(* This program is free software: you can redistribute it and/or modify *)
(* it under the terms of the GNU Affero General Public License as *)
(* published by the Free Software Foundation, either version 3 of the *)
(* License, or (at your option) any later version, with the additional *)
(* exemption that compiling, linking, and/or using OpenSSL is allowed. *)
(* *)
(* This program is distributed in the hope that it will be useful, but *)
(* WITHOUT ANY WARRANTY; without even the implied warranty of *)
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *)
(* Affero General Public License for more details. *)
(* *)
(* You should have received a copy of the GNU Affero General Public *)
(* License along with this program. If not, see *)
(* <http://www.gnu.org/licenses/>. *)
(**************************************************************************)
open Util
open Serializable_t
open Eliom_service
open Eliom_parameter
let uuid = Eliom_parameter.user_type
(fun x -> match Uuidm.of_string x with
| Some x -> x
| None -> invalid_arg "uuid")
Uuidm.to_string
"uuid"
type election_file =
| ESIndex
| ESRaw
| ESKeys
| ESCreds
| ESBallots
| ESRecords
let election_file_of_string = function
| "" -> ESIndex
| "election.json" -> ESRaw
| "public_keys.jsons" -> ESKeys
| "public_creds.txt" -> ESCreds
| "ballots.jsons" -> ESBallots
| "records" -> ESRecords
| x -> invalid_arg ("election_dir_item: " ^ x)
let string_of_election_file = function
| ESIndex -> ""
| ESRaw -> "election.json"
| ESKeys -> "public_keys.jsons"
| ESCreds -> "public_creds.txt"
| ESBallots -> "ballots.jsons"
| ESRecords -> "records"
......@@ -94,7 +94,7 @@ module Make (S : ALL_SERVICES) : TEMPLATES = struct
let e = X.election.e_params in
li [
h3 [
a ~service:(S.election_file e Services.ESIndex)
a ~service:(S.election_file e ESIndex)
[pcdata e.e_name] ();
];
p [pcdata e.e_description];
......@@ -190,7 +190,7 @@ module Make (S : ALL_SERVICES) : TEMPLATES = struct
let election_view ~election ~user =
let module X = (val election : WEB_ELECTION) in
let params = X.election.e_params and m = X.metadata in
let service = S.election_file params Services.ESRaw in
let service = S.election_file params ESRaw in
lwt permissions =
match user with
| None ->
......@@ -245,15 +245,15 @@ module Make (S : ALL_SERVICES) : TEMPLATES = struct
pcdata "Election data: ";
a ~service [ pcdata "parameters" ] ();
pcdata ", ";
a ~service:(S.election_file params Services.ESCreds) [
a ~service:(S.election_file params ESCreds) [
pcdata "public credentials"
] ();
pcdata ", ";
a ~service:(S.election_file params Services.ESKeys) [
a ~service:(S.election_file params ESKeys) [
pcdata "trustee public keys"
] ();
pcdata ", ";
a ~service:(S.election_file params Services.ESBallots) [
a ~service:(S.election_file params ESBallots) [
pcdata "ballots";
] ();
pcdata ".";
......@@ -350,7 +350,7 @@ module Make (S : ALL_SERVICES) : TEMPLATES = struct
];
user_div;
p [
a ~service:(S.election_file params Services.ESIndex) [
a ~service:(S.election_file params ESIndex) [
pcdata "Go back to election"
] ();
pcdata ".";
......@@ -373,7 +373,7 @@ module Make (S : ALL_SERVICES) : TEMPLATES = struct
);
];
p [
a ~service:(S.election_file params Services.ESIndex) [
a ~service:(S.election_file params ESIndex) [
pcdata "Go back to election"
] ();
pcdata ".";
......
......@@ -166,3 +166,34 @@ let check_acl a u =
| _ :: xs -> loop xs
in loop acls
| _ -> false
let uuid = Eliom_parameter.user_type
~of_string:(fun x -> match Uuidm.of_string x with
| Some x -> x
| None -> invalid_arg "uuid")
~to_string:Uuidm.to_string
type election_file =
| ESIndex
| ESRaw
| ESKeys
| ESCreds
| ESBallots
| ESRecords
let election_file_of_string = function
| "" -> ESIndex
| "election.json" -> ESRaw
| "public_keys.jsons" -> ESKeys
| "public_creds.txt" -> ESCreds
| "ballots.jsons" -> ESBallots
| "records" -> ESRecords
| x -> invalid_arg ("election_dir_item: " ^ x)
let string_of_election_file = function
| ESIndex -> ""
| ESRaw -> "election.json"
| ESKeys -> "public_keys.jsons"
| ESCreds -> "public_creds.txt"
| ESBallots -> "ballots.jsons"
| ESRecords -> "records"
......@@ -69,3 +69,20 @@ val set_rewrite_prefix : src:string -> dst:string -> unit
val empty_metadata : metadata
val check_acl : acl list option -> user -> bool
val uuid :
string ->
(Uuidm.t, [ `WithoutSuffix ],
[ `One of Uuidm.t ] Eliom_parameter.param_name)
Eliom_parameter.params_type
type election_file =
| ESIndex
| ESRaw
| ESKeys
| ESCreds
| ESBallots
| ESRecords
val election_file_of_string : string -> election_file
val string_of_election_file : election_file -> string
......@@ -93,19 +93,19 @@ end
module type ELECTION_SERVICES = sig
val election_dir :
(Serializable_t.uuid * Services.election_file, unit,
(Serializable_t.uuid * Web_common.election_file, unit,
[> `Attached of
([> `Internal of [> `Service ] ], [> `Get ])
Eliom_service.a_s ],
[ `WithSuffix ],
[ `One of Serializable_t.uuid ] Eliom_parameter.param_name *
[ `One of Services.election_file ] Eliom_parameter.param_name,
[ `One of Web_common.election_file ] Eliom_parameter.param_name,
unit, [< Eliom_service.registrable > `Registrable ], 'a)
Eliom_service.service
val election_file :
'a Serializable_t.params ->
Services.election_file ->
Web_common.election_file ->
(unit, unit,
[> `Attached of
([> `Internal of [> `Service ] ], [> `Get ])
......
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