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
9fac0280
Commit
9fac0280
authored
Jul 02, 2015
by
Stephane Glondu
Browse files
Pretty-print result when the election is tallied
parent
0dd3fd20
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/web/web_persist.ml
View file @
9fac0280
...
...
@@ -20,13 +20,14 @@
(**************************************************************************)
open
Lwt
open
Serializable_t
open
Common
type
election_state
=
[
`Open
|
`Closed
|
`EncryptedTally
of
int
*
int
*
string
|
`Tallied
|
`Tallied
of
plaintext
]
let
election_states
=
Ocsipersist
.
open_table
"election_states"
...
...
src/web/web_persist.mli
View file @
9fac0280
...
...
@@ -19,11 +19,13 @@
(* <http://www.gnu.org/licenses/>. *)
(**************************************************************************)
open
Serializable_t
type
election_state
=
[
`Open
|
`Closed
|
`EncryptedTally
of
int
*
int
*
string
|
`Tallied
|
`Tallied
of
plaintext
]
val
get_election_state
:
string
->
election_state
Lwt
.
t
val
set_election_state
:
string
->
election_state
->
unit
Lwt
.
t
...
...
src/web/web_site.ml
View file @
9fac0280
...
...
@@ -1206,7 +1206,7 @@ let () =
~
mode
:
Output
(
W
.
dir
/
string_of_election_file
ESResult
)
(
fun
oc
->
Lwt_io
.
write_line
oc
(
string_of_result
W
.
G
.
write
result
))
in
lwt
()
=
Web_persist
.
set_election_state
uuid_s
`Tallied
in
lwt
()
=
Web_persist
.
set_election_state
uuid_s
(
`Tallied
result
.
result
)
in
Eliom_service
.
preapply
election_admin
(
W
.
election
.
e_params
.
e_uuid
,
()
)
|>
Redirection
.
send
)
...
...
src/web/web_templates.ml
View file @
9fac0280
...
...
@@ -667,7 +667,7 @@ let election_home w state () =
pcdata
"."
;
]
in
let
state
=
let
state
_
=
match
state
with
|
`Closed
->
[
...
...
@@ -688,7 +688,7 @@ let election_home w state () =
b
[
pcdata
hash
];
pcdata
"."
;
]
|
`Tallied
->
|
`Tallied
_
->
[
pcdata
" "
;
b
[
pcdata
"This election has been tallied."
];
...
...
@@ -736,9 +736,7 @@ let election_home w state () =
];
]
]
in
let
content
=
[
p
(
voting_period
@
state
);
br
()
;
let
go_to_the_booth
=
div
~
a
:
[
a_style
"text-align:center;"
]
[
div
[
make_button
...
...
@@ -751,7 +749,33 @@ let election_home w state () =
~
service
:
(
Eliom_service
.
preapply
election_cast
(
params
.
e_uuid
,
()
))
[
pcdata
"submit a raw ballot"
]
()
;
];
];
]
in
let
middle
=
match
state
with
|
`Tallied
result
->
let
questions
=
Array
.
to_list
W
.
election
.
e_params
.
e_questions
in
ul
(
List
.
mapi
(
fun
i
x
->
let
answers
=
Array
.
to_list
x
.
q_answers
in
let
answers
=
List
.
mapi
(
fun
j
x
->
tr
[
td
[
pcdata
x
];
td
[
pcdata
@@
string_of_int
result
.
(
i
)
.
(
j
)]]
)
answers
in
let
answers
=
match
answers
with
|
[]
->
pcdata
""
|
x
::
xs
->
table
x
xs
in
li
[
pcdata
x
.
q_question
;
answers
;
]
)
questions
)
|
_
->
go_to_the_booth
in
let
content
=
[
p
(
voting_period
@
state_
);
br
()
;
middle
;
br
()
;
ballots_link
;
]
in
...
...
@@ -855,7 +879,7 @@ let election_admin w ~is_featured state () =
];
release_form
;
]
|
`Tallied
->
|
`Tallied
_
->
return
@@
div
[
pcdata
"This election has been tallied."
;
]
...
...
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