Commit 093248c1 authored by Arnaud Fabre's avatar Arnaud Fabre

dont remove old proposal in import

parent af490f4c
......@@ -173,21 +173,13 @@ class DossierDetailSerializer(DossierSerializer):
proposals_data = validated_data.pop('proposals')
dossier, _ = models.Dossier.objects.get_or_create(**validated_data)
previous_proposals = set(dossier.proposals.all())
for proposal_data in proposals_data:
proposal, created = self._create_proposal(
proposal_data,
dossier
)
if not created:
previous_proposals.remove(proposal)
# Delete proposals that don't belongs to that dossier anymore
for proposal in previous_proposals:
proposal.delete()
return dossier
def _create_proposal(self, proposal_data, dossier):
votes_data = proposal_data.pop('votes')
......@@ -197,3 +189,4 @@ class DossierDetailSerializer(DossierSerializer):
for vote_data in votes_data:
vote_data['proposal'] = proposal
models.Vote.objects.create(**vote_data)
return (proposal, created)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment