Skip to content

Commit

Permalink
Merge pull request #32 from egc-sierrezuela-3/feature/votacion-21
Browse files Browse the repository at this point in the history
CREAR TIPO POSTPROCESADO EN QUESTION
  • Loading branch information
margarcac1 authored Dec 22, 2021
2 parents 6c129fb + c9233b7 commit e91ddf8
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
18 changes: 18 additions & 0 deletions decide/voting/migrations/0004_question_postproc_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.0 on 2021-12-18 18:22

from django.db import migrations, models


class Migration(migrations.Migration):

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

operations = [
migrations.AddField(
model_name='question',
name='postproc_type',
field=models.IntegerField(choices=[(1, 'Dhont'), (2, 'Borda'), (3, 'SaintLague')], default=1),
),
]
18 changes: 18 additions & 0 deletions decide/voting/migrations/0005_auto_20211218_1835.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.0 on 2021-12-18 18:35

from django.db import migrations, models


class Migration(migrations.Migration):

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

operations = [
migrations.AlterField(
model_name='question',
name='postproc_type',
field=models.IntegerField(choices=[(2, 'Borda'), (1, 'Dhont'), (3, 'SaintLague')], default=1),
),
]
1 change: 1 addition & 0 deletions decide/voting/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

class Question(models.Model):
desc = models.TextField()
postproc_type=models.IntegerField(choices={(1,'Dhont'),(2,'Borda'),(3,'SaintLague')},default=1)

def __str__(self):
return self.desc
Expand Down
3 changes: 2 additions & 1 deletion decide/voting/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def post(self, request, *args, **kwargs):
if not data in request.data:
return Response({}, status=status.HTTP_400_BAD_REQUEST)

question = Question(desc=request.data.get('question'))
question = Question(desc=request.data.get('question'),
postproc_type=request.data.get('question'))
question.save()
for idx, q_opt in enumerate(request.data.get('question_opt')):
opt = QuestionOption(question=question, option=q_opt, number=idx)
Expand Down

0 comments on commit e91ddf8

Please sign in to comment.