forked from EGCETSII/decide_django_2
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'visualizer-luibelzan' into temporal
- Loading branch information
Showing
30 changed files
with
1,300 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,3 +101,5 @@ ENV/ | |
.mypy_cache/ | ||
|
||
.vagrant | ||
|
||
requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 -' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1 @@ | ||
from django.db import models | ||
|
||
# Create your models here. | ||
from django.db import models |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{% load socialaccount %} | ||
{% providers_media_js %} | ||
|
||
<a class="fab fa-microsoft size_social text-info" aria-hidden="true" href="{% provider_login_url "microsoft" %}">microsoft</a> | ||
<a class="fab fa-google size_social text-info" aria-hidden="true" href="{% provider_login_url "google" %}">Google</a> | ||
|
||
|
||
{% if user.is_authenticated %} | ||
estoy autenticado | ||
{% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,78 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. | ||
from rest_framework.test import APIClient | ||
from rest_framework.test import APITestCase | ||
|
||
from base import mods | ||
|
||
from voting.models import Voting, QuestionOption, Question | ||
|
||
from .models import VotingCount | ||
|
||
from django.utils import timezone | ||
|
||
class BoothTestCase(APITestCase): | ||
|
||
def setUp(self): | ||
self.client = APIClient() | ||
mods.mock_query(self.client) | ||
|
||
question = Question(desc='qwerty') | ||
question.save() | ||
|
||
for i in range(5): | ||
self.questionOption = QuestionOption(question=question, option='option {}'.format(i+1)) | ||
self.questionOption.save() | ||
|
||
self.voting = Voting(name='test voting', question=question) | ||
self.voting.save() | ||
|
||
self.votingCount = VotingCount(voting=self.voting, option=self.questionOption) | ||
self.votingCount.save() | ||
|
||
def tearDown(self): | ||
self.client = None | ||
|
||
# Descripción: Añade una nueva votación a la tabla de Recuento de votaciones | ||
# Entrada: | ||
## option: id de la opción votada | ||
## voting: id de la votación | ||
# Salida: ninguna | ||
def test_addVotingCount(self): | ||
# Información que se debe insertar vía POST para una opción y votación | ||
data = { | ||
'option': self.questionOption.id, | ||
'voting': self.voting.id | ||
} | ||
|
||
response = self.client.post('/booth/votingCount/', data, format='json') | ||
|
||
# Si en el endpoint se recibe id de opción válido, e id de votación, la respuesta http debería ser 200 | ||
self.assertEqual(response.status_code, 200) | ||
|
||
# Descripción: Prueba la recolección de recuentos de votos en vivo a través de endpoint | ||
# Entrada: | ||
## id: id de la votación | ||
# Salida: Matriz con todos los votos realizados a una votación y su opción | ||
def test_getVotingCount(self): | ||
expected_result = [ | ||
{ | ||
'id': self.votingCount.id, | ||
'voting_id': self.voting.id, | ||
'option_id': self.questionOption.id | ||
} | ||
] | ||
|
||
# Se solicita el recuento de votos a la url añadiendo el id de la votación | ||
response = self.client.get('/booth/votingCount/'+str(self.voting.id)+'/', format='json') | ||
|
||
|
||
# Si en el endpoint se recibe id de opción y de votación, la respuesta http debería ser 200 | ||
self.assertEqual(response.status_code, 200) | ||
|
||
# Pasamos la respuesta a json y comparamos con la esperada | ||
values = response.json()['votingCount'] | ||
for val in values: | ||
val.pop('created_at') | ||
|
||
self.assertEqual(values, expected_result) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
from django.urls import path | ||
from .views import BoothView | ||
|
||
from .views import BoothView, BoothVotingCountView | ||
from . import views | ||
|
||
urlpatterns = [ | ||
path('<int:voting_id>/', BoothView.as_view()), | ||
path('voting', views.votings), | ||
path('voting', views.votings), | ||
path('votingCount/', BoothVotingCountView.as_view()), | ||
path('votingCount/<int:voting_id>/', BoothVotingCountView.as_view()) | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.