From 119946c5cd2d99b0ee155569737cd8b345e1440b Mon Sep 17 00:00:00 2001 From: Dave Cross Date: Tue, 29 Sep 2015 13:04:50 +0100 Subject: [PATCH] Add ability to close the site. --- Kinza/lib/Kinza.pm | 8 +++++++- Kinza/views/closed.tt | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 Kinza/views/closed.tt diff --git a/Kinza/lib/Kinza.pm b/Kinza/lib/Kinza.pm index 0710a08..a14d1aa 100644 --- a/Kinza/lib/Kinza.pm +++ b/Kinza/lib/Kinza.pm @@ -37,6 +37,7 @@ my $dt_p = DateTime::Format::Strptime->new( my $now = DateTime->now(time_zone => 'Europe/London'); my $reg_live = $dt_p->parse_datetime($ENV{KZ_REG_OPEN}); my $sel_live = $dt_p->parse_datetime($ENV{KZ_SEL_OPEN}); +my $closed = $dt_p->parse_datetime($ENV{KZ_CLOSED}); my %private = map { $_ => 1 } qw[/submit]; my %open = map { $_ => 1, "$_/" => 1 } @@ -45,6 +46,9 @@ my %open = map { $_ => 1, "$_/" => 1 } my %reg_open = (%open, map { $_ => 1 } qw[/register]); hook before => sub { + if ($now > $closed && ! $open{request->path_info}) { + forward '/closed'; + } if ($now < $reg_live && ! $open{request->path_info}) { forward '/closed'; } @@ -77,7 +81,9 @@ hook before_template => sub { }; get '/closed' => sub { - if ($now < $reg_live) { + if ($now > $closed) { + return template 'closed'; + } elsif ($now < $reg_live) { return template 'comingsoon'; } else { return template 'sel_closed'; diff --git a/Kinza/views/closed.tt b/Kinza/views/closed.tt new file mode 100644 index 0000000..2d52e5c --- /dev/null +++ b/Kinza/views/closed.tt @@ -0,0 +1,2 @@ +

SCHS Kinza 2015/16

+

The Kinza registration site is now closed.