[Patchew-devel] [PATCH v2] rest: POST for message endpoint
Paolo Bonzini
pbonzini at redhat.com
Mon May 7 17:42:02 UTC 2018
On 07/05/2018 19:37, Shubham Jain wrote:
> + def create(self,project, **validated_data):
> + mbox = validated_data.pop('mbox')
> + m = MboxMessage(mbox)
> + msg = Message(**validated_data)
> + msg.in_reply_to = m.get_in_reply_to() or ""
You still haven't added in_reply_to to the serializer, was there any
reason for that?
>
> +
> + def create(self, validated_data):
> + validated_data['recipients'] = self.fields['recipients'].create(validated_data['recipients'])
> + validated_data['sender'] = self.fields['sender'].create(validated_data['sender'])
> + return Message.objects.create(project=self.context['project'], **validated_data)
If the context doesn't have 'project' this would fail. Would it work to
return Http404 in ProjectMessagesViewSetMixin's get_serializer_context,
whenever the project is not found?
Thanks,
Paolo
More information about the Patchew-devel
mailing list