Add pagination to Studio's Files and Uploads page - #1912
Conversation
There was a problem hiding this comment.
What happens if someone accidentally or maliciously passes in a non-integer string for this parameter? Your code should do a try/catch when converting to int, and if a TypeError or ValueError occurs, handle it in some way.
There was a problem hiding this comment.
If you want to create a helper method for this, a good place would be /edx-platform/common/djangoapps/util/string_utils.py
|
If I type letters ("abc") in the pagination field, I see the text on top of the page number. I would expect the letters to disappear (and to stay on the same page). |
There was a problem hiding this comment.
Translation strings should not contain HTML. Use placeholders (the same way you're already using placeholders for %(start)s and %(end)s) to replace the HTML into the string after it's been localized.
|
If I type -5 in the pagination field and press Enter, about half of the time I get a JavaScript alert dialog with message "Error: [object Object"]. |
There was a problem hiding this comment.
application/json should be the default accepts header for AJAX requests. You can also pass AJAX options through the model.save() call -- it proxies through Backbone.sync to $.ajax. Backbone's source code is actually very readable, if you want to see how it works under the covers.
|
Get rid of this from the URL (form submission). awefjaseofj?page-number=-2# |
There was a problem hiding this comment.
Get rid of old start and max (not working anyway).
|
This general approach looks good. |
|
@frrrances, can you check out this PR when you get a chance. Also, it would be great to finalize how we are going to disable the Next/Previous buttons. Thanks! |
|
@frrrances I've fixed all the bugs including the performance problem you were seeing (I think). Can you try this again. Two issues remain:
Can you help me look into these two. In the meantime I'm going to get back to testing. |
|
@frrrances One more thing: the page input field looks odd when entering text as it still shows the current page number in gray underneath. How would you generally handle this? Could the label be hidden when the input has focus? |
|
@andy-armstrong looks like my sass changed got dropped at some point. I've added them back in and adjusted the focus to handle the transparency a bit better. |
|
Performance and everything else looks good to me now. 👍 |
|
@cahrens @singingwolfboy @frrrances @jzoldak This feature is ready for re-review. BTW, the BDD is also now available if you'd like to review that too: https://edx-wiki.atlassian.net/wiki/display/STU/BDD+specs+for+Asset+Pagination |
There was a problem hiding this comment.
Personally, I would create a helper function (can be scoped just to this method) for the 5 lines of duplicated code. But that's a nit. Actually, if you allow URL to be an argument, you could remove another duplicated line of code.
These changes represent the initial implementation of STUD-813 which adds pagination to the Files and Uploads page. @cahrens and @singingwolfboy, please pre-review this code since this is my first major change, and I want to be sure that I'm following best practices.
Note that I will be adding tests in my next commit, so this pull request will not be merged as is.