[Patchew-devel] [PATCH v2] serializer: Add custom serialzer for recipients and sender

Shubham Jain shubhamjain7495 at gmail.com
Fri May 4 09:13:22 UTC 2018


I was working on the create Mixin part. But I'll first work on this
serialiser part and as well as setters and getters of mbox (according to
the previous review)

On Fri, May 4, 2018 at 1:02 PM Paolo Bonzini <pbonzini at redhat.com> wrote:

>
>
> ----- Original Message -----
> > From: "Shubham Jain" <shubhamjain7495 at gmail.com>
> > To: "Paolo Bonzini" <pbonzini at redhat.com>
> > Cc: patchew-devel at redhat.com
> > Sent: Friday, May 4, 2018 8:47:44 AM
> > Subject: Re: [Patchew-devel] [PATCH v2] serializer: Add custom serialzer
> for recipients and sender
> >
> > I've found the error. Apparently In BaseMessageSerializer, sender and
> > recipient are in the form of  OrderedDict([('name', 'Andrey Smirnov'),
> > ('address', 'andrew.smirnov at gmail.com')]) instead of ['Andrey Smirnov','
> > andrew.smirnov at gmail.com']. I'm not sure what is happening here. Is
> create
> > of AddressSerializer not getting called?
>
> I guess this is the "nested writable serializer" issue, and then you
> have to call "create" yourself.  Following the example in the DRF
> manual, it would be something like
>
>     def create(self, validated_data):
>         validated_data['sender'] =
> self.sender.create(**validated_data['sender'])
>         ... same for recipients ...
>         # Override get_serializer_context in ProjectMessagesViewSetMixin,
>         # so that the project is passed down to the serializer
>         # (see https://stackoverflow.com/questions/31038742/)
>         # The new create method on MessageManager (as discussed on IRC)
>         # saves the mbox and creates the object
>         return Message.objects.create(project=self.context['project'],
>                                       **validated_data)
>
> Which of the tasks in "Convert `import` to REST style POST"
> (https://github.com/patchew-project/patchew/issues/75) are you working
> on now?
>
> Thanks,
>
> Paolo
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/patchew-devel/attachments/20180504/7d7094ac/attachment.htm>


More information about the Patchew-devel mailing list