Skip to content

Commit

Permalink
Fix attribute export (#404)
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Nov 19, 2021
1 parent 6c4c49d commit 896c921
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
8 changes: 1 addition & 7 deletions rdmo/domain/serializers/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
class AttributeExportSerializer(serializers.ModelSerializer):

parent = serializers.CharField(source='parent.uri', default=None, read_only=True)
children = serializers.SerializerMethodField()

class Meta:
model = Attribute
Expand All @@ -16,10 +15,5 @@ class Meta:
'key',
'path',
'comment',
'parent',
'children'
'parent'
)

def get_children(self, obj):
# get the children from the cached mptt tree
return AttributeExportSerializer(obj.get_children(), many=True, read_only=True).data
5 changes: 3 additions & 2 deletions rdmo/domain/viewsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def export(self, request):

@action(detail=True, url_path='export', permission_classes=[HasModelPermission])
def detail_export(self, request, pk=None):
serializer = AttributeExportSerializer(self.get_object())
xml = AttributeRenderer().render([serializer.data])
queryset = self.get_object().get_descendants(include_self=True)
serializer = AttributeExportSerializer(queryset, many=True)
xml = AttributeRenderer().render(serializer.data)
return XMLResponse(xml, name=self.get_object().key)

0 comments on commit 896c921

Please sign in to comment.