[aur-dev] [PATCH 3/3] tu_details.php: Display vote result

Florian Pritz bluewind at xinu.at
Sun Aug 4 16:00:05 EDT 2013


On 04.08.2013 17:43, Lukas Fleischer wrote:
> This adds an field that indicates whether the vote was accepted or
> rejected, based on the rules specified in the TU Bylaws.
> 
> Signed-off-by: Lukas Fleischer <archlinux at cryptocrack.de>
> ---
>  web/template/tu_details.php | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/web/template/tu_details.php b/web/template/tu_details.php
> index 4f291f0..6ed6efd 100644
> --- a/web/template/tu_details.php
> +++ b/web/template/tu_details.php
> @@ -21,6 +21,17 @@
>  		<br />
>  		<?= __("End") ?>:
>  		<strong><?= gmdate("Y-m-d H:i", $row['End']) ?></strong>
> +		<?php if ($isrunning == 0): ?>
> +		<br />
> +		<?= __("Result") ?>:
> +		<?php if ($row['Quorum'] == 0): ?>
> +		<span><?= __("unknown") ?></span>
> +		<?php elseif (($row['Yes'] > $row['ActiveTUs'] / 2) || (($row['Yes'] + $row['No'] + $row['Abstain']) / $row['ActiveTUs'] >= $row['Quorum'] && $row['Yes'] > $row['No'])): ?>

This is rather long and probably better written this way:

$yes = $row["Yes"];
$active = $row["ActiveTUs"];
$no = $row["No"];
$abstain = $row["Abstain"];
$quorum = $row["Quorum"];

$total = $yes + $no + $abstain;

$vote_accepted = false;

if ($yes > $active / 2) {
	$vote_accepted = true;
}

if ($total / $active >= $quorum && $yes > $no) {
	$vote_accepted = true;
}

if ($vote_accepted) {
	...
}

> +		<span style="color: green; font-weight: bold"><?= __("Accepted") ?></span>
> +		<?php else: ?>
> +		<span style="color: red; font-weight: bold"><?= __("Rejected") ?></span>
> +		<?php endif; ?>
> +		<?php endif; ?>

Also the inner if is not indented so the endifs end up at the same
level. I don't care about indentation in the resulting HTML, ymmv.

>  	</p>
>  
>  	<p>
> 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mailman.archlinux.org/pipermail/aur-dev/attachments/20130804/ed50797d/attachment.asc>


More information about the aur-dev mailing list