Index: user/des/fbce/fbce.conf =================================================================== --- user/des/fbce/fbce.conf (revision 235759) +++ user/des/fbce/fbce.conf (revision 235760) @@ -1,29 +1,30 @@ # $FreeBSD$ title = 2012 FreeBSD Core Team Election dsn = "dbi:Pg:dbname=dbname" user = "user" password = "password" nominating_starts = 2012-05-23 00:00:00 UTC nominating_ends = 2012-05-30 00:00:00 UTC voting_starts = 2012-05-30 00:00:00 UTC voting_ends = 2012-06-27 00:00:00 UTC announcement = 2012-06-27 18:00:00 UTC investiture = 2012-07-04 # XXX does not belong here max_votes = 9 + cutoff = 1 year expires = 1800 cookie_expires = 0 # cookie_secure = true cache_size = 8m Index: user/des/fbce/lib/FBCE/Model/Schedule.pm =================================================================== --- user/des/fbce/lib/FBCE/Model/Schedule.pm (revision 235759) +++ user/des/fbce/lib/FBCE/Model/Schedule.pm (revision 235760) @@ -1,115 +1,123 @@ package FBCE::Model::Schedule; use Moose; use MooseX::Types::Common::Numeric qw(PositiveInt); -use MooseX::Types::DateTime::MoreCoercions qw(DateTime); +use MooseX::Types::DateTime::MoreCoercions qw(DateTime Duration); use DateTime; use namespace::autoclean; BEGIN { extends 'Catalyst::Component' } =head1 NAME FBCE::Controller - Catalyst Controller =head1 DESCRIPTION Catalyst Controller. =cut has nominating_starts => ( isa => DateTime, coerce => 1, is => 'ro', required => 1 ); has nominating_ends => ( isa => DateTime, coerce => 1, is => 'ro', required => 1 ); has voting_starts => ( isa => DateTime, coerce => 1, is => 'ro', required => 1 ); has voting_ends => ( isa => DateTime, coerce => 1, is => 'ro', required => 1 ); has announcement => ( isa => DateTime, coerce => 1, is => 'ro', required => 1 ); has investiture => ( isa => DateTime, coerce => 1, is => 'ro', required => 1 ); # XXX does not belong here has max_votes => ( isa => PositiveInt, is => 'ro', required => 1 +); + +# XXX does not belong here +has cutoff => ( + isa => Duration, + coerce => 1, + is => 'ro', + required => 1, ); sub _phase($$$) { my ($self, $phase, $now) = @_; $now //= main::DateTime->now(); my ($starts, $ends) = ("${phase}_starts", "${phase}_ends"); my ($st, $et) = ($self->{$starts}, $self->{$ends}); if (main::DateTime->compare($now, $st) < 0) { return -1; } elsif (main::DateTime->compare($now, $et) < 0) { return 0; } else { return 1; } } sub nominating($;$) { my ($self, $now) = @_; return $self->_phase('nominating', $now); } sub voting($;$) { my ($self, $now) = @_; return $self->_phase('voting', $now); } sub announced($;$) { my ($self, $now) = @_; return (main::DateTime->compare($now, $self->{'announcement'}) > 0); } =head1 AUTHOR Dag-Erling Smørgrav =head1 LICENSE This library is free software. You can redistribute it and/or modify it under the same terms as Perl itself. =cut __PACKAGE__->meta->make_immutable; 1;