[16.0][ADD] portal_pager_size - #1201
halbtonjazz wants to merge 1 commit into
Conversation
geomer198
left a comment
There was a problem hiding this comment.
Could you please check code review result.
| param = ( | ||
| request.env["ir.config_parameter"] | ||
| .sudo() | ||
| .get_param(OPTIONS_PARAM, default="10,20,40,80,100") |
There was a problem hiding this comment.
Maybe better use default value=False and then use DEFAULT_LIMIT_OPTIONS const without split methods?
param = request.env["ir.config_parameter].sudo().get_param(OPTIONS_PARAM, default=False)
if not param:
return DEFAULT_LIMIT_OPTIONS
return [int(x.strip()) for x in param.split(",") if x.strip().isdigit()] or DEFAULT_LIMIT_OPTIONS| _request_stack.pop() | ||
|
|
||
|
|
||
| class TestPagerLimitOptions(TestPortalPagerLimitCommon): |
There was a problem hiding this comment.
Please split this file.
Use for each test class separate file for tests.
| """ | ||
| param = request.env["ir.config_parameter"].sudo().get_param(OPTIONS_PARAM) | ||
| if not param: | ||
| return list(DEFAULT_LIMIT_OPTIONS) |
There was a problem hiding this comment.
it was meant as a defensive copy against append, sort, etc. I just didn't notice the constant was already a list, not a tuple. Reworked the constant into a tuple, now list() actually makes sense (a fresh mutable list from an immutable constant)
| if not param: | ||
| return list(DEFAULT_LIMIT_OPTIONS) | ||
| options = [int(x.strip()) for x in param.split(",") if x.strip().isdigit()] | ||
| return options or list(DEFAULT_LIMIT_OPTIONS) |
|
|
||
| def _prepare_portal_layout_values(self): | ||
| values = super()._prepare_portal_layout_values() | ||
| values.update( |
There was a problem hiding this comment.
Please add comment this with describe about new functional.
| # honors the ``limit`` query parameter without overriding each route. | ||
| @property | ||
| def _items_per_page(self): | ||
| limit = request.httprequest.args.get("limit", "") |
|
This PR has the |
|
@pedrobaeza Hello, could you please take a look? Thank you. |
|
|
@pedrobaeza |
|
@pedrobaeza |
|
Formally, this should be squashed into one commit. About the module itself, I can't say. |
Add a page size selector to portal pager lists. Users pick how many records per page via a whitelisted limit query parameter configurable in system parameters. Task: 0350
732e117 to
1982169
Compare
Done, |
Description
New module that adds a configurable page size selector to the portal
pager. Portal users can pick how many records are shown per page
(10/20/40/80/100 by default) via a dropdown next to the pagination
controls. The choice is applied through a
limitquery parameter andkept while paginating, sorting, filtering and searching.
Allowed values are whitelisted through the
website_portal_pager_limit.optionssystem parameter; any invalid orout-of-list value falls back to the standard portal page size (80), so a
misconfiguration can never break pagination.
How it works
_items_per_pageas a property reading thevalidated
limit, so every/my/*route benefits without overridingeach route.
portal.pageris inherited to render the selector (kept visible evenon single-page lists).
Task: 0350