Skip to content

Commit

Permalink
Merge pull request EGCETSII#23 from Decide-Part-Rota/Rota1-005
Browse files Browse the repository at this point in the history
Rota1-005
  • Loading branch information
vicsotber authored Nov 24, 2022
2 parents ecd1647 + 7e10a81 commit 37efa48
Show file tree
Hide file tree
Showing 10 changed files with 152 additions and 3 deletions.
2 changes: 1 addition & 1 deletion decide/booth/templates/booth/booth.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ <h2>[[ voting.question.desc ]]</h2>
<script src="{% static "crypto/elgamal.js" %}"></script>

<!-- Vuejs -->
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/vue@2.7.10"></script>
<script src="https://unpkg.com/babel-polyfill@latest/dist/polyfill.min.js"></script>
<script src="https://unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.js"></script>

Expand Down
2 changes: 1 addition & 1 deletion decide/visualizer/templates/visualizer/visualizer.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ <h2 class="heading">Resultados:</h2>

{% block extrabody %}
<!-- Vuejs -->
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/vue@2.7.10"></script>
<script src="https://unpkg.com/babel-polyfill@latest/dist/polyfill.min.js"></script>
<script src="https://unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.js"></script>

Expand Down
1 change: 1 addition & 0 deletions decide/voting/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def lookups(self, request, model_admin):
('S', 'Started'),
('R', 'Running'),
('F', 'Finished'),
('V', 'Visibility')
]

def queryset(self, request, queryset):
Expand Down
18 changes: 18 additions & 0 deletions decide/voting/migrations/0004_voting_visibility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.0 on 2022-11-22 18:37

from django.db import migrations, models


class Migration(migrations.Migration):

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

operations = [
migrations.AddField(
model_name='voting',
name='visibility',
field=models.BooleanField(default=True),
),
]
18 changes: 18 additions & 0 deletions decide/voting/migrations/0005_auto_20221122_1928.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.0 on 2022-11-22 19:28

from django.db import migrations, models


class Migration(migrations.Migration):

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

operations = [
migrations.AlterField(
model_name='voting',
name='visibility',
field=models.BooleanField(),
),
]
2 changes: 2 additions & 0 deletions decide/voting/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class Voting(models.Model):
start_date = models.DateTimeField(blank=True, null=True)
end_date = models.DateTimeField(blank=True, null=True)

visibility = models.BooleanField()

pub_key = models.OneToOneField(Key, related_name='voting', blank=True, null=True, on_delete=models.SET_NULL)
auths = models.ManyToManyField(Auth, related_name='votings')

Expand Down
17 changes: 17 additions & 0 deletions decide/voting/static/voting/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.boton-personalizado {
text-decoration: none;
font-weight: 600;
font-size: 20px;
color: #333;
padding: 5px 20px;
background-color: #ffd27d;
border-color: #d8d8d8;
border-width: 3px;
border-style: solid;
border-radius: 35px;
}

/* Este es el estilo al poner el cursor encima del boton */
.boton-personalizado:hover {
background-color: #000;
}
76 changes: 76 additions & 0 deletions decide/voting/templates/voting/listVoting.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<!DOCTYPE html>

{% load i18n static %}

{% block extrahead %}
<link type="text/css" rel="stylesheet"
href="https://unpkg.com/bootstrap/dist/css/bootstrap.min.css" />
<link type="text/css" rel="stylesheet"
href="https://unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.css" />
<link type="text/css" rel="stylesheet" href="{% static "voting/style.css" %}" />
{% endblock %}


{% block content %}

<h1 style="text-align:center">Listado de Votaciones</h1>

<body>

<table class="table table-bordered">

<thead>

<tr>

<td>ID</td>
<td>Name</td>
<td>Description</td>
<td>Visibility</td>
<td></td>

</tr>

</thead>

<tbody>

{% if votaciones %}

<!-- Cojo la colección votaciones que le paso en views.py -->
{% for votacion in votaciones %}

<tr>

<td>{{votacion.id}}</td>
<td>{{votacion.name}}</td>
<td>{{votacion.desc}}</td>
<td>{{votacion.visibility}}</td>

<td>

<a class="boton-personalizado" href="http://127.0.0.1:8000/booth/{{votacion.id}}">

Go Vote

</a>

</td>

</tr>

{% endfor %}

{% else %}

<h3 style="text-align:center">Listado de Votaciones</h3>

{% endif %}

</tbody>

</table>

</body>

{% endblock %}
2 changes: 2 additions & 0 deletions decide/voting/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@


urlpatterns = [
#Acceder al listado con localhost:8000/voting/listadoVotaciones
path('listadoVotaciones', views.VotacionList.mostrarVotacionesPublicas),
path('', views.VotingView.as_view(), name='voting'),
path('<int:voting_id>/', views.VotingUpdate.as_view(), name='voting'),
]
17 changes: 16 additions & 1 deletion decide/voting/views.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
import django_filters.rest_framework
from django.conf import settings
from django.utils import timezone
from django.shortcuts import get_object_or_404
from django.shortcuts import get_object_or_404, render
from rest_framework import generics, status
from rest_framework.response import Response
from django.views.generic import TemplateView


from .models import Question, QuestionOption, Voting
from .serializers import SimpleVotingSerializer, VotingSerializer
from base.perms import UserIsStaff
from base.models import Auth

#Clase para listar todas las votaciones.
class VotacionList(TemplateView):
template_name = 'voting/listVoting.html'

#Método para mostrar un listado de todas las votaciones.
def mostrarVotacionesPublicas(request):
votaciones = Voting.objects.all()

data={
'votaciones': votaciones
}

return render(request, 'voting/listVoting.html', data)

class VotingView(generics.ListCreateAPIView):
queryset = Voting.objects.all()
Expand Down

0 comments on commit 37efa48

Please sign in to comment.