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

dont remove old proposal in import

parent af490f4c
......@@ -173,22 +173,14 @@ 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(
if not created:
# Delete proposals that don't belongs to that dossier anymore
for proposal in previous_proposals:
return dossier
def _create_proposal(self, proposal_data, dossier):
votes_data = proposal_data.pop('votes')
proposal_data['dossier'] = dossier
......@@ -197,3 +189,4 @@ class DossierDetailSerializer(DossierSerializer):
for vote_data in votes_data:
vote_data['proposal'] = proposal
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