Commit 8bc97ca0 authored by Stephane Glondu's avatar Stephane Glondu

Show dates of automatic archiving/deletion in admin pages

parent 3ba870f8
......@@ -47,7 +47,7 @@ let raw_datetime_of_string s =
let datetime_compare (a, _) (b, _) =
CalendarLib.Fcalendar.Precise.compare a b
let format_datetime fmt (a, _) =
let format_datetime ?(fmt = datetime_format) (a, _) =
CalendarLib.Printer.Precise_Fcalendar.sprint fmt a
type period = CalendarLib.Fcalendar.Precise.Period.t
......
......@@ -24,7 +24,7 @@ val now : unit -> datetime
val raw_string_of_datetime : datetime -> string
val raw_datetime_of_string : string -> datetime
val datetime_compare : datetime -> datetime -> int
val format_datetime : string -> datetime -> string
val format_datetime : ?fmt:string -> datetime -> string
type period
val day : int -> period
......
......@@ -24,6 +24,7 @@ open Serializable_builtin_t
open Serializable_j
open Signatures
open Common
open Web_serializable_builtin_t
open Web_serializable_j
open Web_signatures
open Web_common
......@@ -550,12 +551,19 @@ let election_draft uuid se () =
a ~service:election_draft_confirm [pcdata "Create election"] uuid;
] in
let form_destroy =
let t = option_get se.se_creation_date default_creation_date in
let t = datetime_add t (day 365) in
post_form
~service:election_draft_destroy
(fun () ->
[
div [
h2 [pcdata "Destroy election"];
div [
pcdata "Note: this election will be automatically destroyed after ";
pcdata (format_datetime t);
pcdata ".";
];
string_input ~input_type:`Submit ~value:"Destroy election" ();
]
]
......@@ -1857,11 +1865,24 @@ let election_admin election metadata state get_tokens_decrypt () =
pcdata "This election is archived.";
]
in
let%lwt archive_date = match state with
| `Tallied _ ->
let%lwt t = Web_persist.get_election_date `Tally uuid in
let t = datetime_add (option_get t default_tally_date) (day 14) in
return @@
div [
pcdata "This election will be automatically archived after ";
pcdata (format_datetime t);
pcdata ".";
]
| _ -> return @@ pcdata ""
in
let div_archive = match state with
| `Archived -> pcdata ""
| _ -> div [
br ();
hr ();
archive_date;
post_form ~service:election_archive (fun () ->
[
string_input ~input_type:`Submit ~value:"Archive election" ();
......@@ -1870,10 +1891,26 @@ let election_admin election metadata state get_tokens_decrypt () =
) (uuid, ());
]
in
let%lwt deletion_date = match state with
| `Open | `Closed | `EncryptedTally _ ->
let%lwt t = Web_persist.get_election_date `Validation uuid in
return @@ datetime_add (option_get t default_validation_date) (day 365)
| `Tallied _ ->
let%lwt t = Web_persist.get_election_date `Tally uuid in
return @@ datetime_add (option_get t default_tally_date) (day 379)
| `Archived ->
let%lwt t = Web_persist.get_election_date `Archive uuid in
return @@ datetime_add (option_get t default_archive_date) (day 365)
in
let div_delete =
div [
br ();
hr ();
div [
pcdata "This election will be automatically deleted after ";
pcdata (format_datetime deletion_date);
pcdata ".";
];
post_form ~service:election_delete (fun () ->
[
string_input ~input_type:`Submit ~value:"Delete election" ();
......
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