svn commit: r333692 - in user/des/fbce: lib/FBCE/Controller root/run root/see

Dag-Erling Smørgrav des at FreeBSD.org
Wed May 16 23:10:21 UTC 2018


Author: des
Date: Wed May 16 23:10:19 2018
New Revision: 333692
URL: https://svnweb.freebsd.org/changeset/base/333692

Log:
  Allow a candidate to not provide a slogan, but display an error message
  if the statement is empty.

Modified:
  user/des/fbce/lib/FBCE/Controller/Run.pm
  user/des/fbce/root/run/edit.tt
  user/des/fbce/root/run/register.tt
  user/des/fbce/root/see/candidate.tt
  user/des/fbce/root/see/index.tt

Modified: user/des/fbce/lib/FBCE/Controller/Run.pm
==============================================================================
--- user/des/fbce/lib/FBCE/Controller/Run.pm	Wed May 16 22:32:08 2018	(r333691)
+++ user/des/fbce/lib/FBCE/Controller/Run.pm	Wed May 16 23:10:19 2018	(r333692)
@@ -45,13 +45,15 @@ sub register :Local :Args(0) {
 	$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});
@@ -76,11 +78,13 @@ sub edit :Local :Args(0) {
 	$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);

Modified: user/des/fbce/root/run/edit.tt
==============================================================================
--- user/des/fbce/root/run/edit.tt	Wed May 16 22:32:08 2018	(r333691)
+++ user/des/fbce/root/run/edit.tt	Wed May 16 23:10:19 2018	(r333692)
@@ -8,10 +8,13 @@
 [% IF !user.active %]
 <p>You are not qualified to run in the election.  If you believe this is incorrect, please contact the election administrator.</p>
 [% ELSIF nominating == 0 %]
+[% IF error != '' %]
+  <div class="error">[% error | html %]</div>
+[% END %]
 <form method="post" action="">
-  <p>Slogan</p>
+  <p>Slogan (optional)</p>
   <input name="short" size="80" maxlength="64" value="[% short | html %]"/>
-  <p>Statement (<a href="http://search.cpan.org/~chromatic/Text-WikiFormat-0.79/lib/Text/WikiFormat.pm#Wiki_Format">WikiFormat</a>)</p> 
+  <p>Statement (<a href="http://search.cpan.org/~chromatic/Text-WikiFormat-0.81/lib/Text/WikiFormat.pm#Wiki_Format">WikiFormat</a>)</p> 
   <textarea name="long" cols="80" rows="24">[% long | html %]</textarea>
   </fieldset>
   <div>

Modified: user/des/fbce/root/run/register.tt
==============================================================================
--- user/des/fbce/root/run/register.tt	Wed May 16 22:32:08 2018	(r333691)
+++ user/des/fbce/root/run/register.tt	Wed May 16 23:10:19 2018	(r333692)
@@ -15,8 +15,11 @@
 </ul>
 <p>If you have a <a href="http://en.gravatar.com/">Gravatar</a>, it will appear next to your statement.</p>
 <form method="post" action="">
-  <p>Slogan</p>
-  <input name="short" size="80" maxlength="64" value="[% short | html %]"/>
+[% IF error %]
+  <div class="error">[% error | html %]</div>
+[% END %]
+  <p>Slogan (optional)</p>
+  <input name="short" size="64" maxlength="64" value="[% short | html %]"/>
   <p>Statement (<a href="http://search.cpan.org/~cycles/Text-WikiFormat-0.81/lib/Text/WikiFormat.pm#Wiki_Format">WikiFormat</a>)</p>
   <textarea name="long" cols="80" rows="24">[% long | html %]</textarea>
   <div>

Modified: user/des/fbce/root/see/candidate.tt
==============================================================================
--- user/des/fbce/root/see/candidate.tt	Wed May 16 22:32:08 2018	(r333691)
+++ user/des/fbce/root/see/candidate.tt	Wed May 16 23:10:19 2018	(r333692)
@@ -10,7 +10,9 @@
 [% IF candidate.incumbent %]<p class="candidate-incumbent">(incumbent)</p>[% END %]
 </div>
 <div class="statement">
+[% IF candidate.statement.short %]
   <h3 class="statement-title">[% candidate.statement.short | wiki %]</h3>
+[% END %]
   <div class="statement-body">
     [% candidate.statement.long | wiki %]
   </div>

Modified: user/des/fbce/root/see/index.tt
==============================================================================
--- user/des/fbce/root/see/index.tt	Wed May 16 22:32:08 2018	(r333691)
+++ user/des/fbce/root/see/index.tt	Wed May 16 23:10:19 2018	(r333692)
@@ -15,7 +15,7 @@
 [% END %]
 <ul>
   [% WHILE (candidate = candidates.next) %]
-  <li>[% candidate.name | html %][% IF candidate.incumbent %] (incumbent)[% END %]: <a href="[% c.uri_for('/see/candidate', candidate.login) | html %]">[% candidate.statement.short | html %]</a></li>
+  <li>[% candidate.name | html %][% IF candidate.incumbent %] (incumbent)[% END %]: <a href="[% c.uri_for('/see/candidate', candidate.login) | html %]">[% IF candidate.statement.short %][% candidate.statement.short | html %][% ELSE %]see statement[% END %]</a></li>
   [% END %]
 </ul>
 [% END %]


More information about the svn-src-user mailing list