[Patchew-devel] [PATCH v2] rest: add api/v1/messages endpoint (POST support)

Fam Zheng famz at redhat.com
Wed May 16 01:31:07 UTC 2018


On Tue, 05/15 14:08, Paolo Bonzini wrote:
> On 15/05/2018 14:02, Shubham Jain wrote:
> > +    def create(self, request, *args, **kwargs):
> > +        projects = [p for p in Project.objects.all() if p.recognizes(MboxMessage(self.request.data['mbox']))]

It is better to create MboxMessage object once to avoid repeating the mbox
parse:

             m = MboxMessage(self.request.data['mbox'])
             projects = [p for p in Project.objects.all() if p.recognizes(m)]


> > +        if 'importers' not in self.request.user.groups.all():
> > +            projects = set(projects) & set([p for p in Project.objects.all() if p.maintained_by(self.request.user)])
> 
> This can be just "projects = (p for p in projects if
> p.maintained_by(self.request_user))".  I'll make the change and commit it.
> 
> Fam, what do you think should Admin accounts do?  Import only to the
> projects they maintain, or to all of them?

I think all is better. The projects to import can be explicitly limited if they want.

Fam




More information about the Patchew-devel mailing list