Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
belenios
belenios
Commits
431bcca9
Commit
431bcca9
authored
Jun 21, 2013
by
Stephane Glondu
Browse files
Add voters_list to metadata
parent
132e8742
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/lib/serializable.atd
View file @
431bcca9
...
...
@@ -94,4 +94,5 @@ type randomness = {
type metadata = {
voting_starts_at : datetime;
voting_ends_at : datetime;
?voters_list : string list option;
} <ocaml field_prefix="e_">
src/web/registration.ml
View file @
431bcca9
...
...
@@ -7,6 +7,7 @@ open Lwt
let
()
=
Ocsigen_config
.
set_maxrequestbodysizeinmemory
128000
module
EMap
=
Map
.
Make
(
Uuidm
)
module
SSet
=
Set
.
Make
(
String
)
let
(
/
)
=
Filename
.
concat
...
...
@@ -60,6 +61,28 @@ lwt election_table =
Serializable_j
.
read_ff_pubkey
raw
in
let
fingerprint
=
sha256_b64
raw
in
lwt
metadata
=
let
fn
=
path
/
"metadata.json"
in
lwt
b
=
file_exists
fn
in
if
b
then
(
Lwt_io
.
chars_of_file
fn
|>
Lwt_stream
.
to_string
>>=
wrap1
Serializable_j
.
metadata_of_string
>>=
(
fun
x
->
return
(
Some
x
))
)
else
return
None
in
let
can_vote
=
match
metadata
with
|
None
->
Web_common
.
Any
|
Some
m
->
match
m
.
e_voters_list
with
|
None
->
Web_common
.
Any
|
Some
voters
->
let
set
=
List
.
fold_left
(
fun
accu
u
->
SSet
.
add
u
accu
)
SSet
.
empty
voters
in
Web_common
.
Restricted
(
fun
u
->
return
(
SSet
.
mem
(
Web_common
.
string_of_user
u
)
set
)
)
in
let
election_data
=
Web_common
.({
fn_election
;
fingerprint
;
...
...
@@ -67,23 +90,13 @@ lwt election_table =
fn_public_keys
;
featured_p
=
true
;
can_read
=
Any
;
can_vote
=
Any
;
can_vote
;
})
in
let
{
g
;
p
;
q
;
y
}
=
election
.
e_public_key
in
let
module
G
=
(
val
Election
.
finite_field
~
p
~
q
~
g
:
Signatures
.
GROUP
with
type
t
=
Z
.
t
)
in
lwt
metadata
=
let
fn
=
path
/
"metadata.json"
in
lwt
b
=
file_exists
fn
in
if
b
then
(
Lwt_io
.
chars_of_file
fn
|>
Lwt_stream
.
to_string
>>=
wrap1
Serializable_j
.
metadata_of_string
>>=
(
fun
x
->
return
(
Some
x
))
)
else
return
None
in
let
module
P
=
struct
module
G
=
G
let
public_keys
=
lazy
(
assert
false
)
...
...
tests/data/{2c91b0df-21b7-4631-ac3b-2613301f24bc}/metadata.json
View file @
431bcca9
{
"voting_starts_at"
:
"2013-06-22 09:18:04.836200"
,
"voting_ends_at"
:
"2013-06-29 09:18:04.836200"
}
\ No newline at end of file
{
"voting_starts_at"
:
"2013-06-22 09:18:04.836200"
,
"voting_ends_at"
:
"2013-06-29 09:18:04.836200"
,
"voters_list"
:[
"dummy:tata"
,
"dummy:titi"
,
"dummy:toto"
,
"dummy:tutu"
]}
\ No newline at end of file
tests/sandbox.ml
View file @
431bcca9
...
...
@@ -73,6 +73,7 @@ let metadata =
{
e_voting_starts_at
=
add
now
Period
.(
day
1
)
,
None
;
e_voting_ends_at
=
add
now
Period
.(
day
8
)
,
None
;
e_voters_list
=
None
;
}
;;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment