Greetings, all!

The elections for {{ election.shortdesc }} have concluded, and the results
are shown below.

XXX is electing {{ election.seats_elected }} seats this time.
A total of {{stats['n_voters'] }} ballots were cast, meaning a candidate
could accumulate up to {{ stats['n_voters'] * stats['max_vote'] }} votes ({{stats['n_voters'] }} * {{ stats['max_vote'] }}).

The results for the elections are as follows:

  # votes |  name
- --------+----------------------{%
for candidate in election.candidates|sort(attribute='vote_count', reverse=True) -%}
  {% if loop.index <= election.seats_elected -%}
        {# If we are below the number of user that will be selected,
          get the number of votes and the flag to False -#}
    {% set flag = False -%}
    {% set votes = candidate.vote_count -%}
  {%- elif loop.index > election.seats_elected and votes > candidate.vote_count and not flag -%}
    {# if we are above the number of user that will be selected (seats
      available), check if the number of votes for this candidate is lower
      than the number of votes for the last candidate and if the Flag is
      False.
      So this takes care of the case where there are 10 seats elected and
      the 11th candidate has the same score as the 10th one.
      In this case we would end up with one more person that the number of
      seats available and we'll need to either find a way to select one
      over the other or deal with having one more candidate accepted -#}
    {% set flag = True -%}
    {% set lastrow = True -%}
  {%- else -%}
    {# we are above the number of seats available, the number of votes is
      below that of the last candidate above selected and the Flag is True
      which means we already passed the condition above -#}
    {% set lastrow = False -%} {%- endif %}{% if lastrow == True %}
- --------+---------------------- {%- endif %}
{{ candidate.vote_count | rjust(8) }}  | {% if election.candidates_are_fasusers -%}
      {{ usernamemap[candidate.id] }} {%- else -%} {{candidate.name}}
    {%- endif %}
{%- endfor %}


Congratulations to the winning candidates, and thank you all
candidates for running this elections!