Skip to content

Commit

Permalink
Merge pull request #384 from dinukadesilva/fix-print-settings-in-all-…
Browse files Browse the repository at this point in the history
…island-ed

Fix print settings in all island ed
  • Loading branch information
dinukadesilva authored Nov 18, 2019
2 parents f666763 + 443617a commit 4d5bcad
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from orm.entities.SubmissionVersion import TallySheetVersion
from orm.entities.TallySheetVersionRow import TallySheetVersionRow_PRE_ALL_ISLAND_RESULTS_BY_ELECTORAL_DISTRICTS, \
TallySheetVersionRow_RejectedVoteCount
from util import to_comma_seperated_num, sqlalchemy_num_or_zero
from util import to_comma_seperated_num, sqlalchemy_num_or_zero, to_percentage
from orm.enums import TallySheetCodeEnum, AreaTypeEnum
from sqlalchemy import and_

Expand Down Expand Up @@ -267,6 +267,11 @@ def get_html_content_dict(self):
content["rejectedVoteCounts"].append(to_comma_seperated_num(vote_count_result.rejectedVoteCount))
content["totalVoteCounts"].append(to_comma_seperated_num(vote_count_result.totalVoteCount))

# Append the percentages.
content["validVoteCounts"].append(to_percentage(vote_count_result.validVoteCount * 100 / vote_count_result.totalVoteCount))
content["rejectedVoteCounts"].append(to_percentage(vote_count_result.rejectedVoteCount * 100 / vote_count_result.totalVoteCount))
content["totalVoteCounts"].append(to_percentage(100))

number_of_electoral_districts = len(area_wise_vote_count_result)
number_of_candidates = len(candidate_wise_vote_count_result)

Expand Down Expand Up @@ -296,6 +301,9 @@ def get_html_content_dict(self):

data_row.append(to_comma_seperated_num(candidate_wise_vote_count_result_item.validVoteCount))

candidate_wise_vote_count_percentage = (candidate_wise_vote_count_result_item.validVoteCount/vote_count_result.validVoteCount) * 100
data_row.append(to_percentage(candidate_wise_vote_count_percentage))

content["data"].append(data_row)

return content
Expand Down
51 changes: 45 additions & 6 deletions templates/PRE_ALL_ISLAND_RESULTS_BY_ELECTORAL_DISTRICTS.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
{% extends 'base.html' %}

{% block container %}
<style>
@media print{
@page {
/*size: 16.5in 11.7in;*/
size: 40in 28.36in
}
}

.table td, .table th {
padding: 8px;
font-size: 20px;
}

.table td, .table th {
padding: 8px;
font-size: 20px;
}

.pre-all-ed .ed th div,
.pre-all-ed th.percentage-th div
{
-moz-transform: rotate(-90.0deg);
-o-transform: rotate(-90.0deg);
-webkit-transform: rotate(-90.0deg);
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=0.083);
-ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=0.083)";
margin-top: 100px;
white-space: nowrap;
}
</style>
<div class="pre-all-ed">
<div style="text-align: center; margin-bottom: 10px;">
<b>{{content.election.electionName}}</b>
Expand All @@ -16,13 +46,17 @@
<tbody>

<tr>
<th class="left right top bottom" rowspan="2" style="width:200px">
<th class="left right top bottom" rowspan="2" style="width:40px" ># </th>
<th class="left right top bottom" rowspan="2" style="width:500px">
Name of the Candidate (According to the order in the Ballot Paper)
</th>
<th class="left right top bottom" colspan="{{content.electoralDistricts|length}}" style="width:{{content.electoralDistricts|length * 100}}px;">
<th class="left right top bottom" colspan="{{content.electoralDistricts|length}}" style="width:{{content.electoralDistricts|length * 110}}px;">
ELECTORAL DISTRICT {{ed_column_width}}
</th>
<th class="left right top bottom" rowspan="2" style="width:100px">TOTAL</th>
<th class="left right top bottom" rowspan="2" style="width:150px">TOTAL</th>
<th class="left right top bottom percentage-th" rowspan="2" style="width:100px">
<div>Percentage</div>
</th>
<th class="left right top bottom" rowspan="2" style="width:170px">TOTAL NUMBER OF VOTES IN WORDS</th>
</tr>
<tr class="ed">
Expand All @@ -33,6 +67,7 @@

{% for row in content.data %}
<tr>
<td class="left right top bottom">{{loop.index}}</td>
{% for cell in row %}
<td class="left right top bottom {%if cell=="" %}missing-value{% endif %}" style="text-align:right">{{cell}}</td>
{% endfor %}
Expand All @@ -41,23 +76,27 @@
{% endfor %}

<tr>
<td class="left right top bottom">NO OF VALID VOTES</td>
<th colspan="{{content.electoralDistricts|length + 5}}"></th>
</tr>

<tr>
<th class="left right top bottom" colspan="2">NO OF VALID VOTES</th>
{% for validVoteCount in content.validVoteCounts %}
<td class="left right top bottom {%if validVoteCount=="" %}missing-value{% endif %}" style="text-align:right">{{validVoteCount}}</td>
{% endfor %}
<td class="left right top bottom" style="vertical-align: middle;"></td>
</tr>

<tr>
<td class="left right top bottom">NO OF REJECTED VOTES</td>
<th colspan="2" class="left right top bottom">NO OF REJECTED VOTES</th>
{% for rejectedVoteCount in content.rejectedVoteCounts %}
<td class="left right top bottom {%if rejectedVoteCount=="" %}missing-value{% endif %}" style="text-align:right">{{rejectedVoteCount}}</td>
{% endfor %}
<td class="left right top bottom" style="vertical-align: middle;"></td>
</tr>

<tr>
<td class="left right top bottom">TOTAL NO OF VOTES POLLED (INCLUDING REJECTED VOTES)</td>
<th colspan="2" class="left right top bottom">TOTAL NO OF VOTES POLLED (INCLUDING REJECTED VOTES)</th>
{% for totalVoteCount in content.totalVoteCounts %}
<td class="left right top bottom {%if totalVoteCount=="" %}missing-value{% endif %}" style="text-align:right">{{totalVoteCount}}</td>
{% endfor %}
Expand Down

0 comments on commit 4d5bcad

Please sign in to comment.