Stephen Finucane <[email protected]> writes:

> queryset.reverse() is either broken or being used incorrectly in
> Django 1.6 and Django 1.7. Replace it with an alternative approach.
>
> Signed-off-by: Stephen Finucane <[email protected]>
> Closes-bug: #35

Thanks!

Tested-by: Daniel Axtens <[email protected]>

Regards,
Daniel

> ---
>  patchwork/views/xmlrpc.py | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/patchwork/views/xmlrpc.py b/patchwork/views/xmlrpc.py
> index 8f759aa..81df266 100644
> --- a/patchwork/views/xmlrpc.py
> +++ b/patchwork/views/xmlrpc.py
> @@ -406,8 +406,8 @@ def project_list(search_str=None, max_count=0):
>          if max_count > 0:
>              return list(map(project_to_dict, projects[:max_count]))
>          elif max_count < 0:
> -            query = projects.reverse()[:-max_count]
> -            return list(map(project_to_dict, reversed(query)))
> +            min_count = projects.count() + max_count
> +            return list(map(project_to_dict, projects[min_count:]))
>          else:
>              return list(map(project_to_dict, projects))
>      except Project.DoesNotExist:
> @@ -461,8 +461,8 @@ def person_list(search_str=None, max_count=0):
>          if max_count > 0:
>              return list(map(person_to_dict, people[:max_count]))
>          elif max_count < 0:
> -            query = people.reverse()[:-max_count]
> -            return list(map(person_to_dict, reversed(query)))
> +            min_count = people.count() + max_count
> +            return list(map(person_to_dict, people[min_count:]))
>          else:
>              return list(map(person_to_dict, people))
>      except Person.DoesNotExist:
> @@ -607,8 +607,8 @@ def patch_list(filt=None):
>          if max_count > 0:
>              return list(map(patch_to_dict, patches[:max_count]))
>          elif max_count < 0:
> -            query = patches.reverse()[:-max_count]
> -            return list(map(patch_to_dict, reversed(query)))
> +            min_count = patches.count() + max_count
> +            return list(map(patch_to_dict, patches[min_count:]))
>          else:
>              return list(map(patch_to_dict, patches))
>      except Patch.DoesNotExist:
> @@ -803,8 +803,8 @@ def state_list(search_str=None, max_count=0):
>          if max_count > 0:
>              return list(map(state_to_dict, states[:max_count]))
>          elif max_count < 0:
> -            query = states.reverse()[:-max_count]
> -            return list(map(state_to_dict, reversed(query)))
> +            min_count = states.count() + max_count
> +            return list(map(state_to_dict, states[min_count:]))
>          else:
>              return list(map(state_to_dict, states))
>      except State.DoesNotExist:
> -- 
> 2.7.4
>
> _______________________________________________
> Patchwork mailing list
> [email protected]
> https://lists.ozlabs.org/listinfo/patchwork

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Patchwork mailing list
[email protected]
https://lists.ozlabs.org/listinfo/patchwork

Reply via email to