Now can filter and upload issue attachments.
parent
00c5ff9d70
commit
217e07eefb
|
@ -121,6 +121,7 @@ class IssuesAttachmentList(generics.ListCreateAPIView):
|
||||||
.filter(content_type=ct)
|
.filter(content_type=ct)
|
||||||
|
|
||||||
def pre_save(self, obj):
|
def pre_save(self, obj):
|
||||||
|
obj.content_type = ContentType.objects.get_for_model(Issue)
|
||||||
obj.owner = self.request.user
|
obj.owner = self.request.user
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -49,11 +49,17 @@ class MilestoneSerializer(serializers.ModelSerializer):
|
||||||
|
|
||||||
|
|
||||||
class AttachmentSerializer(serializers.ModelSerializer):
|
class AttachmentSerializer(serializers.ModelSerializer):
|
||||||
issue = serializers.Field(source='object_id')
|
url = serializers.SerializerMethodField('get_url')
|
||||||
|
|
||||||
|
def get_url(self, obj):
|
||||||
|
# FIXME: add sites or correct url.
|
||||||
|
return "http://localhost:8000{0}".format(obj.attached_file.url)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Attachment
|
model = Attachment
|
||||||
fields = ('id', 'project', 'owner', 'attached_file', 'created_date', 'issue')
|
fields = ('id', 'project', 'owner', 'attached_file',
|
||||||
|
'created_date', 'object_id', 'url')
|
||||||
|
read_only_fields = ('owner',)
|
||||||
|
|
||||||
|
|
||||||
class TaskSerializer(serializers.ModelSerializer):
|
class TaskSerializer(serializers.ModelSerializer):
|
||||||
|
|
Loading…
Reference in New Issue