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
5c1d0076
Commit
5c1d0076
authored
Apr 01, 2014
by
Stephane Glondu
Browse files
Add the possibility to (un)feature an election from its admin page
parent
1bd922a9
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/web/web_election.ml
View file @
5c1d0076
...
...
@@ -318,7 +318,27 @@ module Make (D : ELECTION_DATA) (P : WEB_PARAMS) : REGISTRATION = struct
let
()
=
Html5
.
register
~
service
:
W
.
S
.
admin
(
fun
()
()
->
match_lwt
S
.
get_user
()
with
|
Some
u
when
W
.
metadata
.
e_owner
=
Some
u
->
T
.
admin
()
|
Some
u
when
W
.
metadata
.
e_owner
=
Some
u
->
let
post_params
=
Eliom_parameter
.(
bool
"featured"
)
in
let
set_featured
=
Eliom_service
.
post_coservice
~
csrf_safe
:
true
~
csrf_scope
:
scope
~
fallback
:
W
.
S
.
admin
~
post_params
()
in
let
()
=
Any
.
register
~
scope
~
service
:
set_featured
(
fun
()
featured
->
lwt
()
=
if
featured
then
(
S
.
add_featured_election
uuid
)
else
(
S
.
remove_featured_election
uuid
)
in
Redirection
.
send
W
.
S
.
admin
)
in
T
.
admin
~
set_featured
()
|
_
->
forbidden
()
)
...
...
src/web/web_signatures.mli
View file @
5c1d0076
...
...
@@ -223,6 +223,11 @@ module type ELECTION_TEMPLATES = sig
unit
->
[
>
`Html
]
Eliom_content
.
Html5
.
F
.
elt
Lwt
.
t
val
admin
:
set_featured
:
(
unit
,
'
a
,
[
<
Eliom_service
.
post_service_kind
]
,
[
<
Eliom_service
.
suff
]
,
'
b
,
[
`One
of
bool
]
Eliom_parameter
.
param_name
,
[
<
Eliom_service
.
registrable
]
,
'
c
)
Eliom_service
.
service
->
unit
->
[
>
`Html
]
Eliom_content
.
Html5
.
F
.
elt
Lwt
.
t
val
update_credential
:
...
...
src/web/web_templates.ml
View file @
5c1d0076
...
...
@@ -381,8 +381,14 @@ module Make (S : SITE_SERVICES) : TEMPLATES = struct
lwt
login_box
=
election_login_box
()
in
base
~
title
:
params
.
e_name
~
login_box
~
content
let
admin
()
=
let
admin
~
set_featured
()
=
let
title
=
W
.
election
.
e_params
.
e_name
^
" — Administration"
in
let
feature_form
=
post_form
~
service
:
set_featured
(
fun
featured
->
[
bool_checkbox
~
name
:
featured
()
;
string_input
~
input_type
:
`Submit
~
value
:
"(Un)feature"
()
;
])
()
in
let
content
=
[
h1
[
pcdata
title
];
div
[
...
...
@@ -393,6 +399,7 @@ module Make (S : SITE_SERVICES) : TEMPLATES = struct
let
service
=
W
.
S
.
election_update_credential
in
a
~
service
[
pcdata
"Update a credential"
]
()
;
];
div
[
feature_form
];
]
in
lwt
login_box
=
site_login_box
()
in
base
~
title
~
login_box
~
content
...
...
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