jazzband / django-mongonaut

Built from scratch to replicate some of the Django admin functionality and add some more, to serve as an introspective interface for Django and Mongo.
MIT License
240 stars 67 forks source link

Resolved bug with pagination. #82

Closed anushajp closed 8 years ago

anushajp commented 8 years ago

Hi

I found an error with the pagination functionality.

Suppose the documents per page is 25 and the page contains 11 documents, the pagination button gives me a wrong message (page 1 of 1.44) and it shows the Next button and it lets to click the button. Ideally it should not show the Next button if the count is less than 25. It redirects to an error page when I click the Next button. It was a TypeError at /mongonaut/... (integer argument expected, got float).

I found that the error is getting when you calculate total pages. self.total_pages = obj_count / self.documents_per_page + (1 if obj_count % self.documents_per_page else 0) ie, self.total_pages = 11/25+0

this results a float no(1.44). so the total pages will be more than 1 and it shows the next button

So I did a small correction in the same line self.total_pages = int(obj_count / self.documents_per_page + (1 if obj_count % self.documents_per_page else 0))

it works fine with this code

Thank you

anushajp commented 8 years ago

@garrypolley
Hi I made the changes which you suggested regarding the pagination error. It works fine Thank you

garrypolley commented 8 years ago

Thanks for the update.