Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin'
Browse files Browse the repository at this point in the history
  • Loading branch information
helgihg committed Jul 11, 2018
2 parents 1a1d9da + ceb2c8d commit 7ea9d24
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 28 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ The 3rd step will populate the database with a small amount of random data, incl

That should be it!

#### Docker Compose

If you have `docker-compose` installed you should only need these 1-2 commands:

Start web + db containers:
`docker-compose up`

Run database migrations (if needed):
`docker-compose run wasaweb python manage.py migrate`

### Manual installation using pip

If you run into errors manually installing with `pip` (or get error output from `pip` wile running `initial_setup.py`), more often than not it's due to you not having MySQL installed. Try commenting those lines out of the `requirements.txt` file and running pip again.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.10.12
0.10.13
38 changes: 21 additions & 17 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,25 @@
# docker-compose up
# Then migrate the database: (you might need to run it twice)
# docker-compose run wasaweb python manage.py migrate
version: '2'

wasaweb:
build: .
volumes:
- .:/usr/src/app
ports:
- "8000:8000"
links:
- "db"
environment:
- DOCKER_DB_HOST=db
db:
image: mysql
environment:
- MYSQL_ROOT_PASSWORD=docker
- MYSQL_DATABASE=docker
- MYSQL_USER=docker
- MYSQL_PASSWORD=docker
services:
wasaweb:
build: .
volumes:
- .:/usr/src/app
ports:
- "8000:8000"
links:
- "db"
environment:
- DOCKER_DB_HOST=db
depends_on:
- db
db:
image: mysql:5
environment:
- MYSQL_ROOT_PASSWORD=docker
- MYSQL_DATABASE=docker
- MYSQL_USER=docker
- MYSQL_PASSWORD=docker
20 changes: 20 additions & 0 deletions election/migrations/0010_auto_20180705_2005.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.13 on 2018-07-05 20:05
from __future__ import unicode_literals

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('election', '0009_auto_20171201_1340'),
]

operations = [
migrations.RenameField(
model_name='election',
old_name='stats_limit',
new_name='results_limit',
),
]
20 changes: 20 additions & 0 deletions election/migrations/0011_auto_20180711_2207.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.13 on 2018-07-11 22:07
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('election', '0010_auto_20180705_2005'),
]

operations = [
migrations.AlterField(
model_name='election',
name='results_limit',
field=models.IntegerField(blank=True, null=True, verbose_name='How many candidates will be publicly listed in the results of an election'),
),
]
14 changes: 11 additions & 3 deletions election/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ class Election(models.Model):
# should to be turned into a proper Django model.
results_are_ordered = models.BooleanField(default=True, verbose_name=_('Results are ordered'))

# How many candidates will be publicly listed in the results of an
# election. Officers still see entire list. Individual candidates can also
# see where they ended up in the results.
results_limit = models.IntegerField(
null=True,
blank=True,
verbose_name=_('How many candidates will be publicly listed in the results of an election')
)

deadline_candidacy = models.DateTimeField(verbose_name=_('Deadline for candidacies'))
starttime_votes = models.DateTimeField(null=True, blank=True, verbose_name=_('Election begins'))
deadline_votes = models.DateTimeField(verbose_name=_('Election ends'))
Expand All @@ -60,7 +69,6 @@ class Election(models.Model):

# These are election statistics;
stats = models.TextField(null=True, blank=True, verbose_name=_('Statistics as JSON'))
stats_limit = models.IntegerField(null=True, blank=True, verbose_name=_('Limit how many candidates we publish stats for'))
stats_publish_ballots_basic = models.BooleanField(default=False, verbose_name=_('Publish basic ballot statistics'))
stats_publish_ballots_per_candidate = models.BooleanField(default=False, verbose_name=_('Publish ballot statistics for each candidate'))
stats_publish_files = models.BooleanField(default=False, verbose_name=_('Publish advanced statistics (downloadable)'))
Expand Down Expand Up @@ -309,11 +317,11 @@ def get_stats(self, user=None, load_users=True, rename_users=False):

# Censor the statistics, if we only want to publish details about
# the top N candidates.
if self.stats_limit:
if self.results_limit:
excluded = set([])
if not user or not user.is_staff:
excluded |= set(cand.user.username for cand in
self.get_winners()[self.stats_limit:])
self.get_winners()[self.results_limit:])
if user and user.username in excluded:
excluded.remove(user.username)
stats = BallotCounter.exclude_candidate_stats(stats, excluded)
Expand Down
10 changes: 7 additions & 3 deletions wasa2il/templates/accounts/personal_data.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@ <h2>{% trans 'Terms and Conditions' %}</h2>
<p>{% trans 'Here you can retrieve the latest version of our terms and conditions to which you have provided your consent. There you should find anything you might need regarding to your personal data, including why and how we process it. If not, please let us know!' %}</p>

<p>
<a href="{% url 'tc_view_specific_version_page' terms.slug terms.version_number %}" class="btn btn-default" role="button">
{% trans 'Show terms and conditions' %}
</a>
{% if terms %}
<a href="{% url 'tc_view_specific_version_page' terms.slug terms.version_number %}" class="btn btn-default" role="button">
{% trans 'Show terms and conditions' %}
</a>
{% else %}
<span class="label label-warning">{% trans 'No terms and conditions provided yet.' %}</span>
{% endif %}
</p>
</div>

Expand Down
8 changes: 4 additions & 4 deletions wasa2il/templates/election/election_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ <h2>{% trans 'Election results' %}</h2>
<div id="election_candidates_winners" style="margin-top: 1em;">
<ol class="candidates" id="candidates_winners" {% if not election.results_are_ordered %}style="list-style: none; padding-left: 0px;"{% endif %}>
{% for candidate in ordered_candidates %}
{% if not election.stats_limit or forloop.counter <= election.stats_limit or candidate.user == user or user.is_staff %}
<li data-seqid="{{ candidate.id }}"{% if election.stats_limit and forloop.counter > election.stats_limit %} style="background: #efe;"{% endif %}>
{% if not election.results_limit or forloop.counter <= election.results_limit or candidate.user == user or user.is_staff %}
<li data-seqid="{{ candidate.id }}"{% if election.results_limit and forloop.counter > election.results_limit %} style="background: #efe;"{% endif %}>
<div style="position: relative;">
<img src="{{ candidate.user.userprofile.picture|thumbnail:'50x50' }}" class="img-rounded vote-image" />
<a href="/accounts/profile/{{ candidate.user.username }}/">{{ candidate.user.get_name }}</a>
Expand All @@ -226,7 +226,7 @@ <h2>{% trans 'Election results' %}</h2>
{% endwith %}
</div>
{% endif %}
{% if election.stats_limit and forloop.counter > election.stats_limit %}
{% if election.results_limit and forloop.counter > election.results_limit %}
<tt style="font-size: 0.5em; position: absolute; right: 2px; bottom: 1px;">{% trans "for your eyes only" %}</tt>
{% endif %}
</div>
Expand Down Expand Up @@ -260,7 +260,7 @@ <h2>{% trans 'Election results' %}</h2>
<a href="stats-dl/election-{{ election.id }}-stats.xlsx">XLS</a><br>
<small style="display: inline-block; width: 50%;">
{% trans "Downloads include rankings, pairwise victories and ballot counts." %}
{% if election.stats_limit %}{% with election.stats_limit as limit %}{% blocktrans %}
{% if election.results_limit %}{% with election.results_limit as limit %}{% blocktrans %}
Details below {{limit}}. place are omitted except for
the candidates themselves and members of staff.
{% endblocktrans %}{% endwith %}{% endif %}
Expand Down

0 comments on commit 7ea9d24

Please sign in to comment.