maposmatic-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Maposmatic-dev] [PATCH] Add pagination when searching


From: Maxime Petazzoni
Subject: Re: [Maposmatic-dev] [PATCH] Add pagination when searching
Date: Mon, 21 Jun 2010 11:55:31 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

* David MENTRE <address@hidden> [2010-06-21 11:51:58]:

> > +    form = forms.MapSearchForm(request.GET)
> > +
> > +    if form.is_valid():
> > +        map_list = (models.MapRenderingJob.objects
> > +                    .order_by('maptitle')
> > +                    .filter(status=2)
> > +                    
> > .filter(maptitle__icontains=form.cleaned_data['query']))
> > +        if len(map_list) == 1:
> > +            return HttpResponseRedirect(reverse('job-by-id',
> > +                                                args=[map_list[0].id]))
> 
> On this patch you do not test "if request.method == 'GET':". Can I
> assume this code is not necessary?

Regardless of the request method (GET/POST), the code gracefully handles
the case where the GET query parameter is not provided (the form simply
doesn't validate). So it's not really useful to test for the request
method and add a level of indent here.

- Maxime, who helped Maxime² on this
-- 
Maxime Petazzoni <http://www.bulix.org>
 ``One by one, the penguins took away my sanity.''
Linux kernel and software developer at MontaVista Software

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]