Commit e1c14bcc authored by Dmitry Volodin's avatar Dmitry Volodin
Browse files

Merge branch 'patch-avs-add-unlimited-row' into 'master'

Add api_unlimited_row_limit param

See merge request !4573
parents 00e8f7be 9a88e594
Pipeline #28141 passed with stages
in 31 minutes and 48 seconds
......@@ -567,6 +567,7 @@ class Config(BaseConfig):
class web(ConfigSection):
theme = StringParameter(default="gray")
api_row_limit = IntParameter(default=0)
api_unlimited_row_limit = IntParameter(default=1000)
api_arch_alarm_limit = IntParameter(default=4 * 86400)
max_upload_size = IntParameter(default=16777216)
language = StringParameter(default="en")
......
......@@ -55,6 +55,7 @@ class ExtApplication(Application):
super().__init__(*args, **kwargs)
self.document_root = os.path.join("services", "web", "apps", self.module, self.app)
self.row_limit = config.web.api_row_limit
self.unlimited_row_limit = config.web.api_unlimited_row_limit
self.pk = "id"
# Bulk fields API
self.bulk_fields = []
......@@ -149,7 +150,8 @@ class ExtApplication(Application):
q = {str(k): v[0] if len(v) == 1 else v for k, v in request.POST.lists()}
else:
q = {str(k): v[0] if len(v) == 1 else v for k, v in request.GET.lists()}
limit = q.get(self.limit_param)
# Apply row limit if necessary
limit = q.get(self.limit_param, self.unlimited_row_limit)
if limit:
try:
limit = max(int(limit), 0)
......@@ -222,9 +224,6 @@ class ExtApplication(Application):
ordering = ordering or self.default_ordering
if ordering:
data = data.order_by(*ordering)
# Apply row limit if necessary
if self.row_limit:
limit = min(limit or self.row_limit, self.row_limit + 1)
# Apply paging
if limit:
data = data[start : start + limit]
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment