diff --git a/.gitignore b/.gitignore index b823e313b4..9b32acb911 100644 --- a/.gitignore +++ b/.gitignore @@ -101,3 +101,5 @@ ENV/ .mypy_cache/ .vagrant + +requirements.txt diff --git a/Procfile b/Procfile new file mode 100644 index 0000000000..813249a6c6 --- /dev/null +++ b/Procfile @@ -0,0 +1,4 @@ +% prepara el repositorio para su despliegue. +release: sh -c 'cd decide && python manage.py migrate' +% especifica el comando para lanzar Decide +web: sh -c 'cd decide && gunicorn decide.wsgi --log-file -' \ No newline at end of file diff --git a/README.md b/README.md index 83d0a57e27..240a10a63e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ -[![Build Status](https://travis-ci.com/wadobo/decide.svg?branch=master)](https://travis-ci.com/wadobo/decide) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/94a85eaa0e974c71af6899ea3b0d27e0)](https://www.codacy.com/app/Wadobo/decide?utm_source=github.com&utm_medium=referral&utm_content=wadobo/decide&utm_campaign=Badge_Grade) [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/94a85eaa0e974c71af6899ea3b0d27e0)](https://www.codacy.com/app/Wadobo/decide?utm_source=github.com&utm_medium=referral&utm_content=wadobo/decide&utm_campaign=Badge_Coverage) +[![Python application](https://github.com/Penyagolosa-3/Decide/actions/workflows/django.yml/badge.svg?branch=develop)](https://github.com/Penyagolosa-3/Decide/actions/workflows/django.yml) +[![Codacy Badge](https://app.codacy.com/project/badge/Grade/06c453c2aba8409d8c5fbf354704fd65)](https://www.codacy.com/gh/Penyagolosa-3/Decide/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Penyagolosa-3/Decide&utm_campaign=Badge_Grade) +[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/06c453c2aba8409d8c5fbf354704fd65)](https://www.codacy.com/gh/Penyagolosa-3/Decide/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Penyagolosa-3/Decide&utm_campaign=Badge_Coverage) + +[![Python application](https://github.com/Decide-part-Penyagolosa/Decide/actions/workflows/django.yml/badge.svg?branch=deploy)](https://github.com/Decide-part-Penyagolosa/Decide/actions/workflows/django.yml) Plataforma voto electrónico educativa ===================================== diff --git a/decide/authentication/models.py b/decide/authentication/models.py index 71a8362390..0f02227440 100644 --- a/decide/authentication/models.py +++ b/decide/authentication/models.py @@ -1,3 +1 @@ -from django.db import models - -# Create your models here. +from django.db import models \ No newline at end of file diff --git a/decide/authentication/templates/login.html b/decide/authentication/templates/login.html new file mode 100644 index 0000000000..4609a2d5b5 --- /dev/null +++ b/decide/authentication/templates/login.html @@ -0,0 +1,10 @@ +{% load socialaccount %} +{% providers_media_js %} + +
+ + + +{% if user.is_authenticated %} +estoy autenticado +{% endif %} \ No newline at end of file diff --git a/decide/authentication/urls.py b/decide/authentication/urls.py index d05bfed6fc..c70bcd5175 100644 --- a/decide/authentication/urls.py +++ b/decide/authentication/urls.py @@ -1,12 +1,15 @@ from django.urls import include, path from rest_framework.authtoken.views import obtain_auth_token +from django.views.generic import TemplateView +from django.contrib import admin from .views import GetUserView, LogoutView, RegisterView - urlpatterns = [ path('login/', obtain_auth_token), path('logout/', LogoutView.as_view()), path('getuser/', GetUserView.as_view()), path('register/', RegisterView.as_view()), + path('signin/',TemplateView.as_view(template_name="login.html")), + path('accounts/',include('allauth.urls')), ] diff --git a/decide/base/tests.py b/decide/base/tests.py index 907964aa95..4949c15104 100644 --- a/decide/base/tests.py +++ b/decide/base/tests.py @@ -16,7 +16,7 @@ def setUp(self): user_noadmin.set_password('qwerty') user_noadmin.save() - user_admin = User(username='admin', is_staff=True) + user_admin = User(username='admin', is_staff=True, is_superuser=True) user_admin.set_password('qwerty') user_admin.save() diff --git a/decide/booth/migrations/0001_initial.py b/decide/booth/migrations/0001_initial.py new file mode 100644 index 0000000000..6da7dd5d9e --- /dev/null +++ b/decide/booth/migrations/0001_initial.py @@ -0,0 +1,24 @@ +# Generated by Django 2.0 on 2021-12-17 23:56 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ('voting', '0003_auto_20180605_0842'), + ] + + operations = [ + migrations.CreateModel( + name='VotingCount', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('option', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='voting.QuestionOption')), + ('voting', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='voting.Voting')), + ], + ), + ] diff --git a/decide/booth/migrations/0002_votingcount_created_at.py b/decide/booth/migrations/0002_votingcount_created_at.py new file mode 100644 index 0000000000..0ee06389a4 --- /dev/null +++ b/decide/booth/migrations/0002_votingcount_created_at.py @@ -0,0 +1,19 @@ +# Generated by Django 2.0 on 2021-12-20 16:50 + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('booth', '0001_initial'), + ] + + operations = [ + migrations.AddField( + model_name='votingcount', + name='created_at', + field=models.DateTimeField(default=django.utils.timezone.now), + ), + ] diff --git a/decide/booth/models.py b/decide/booth/models.py index 71a8362390..ca787c7340 100644 --- a/decide/booth/models.py +++ b/decide/booth/models.py @@ -1,3 +1,11 @@ from django.db import models +from django.utils import timezone + +from voting.models import Voting, QuestionOption # Create your models here. + +class VotingCount(models.Model): + voting = models.ForeignKey(Voting, on_delete=models.CASCADE) + option = models.ForeignKey(QuestionOption, on_delete=models.CASCADE) + created_at = models.DateTimeField(default=timezone.now) \ No newline at end of file diff --git a/decide/booth/serializers.py b/decide/booth/serializers.py new file mode 100644 index 0000000000..75fb047db3 --- /dev/null +++ b/decide/booth/serializers.py @@ -0,0 +1,9 @@ +from rest_framework import serializers + +from .models import VotingCount + + +class VotingCountSerializer(serializers.HyperlinkedModelSerializer): + class Meta: + model = VotingCount + fields = ('id', 'voting_id', 'option_id', 'created_at') diff --git a/decide/booth/templates/booth/booth.html b/decide/booth/templates/booth/booth.html index 9b8706593f..66afbbc56e 100644 --- a/decide/booth/templates/booth/booth.html +++ b/decide/booth/templates/booth/booth.html @@ -29,6 +29,7 @@Opción | +Porcentaje | +Votos | +
---|---|---|
[[opt.option]] | +[[ (((opt.votingCount ?? 0) * 100)/census) ]]% | +[[opt.votingCount ?? 0]] | +
Votos realizados: [[ totalVotes ]] | +Censo: [[ census ]] | +Votos restantes: [[ census - totalVotes ]] | +