Index: user/des/fbce/lib/FBCE/Controller/Run.pm =================================================================== --- user/des/fbce/lib/FBCE/Controller/Run.pm (revision 333691) +++ user/des/fbce/lib/FBCE/Controller/Run.pm (revision 333692) @@ -1,129 +1,133 @@ package FBCE::Controller::Run; use Moose; use namespace::autoclean; BEGIN { extends 'Catalyst::Controller' } =head1 NAME FBCE::Controller::Run - Catalyst Controller =head1 DESCRIPTION Catalyst Controller. =head1 METHODS =cut =head2 index =cut sub index :Path :Args(0) { my ($self, $c) = @_; my $user = $c->user->get_object(); $c->stash(user => $user); } sub register :Local :Args(0) { my ($self, $c) = @_; my $user = $c->user->get_object(); if ($c->stash->{'nominating'} != 0 || !$user->active) { $c->res->redirect($c->uri_for('/run')); $c->detach(); } $c->stash(user => $user); if ($user->statement) { $c->res->redirect($c->uri_for('/run/edit')); $c->detach(); } my $p = $c->req->params; if ($p->{cancel}) { $c->res->redirect($c->uri_for('/run')); $c->detach(); } - if ($p->{submit}) { + if ($p->{submit} && $p->{long}) { my $stmt = $c->model('FBCE::Statement')-> new({ person => $user, short => $p->{short}, long => $p->{long} }); $stmt->insert() or die("failed to register"); $c->res->redirect($c->uri_for('/run')); $c->detach(); + } elsif ($p->{submit}) { + $c->stash(error => "You must provide a stamement!"); } $c->stash(short => $p->{short}); $c->stash(long => $p->{long}); } sub edit :Local :Args(0) { my ($self, $c) = @_; my $user = $c->user->get_object(); if ($c->stash->{'nominating'} != 0 || !$user->active) { $c->res->redirect($c->uri_for('/run')); $c->detach(); } $c->stash(user => $user); if (!$user->statement) { $c->res->redirect($c->uri_for('/run/register')); $c->detach(); } my $p = $c->req->params; if ($p->{cancel}) { $c->res->redirect($c->uri_for('/run')); $c->detach(); } my $statement = $user->statement; - if ($p->{submit}) { + if ($p->{submit} && $p->{long}) { $statement->update({ short => $p->{short}, long => $p->{long} }) or die("failed to update"); $c->res->redirect($c->uri_for('/run')); $c->detach(); + } elsif ($p->{submit}) { + $c->stash(error => "You must provide a stamement!"); } $c->stash(short => $p->{short} // $statement->short); $c->stash(long => $p->{long} // $statement->long); } sub withdraw :Local :Args(0) { my ($self, $c) = @_; my $user = $c->user->get_object(); if ($c->stash->{'nominating'} != 0 || !$user->active) { $c->res->redirect($c->uri_for('/run')); $c->detach(); } $c->stash(user => $user); if (!$user->statement) { $c->res->redirect($c->uri_for('/run')); $c->detach(); } my $p = $c->req->params; if ($p->{cancel}) { $c->res->redirect($c->uri_for('/run')); $c->detach(); } my $statement = $user->statement; if ($p->{submit}) { $statement->delete() or die("failed to delete"); $c->res->redirect($c->uri_for('/run')); $c->detach(); } } =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; Index: user/des/fbce/root/run/edit.tt =================================================================== --- user/des/fbce/root/run/edit.tt (revision 333691) +++ user/des/fbce/root/run/edit.tt (revision 333692) @@ -1,27 +1,30 @@ [%-# $FreeBSD$ -%] [% PROCESS lib/html_top %] [% PROCESS lib/header %] [% WRAPPER lib/main %] [% PROCESS run/when %] [% IF !user.active %]
You are not qualified to run in the election. If you believe this is incorrect, please contact the election administrator.
[% ELSIF nominating == 0 %] +[% IF error != '' %] +You are not qualified to run in the election. If you believe this is incorrect, please contact the election administrator.
[% ELSIF nominating == 0 %]To register as a candidate in the election, enter the following information:
If you have a Gravatar, it will appear next to your statement.
[% END %] [% END %] [% PROCESS lib/footer %] [% PROCESS lib/html_bottom %] Index: user/des/fbce/root/see/candidate.tt =================================================================== --- user/des/fbce/root/see/candidate.tt (revision 333691) +++ user/des/fbce/root/see/candidate.tt (revision 333692) @@ -1,21 +1,23 @@ [%-# $FreeBSD$ -%] [% USE WikiFormat %] [% PROCESS lib/html_top %] [% PROCESS lib/header %] [% WRAPPER lib/main %](incumbent)
[% END %]The nomination period starts on [% INCLUDE lib/datetime dt=nominating_starts %].
[% ELSIF candidates.count == 0 %]There are no candidates yet.
[% ELSE %] [% IF candidates.count == 1 %]The following person has registered as a candidate in the election:
[% ELSE %]The following [% candidates.count %] people have registered as candidates in the election:
[% END %]