Skip to content

Commit

Permalink
Set MergedXForm uuid on create
Browse files Browse the repository at this point in the history
- Update tests to ensure uuid is returned on retrieve from the MergedXFormViewset
  • Loading branch information
DavisRayM committed Mar 9, 2020
1 parent 89cd97d commit 67918f5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ def _create_merged_dataset(self, geo=False):
self.assertIn('id', response.data)
self.assertIn('title', response.data)
self.assertIn('xforms', response.data)
self.assertIn('uuid', response.data)
expected_xforms_data = {
'id': xform1.pk,
'title': xform1.title,
Expand Down
4 changes: 3 additions & 1 deletion onadata/libs/serializers/merged_xform_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,9 @@ class MergedXFormSerializer(serializers.HyperlinkedModelSerializer):

class Meta:
model = MergedXForm
fields = ('url', 'id', 'xforms', 'name', 'project', 'title',
fields = ('url', 'id', 'uuid', 'xforms', 'name', 'project', 'title',
'num_of_submissions', 'last_submission_time')
write_only_fields = ('uuid', )

# pylint: disable=no-self-use
def get_num_of_submissions(self, obj):
Expand Down Expand Up @@ -198,6 +199,7 @@ def create(self, validated_data):
validated_data['instances_with_geopoints'] = any([
__.instances_with_geopoints for __ in validated_data.get('xforms')
])
validated_data['uuid'] = uuid.uuid4().hex

with transaction.atomic():
instance = super(MergedXFormSerializer,
Expand Down

0 comments on commit 67918f5

Please sign in to comment.