From owner-svn-src-user@FreeBSD.ORG Thu Apr 17 11:57:12 2014 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9E196DE9; Thu, 17 Apr 2014 11:57:12 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 719C011A3; Thu, 17 Apr 2014 11:57:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s3HBvC5x015006; Thu, 17 Apr 2014 11:57:12 GMT (envelope-from des@svn.freebsd.org) Received: (from des@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s3HBvCXv015004; Thu, 17 Apr 2014 11:57:12 GMT (envelope-from des@svn.freebsd.org) Message-Id: <201404171157.s3HBvCXv015004@svn.freebsd.org> From: Dag-Erling Smørgrav Date: Thu, 17 Apr 2014 11:57:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r264595 - in user/des/fbp: lib/FBP/Controller root/poll X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Apr 2014 11:57:12 -0000 Author: des Date: Thu Apr 17 11:57:11 2014 New Revision: 264595 URL: http://svnweb.freebsd.org/changeset/base/264595 Log: Add a result page. Added: user/des/fbp/root/poll/result.tt (contents, props changed) Modified: user/des/fbp/lib/FBP/Controller/Poll.pm Modified: user/des/fbp/lib/FBP/Controller/Poll.pm ============================================================================== --- user/des/fbp/lib/FBP/Controller/Poll.pm Thu Apr 17 11:56:38 2014 (r264594) +++ user/des/fbp/lib/FBP/Controller/Poll.pm Thu Apr 17 11:57:11 2014 (r264595) @@ -232,6 +232,29 @@ sub done :Chained('poll') :Path :Args(0) delete($c->session->{$pid}); } +=head2 result + +Show results. + +=cut + +sub result :Chained('poll') :Path :Args(0) { + my ($self, $c) = @_; + + my $poll = $c->stash->{poll}; + $c->detach('/default') + unless ($c->user->admin || $poll->ended); + my $questions = $poll->questions; + foreach my $question ($questions->all) { + $c->log->debug("Question " . $question->id); + my $options = $question->options; + foreach my $option ($options->all) { + $c->log->debug("Option " . $option->id . ": " . $option->label); + $c->log->debug("Votes: " . $option->votes->count); + } + } +} + =head2 default Default page. Added: user/des/fbp/root/poll/result.tt ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/des/fbp/root/poll/result.tt Thu Apr 17 11:57:11 2014 (r264595) @@ -0,0 +1,45 @@ +[%-# $FreeBSD$ -%] +[% USE WikiFormat %] +[% PROCESS lib/html_top %] +[% PROCESS lib/header %] +[% WRAPPER lib/main %] + +
+
+[% poll.synopsis | wiki %] +
+[% IF error %] +
+

[% error | html %]

+
+[% ELSIF now < poll.starts %] +

This poll has not started yet.

+[% ELSIF poll.votes_rs.count == 0 %] +

No votes have been cast yet.

+[% ELSE %] +

Here are the[% IF now < poll.ends %] preliminary[% END %] results of the poll:

+[% FOREACH question IN poll.questions %] +[% qid = question.id %] +
+[% question.short | wiki %] +
+ + + + + + +[% FOREACH option IN question.options %] + + + + +[% END %] +
OptionVotesPercentage
[% option.label | html %][% IF option.votes_rs.count > 0 %][% option.votes_rs.count %][% ELSE %]-[% END %][% IF option.votes_rs.count > 0 && question.votes_rs.count > 0 %][% option.votes_rs.count * 100 / question.votes_rs.count %]%[% ELSE %]-[% END %]
+[% END %] +[% END %] +
+ +[% END %] +[% PROCESS lib/footer %] +[% PROCESS lib/html_bottom %]