On Sun, Aug 04, 2013 at 10:00:05PM +0200, Florian Pritz wrote:
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@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) { ... }
Yes, I didn't do it like this in the first place because everything else directly uses $row[] and inline computations. If we want to do it right, we refactor the current code, set $yes, $no, etc. at the beginning of the file, then add the $vote_accepted conditions in a second patch (a rebased version of this one, basically). It's a routine piece of work... I might do it tomorrow.
+ <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.
We do not indent these throughout the whole code base. Not changing this here since having different styles is even more questionable than not indenting. And unfortunately, I do not have the time to refactor all of them now...
</p>
<p>