Skip to content
This repository has been archived by the owner on Jul 25, 2024. It is now read-only.

Commit

Permalink
api/rest.py,core/models.py: WIP support for attachement access
Browse files Browse the repository at this point in the history
WIP draft of support for accessing attachments.
  • Loading branch information
katieworton committed Nov 2, 2023
1 parent b7adc79 commit eeb2fdd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion squad/api/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1310,9 +1310,17 @@ class StatusViewSet(NestedViewSetMixin, ModelViewSet):

class AttachmentSerializer(serializers.ModelSerializer):

attachment_url = serializers.SerializerMethodField()

class Meta:
model = Attachment
fields = ('filename', 'mimetype', 'length')
fields = '__all__'

def get_attachment_url(self, attachment):
request = self.context.get('request')
if request is None:
return None
return request.build_absolute_uri(f"/{attachment.test_run.project}/build/{attachment.test_run.build.version}/attachments/testrun/{attachment.pk}/{attachment.filename}")


class TestRunSerializer(DynamicFieldsModelSerializer, serializers.HyperlinkedModelSerializer):
Expand Down

0 comments on commit eeb2fdd

Please sign in to comment.