Skip to content

Commit

Permalink
Merge pull request #8 from bencrealc/master
Browse files Browse the repository at this point in the history
Merge grupo 2 decide penyagolosa
  • Loading branch information
bencrealc authored Jan 6, 2022
2 parents d550c48 + d760a83 commit 838aa1d
Show file tree
Hide file tree
Showing 30 changed files with 458 additions and 19 deletions.
23 changes: 23 additions & 0 deletions .github/issue_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Title: Summary, imperative, start upper case, don't end with a period
# No more than 50 chars. #### 50 chars is here: #

# Remember blank line between title and body.

# Body: Explain *what* and *why* (not *how*).
# Wrap at 72 chars. ################################## which is here: #


# At the end: Include Co-authored-by for all contributors.
# Include at least one empty line before it. Format:
# Co-authored-by: name <user@users.noreply.github.com>
#
# How to Write a Git Commit Message:
# https://chris.beams.io/posts/git-commit/
#
# 1.Separate subject from body with a blank line
# 2. Limit the subject line to 50 characters
# 3. Capitalize the subject line
# 4. Do not end the subject line with a period
# 5. Use the imperative mood in the subject line
# 6. Wrap the body at 72 characters
# 7. Use the body to explain what and why vs. how
42 changes: 42 additions & 0 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Python application

on: [push]

jobs:
build:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:10.8
env:
POSTGRES_USER: decide
POSTGRES_PASSWORD: decide
POSTGRES_DB: decide
ports:
- 5432:5432
# needed because the postgres container does not provide a healthcheck
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5

steps:
- uses: actions/checkout@v1
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: psycopg2 prerequisites
run: sudo apt-get install libpq-dev
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install codacy-coverage
- name: Run migrations
run: cd decide;python manage.py migrate
- name: Run tests
run: cd decide;coverage run --branch --source=. ./manage.py test voting --keepdb; coverage xml;
- name: Codacy Coverage Reporter
uses: codacy/codacy-coverage-reporter-action@v1.1.0
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: decide/coverage.xml
2 changes: 1 addition & 1 deletion decide/booth/templates/booth/booth.html
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,4 @@ <h2>[[ voting.question.desc ]]</h2>
})
</script>
</body>
{% endblock %}
{% endblock %}
27 changes: 27 additions & 0 deletions decide/booth/templates/booth/votings.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% extends "base.html" %}
{% load i18n static %}

{% block content %}
<link rel="stylesheet" href="/static/css/style.css">
<table>
<tr>
<th>Name</th>
<th>Start Date</th>
<th>Vote</th>
</tr>

{% for v in votings %}
<tr>
<td>{{v.name}}</td>
{% if v.start_date is None %}
<td>It's not started</td>
{% else %}
<td>{{v.start_date}}</td>
{% endif %}
<td><a href='/booth/{{v.id}}/'>Vote</a></td>
</tr>
{% endfor %}

</table>

{% endblock %}
3 changes: 2 additions & 1 deletion decide/booth/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from django.urls import path
from .views import BoothView

from . import views

urlpatterns = [
path('<int:voting_id>/', BoothView.as_view()),
path('voting', views.votings),
]
8 changes: 8 additions & 0 deletions decide/booth/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
from django.views.generic import TemplateView
from django.conf import settings
from django.http import Http404
from voting.models import Voting
from django.shortcuts import render, redirect

from base import mods



# TODO: check permissions and census
class BoothView(TemplateView):
template_name = 'booth/booth.html'
Expand All @@ -29,3 +32,8 @@ def get_context_data(self, **kwargs):
context['KEYBITS'] = settings.KEYBITS

return context

def votings(request):
votings = Voting.objects.exclude(end_date__isnull = False)
return render(request, 'booth/votings.html', {'votings': votings})

2 changes: 1 addition & 1 deletion decide/decide/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
'voting',
]

BASEURL = 'http://localhost:8000'
BASEURL = 'http://localhost:8000/'

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
Expand Down
2 changes: 2 additions & 0 deletions decide/decide/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from django.contrib import admin
from django.urls import path, include
from rest_framework_swagger.views import get_swagger_view
from django.contrib.staticfiles.urls import staticfiles_urlpatterns


schema_view = get_swagger_view(title='Decide API')
Expand All @@ -31,3 +32,4 @@
urlpatterns += [
path('{}/'.format(module), include('{}.urls'.format(module)))
]
urlpatterns+= staticfiles_urlpatterns()
6 changes: 1 addition & 5 deletions decide/test-scripts/js/index.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
<!--
ElGamal encryption example, simplify of the code in agora-gui-booth
https://github.com/agoravoting/agora-gui-booth
-->

<html>


<head>
</head>

Expand Down
5 changes: 4 additions & 1 deletion decide/voting/admin.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from django.contrib import admin
from django.utils import timezone


from .models import QuestionOption
from .models import Question
from .models import Voting


from .filters import StartedFilter



def start(modeladmin, request, queryset):
for v in queryset.all():
v.create_pubkey()
Expand All @@ -34,7 +37,6 @@ class QuestionOptionInline(admin.TabularInline):
class QuestionAdmin(admin.ModelAdmin):
inlines = [QuestionOptionInline]


class VotingAdmin(admin.ModelAdmin):
list_display = ('name', 'start_date', 'end_date')
readonly_fields = ('start_date', 'end_date', 'pub_key',
Expand All @@ -46,5 +48,6 @@ class VotingAdmin(admin.ModelAdmin):
actions = [ start, stop, tally ]



admin.site.register(Voting, VotingAdmin)
admin.site.register(Question, QuestionAdmin)
26 changes: 26 additions & 0 deletions decide/voting/migrations/0004_auto_20211219_1730.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 2.0 on 2021-12-19 17:30

from django.db import migrations, models
import voting.validators


class Migration(migrations.Migration):

dependencies = [
('voting', '0003_auto_20180605_0842'),
]

operations = [
migrations.CreateModel(
name='Detector',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('word', models.TextField()),
],
),
migrations.AlterField(
model_name='voting',
name='desc',
field=models.TextField(blank=True, null=True, validators=[voting.validators.lofensivo]),
),
]
36 changes: 36 additions & 0 deletions decide/voting/migrations/0004_auto_20211220_1657.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated by Django 2.0 on 2021-12-20 16:57

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('voting', '0003_auto_20180605_0842'),
]

operations = [
migrations.CreateModel(
name='RespuestaBinaria',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('respuesta', models.BooleanField(choices=[(1, 'Sí'), (0, 'No')])),
],
),
migrations.CreateModel(
name='VotacionBinaria',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('titulo', models.CharField(max_length=60)),
('descripcion', models.TextField()),
('fecha_inicio', models.DateTimeField(blank=True, null=True)),
('fecha_fin', models.DateTimeField(blank=True, null=True)),
],
),
migrations.AddField(
model_name='respuestabinaria',
name='votacionBinaria',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='respuestasBinarias', to='voting.VotacionBinaria'),
),
]
28 changes: 28 additions & 0 deletions decide/voting/migrations/0005_auto_20211220_2001.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 2.0 on 2021-12-20 20:01

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('voting', '0004_auto_20211220_1657'),
]

operations = [
migrations.RemoveField(
model_name='respuestabinaria',
name='votacionBinaria',
),
migrations.AddField(
model_name='question',
name='yes_no_question',
field=models.BooleanField(default=False, help_text='Check the box to generate automatically the options yes/no ', verbose_name='Yes/No question'),
),
migrations.DeleteModel(
name='RespuestaBinaria',
),
migrations.DeleteModel(
name='VotacionBinaria',
),
]
21 changes: 21 additions & 0 deletions decide/voting/migrations/0005_percentage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Generated by Django 2.0 on 2021-12-19 18:02

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('voting', '0004_auto_20211219_1730'),
]

operations = [
migrations.CreateModel(
name='Percentage',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('number', models.PositiveIntegerField(validators=[django.core.validators.MinValueValidator(0), django.core.validators.MaxValueValidator(100)])),
],
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 4.0 on 2022-01-01 18:59

from django.db import migrations
from django.contrib.postgres.fields import JSONField


class Migration(migrations.Migration):

dependencies = [
('voting', '0005_percentage'),
]

operations = [
migrations.AlterField(
model_name='voting',
name='postproc',
field=JSONField(blank=True, null=True),
),
migrations.AlterField(
model_name='voting',
name='tally',
field=JSONField(blank=True, null=True),
),
]
22 changes: 22 additions & 0 deletions decide/voting/migrations/0006_auto_20211220_2225.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 2.0 on 2021-12-20 22:25

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('voting', '0005_auto_20211220_2001'),
]

operations = [
migrations.RemoveField(
model_name='question',
name='yes_no_question',
),
migrations.AddField(
model_name='question',
name='binary_question',
field=models.BooleanField(default=False, help_text='Check the box to generate a binary question', verbose_name='Answers Yes/No'),
),
]
14 changes: 14 additions & 0 deletions decide/voting/migrations/0007_merge_20220103_1820.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 2.0 on 2022-01-03 18:20

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('voting', '0006_auto_20211220_2225'),
('voting', '0006_alter_voting_postproc_alter_voting_tally'),
]

operations = [
]
14 changes: 14 additions & 0 deletions decide/voting/migrations/0007_merge_20220104_1653.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 2.0 on 2022-01-04 16:53

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('voting', '0006_auto_20211220_2225'),
('voting', '0006_alter_voting_postproc_alter_voting_tally'),
]

operations = [
]
Loading

0 comments on commit 838aa1d

Please sign in to comment.