Skip to content

Commit

Permalink
apps/polls: also fill weight field for choices
Browse files Browse the repository at this point in the history
The order of the choices stays the same like that.
We have to change it in this migration, because we cannot make sure, that this is run before
the migration in a4 adding the weight to the poll. And for projects where this migration is already run, it is no problem that it changed.
  • Loading branch information
fuzzylogic2000 committed Aug 19, 2021
1 parent 06175ef commit e058ca9
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ def copy_data(apps, schema_editor):
multiple_choice = mb_question.multiple_choice,
poll = poll)
mb_choices = MBChoice.objects.filter(question=mb_question)
for mb_choice in mb_choices:
for i, mb_choice in enumerate(mb_choices):
choice = Choice.objects.create(
label = mb_choice.label,
question = question)
question = question,
weight = i)
mb_votes = MBVote.objects.filter(choice=mb_choice)
for mb_vote in mb_votes:
Vote.objects.create(
Expand Down

0 comments on commit e058ca9

Please sign in to comment.