Skip to content

Commit

Permalink
Add ability to close the site.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Cross committed Sep 29, 2015
1 parent a4954ab commit 119946c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Kinza/lib/Kinza.pm
Expand Up @@ -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 }
Expand All @@ -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';
}
Expand Down Expand Up @@ -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';
Expand Down
2 changes: 2 additions & 0 deletions Kinza/views/closed.tt
@@ -0,0 +1,2 @@
<h1>SCHS Kinza 2015/16</h1>
<p>The Kinza registration site is now closed.</p>

0 comments on commit 119946c

Please sign in to comment.