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 != '' %] +
[% error | html %]
+[% END %]
-

Slogan

+

Slogan (optional)

-

Statement (WikiFormat)

+

Statement (WikiFormat)

[% END %] [% END %] [% PROCESS lib/footer %] [% PROCESS lib/html_bottom %] Index: user/des/fbce/root/run/register.tt =================================================================== --- user/des/fbce/root/run/register.tt (revision 333691) +++ user/des/fbce/root/run/register.tt (revision 333692) @@ -1,32 +1,35 @@ [%-# $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 %]

To register as a candidate in the election, enter the following information:

If you have a Gravatar, it will appear next to your statement.

-

Slogan

- +[% IF error %] +
[% error | html %]
+[% END %] +

Slogan (optional)

+

Statement (WikiFormat)

[% 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 %]

[% candidate.name | html %] ([% candidate.login %])

[% IF candidate.incumbent %]

(incumbent)

[% END %]
+[% IF candidate.statement.short %]

[% candidate.statement.short | wiki %]

+[% END %]
[% candidate.statement.long | wiki %]
[% END %] [% PROCESS lib/footer %] [% PROCESS lib/html_bottom %] Index: user/des/fbce/root/see/index.tt =================================================================== --- user/des/fbce/root/see/index.tt (revision 333691) +++ user/des/fbce/root/see/index.tt (revision 333692) @@ -1,25 +1,25 @@ [%-# $FreeBSD$ -%] [% PROCESS lib/html_top %] [% PROCESS lib/header %] [% WRAPPER lib/main %] [% IF nominating < 0 %]

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 %] [% END %] [% END %] [% PROCESS lib/footer %] [% PROCESS lib/html_bottom %]