Re: [RFC PATCH] REST: Add new setting for maximum API page size

2018-07-23 Thread Andrew Donnellan

On 24/07/18 15:10, Andrew Donnellan wrote:

diff --git a/docs/deployment/configuration.rst 
b/docs/deployment/configuration.rst
index 347485636d47..e599522a412b 100644
--- a/docs/deployment/configuration.rst
+++ b/docs/deployment/configuration.rst
@@ -88,7 +88,13 @@ Enable the :doc:`REST API <../api/rest>`.
  The number of items to include in REST API responses by default. This can be
  overridden by the ``per_page`` parameter for some endpoints.
  
-.. versionadded:: 2.0


This obviously shouldn't have been there, will fix when I send non RFC


+``MAX_REST_RESULTS_PER_PAGE``
+~
+
+The maximum number of items that can be requested in a REST API request using
+the ``per_page`` parameter.
+
+.. versionadded:: 2.2



--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited

___
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork


[RFC PATCH] REST: Add new setting for maximum API page size

2018-07-23 Thread Andrew Donnellan
In 41790caf59ad ("REST: Limit max page size") we limited the maximum page
size to the default page size in the settings.

This turns out to be rather restrictive, as we usually want to keep the
default page size low, but an administrator may want to allow API clients
to fetch more than that per request.

Add a new setting, MAX_REST_RESULTS_PER_PAGE, to set the maximum page size.

Closes: #202 ("Separate max API page size and default API page size into 
different settings")
Suggested-by: Stewart Smith 
Suggested-by: Joel Stanley 
Signed-off-by: Andrew Donnellan 

---

This is completely untested but should work, sending this as an RFC because
I have no idea what the default should be, thoughts?
---
 docs/deployment/configuration.rst | 8 +++-
 patchwork/api/base.py | 3 ++-
 patchwork/settings/base.py| 1 +
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/docs/deployment/configuration.rst 
b/docs/deployment/configuration.rst
index 347485636d47..e599522a412b 100644
--- a/docs/deployment/configuration.rst
+++ b/docs/deployment/configuration.rst
@@ -88,7 +88,13 @@ Enable the :doc:`REST API <../api/rest>`.
 The number of items to include in REST API responses by default. This can be
 overridden by the ``per_page`` parameter for some endpoints.
 
-.. versionadded:: 2.0
+``MAX_REST_RESULTS_PER_PAGE``
+~
+
+The maximum number of items that can be requested in a REST API request using
+the ``per_page`` parameter.
+
+.. versionadded:: 2.2
 
 ``COMPAT_REDIR``
 
diff --git a/patchwork/api/base.py b/patchwork/api/base.py
index 8c38d5a1d5f4..bf452f78b390 100644
--- a/patchwork/api/base.py
+++ b/patchwork/api/base.py
@@ -36,7 +36,8 @@ class LinkHeaderPagination(PageNumberPagination):
https://tools.ietf.org/html/rfc5988#section-5
https://developer.github.com/guides/traversing-with-pagination
 """
-page_size = max_page_size = settings.REST_RESULTS_PER_PAGE
+page_size = settings.REST_RESULTS_PER_PAGE
+max_page_size = settings.MAX_REST_RESULTS_PER_PAGE
 page_size_query_param = 'per_page'
 
 def get_paginated_response(self, data):
diff --git a/patchwork/settings/base.py b/patchwork/settings/base.py
index 4b0d5513895a..7dc20041ec42 100644
--- a/patchwork/settings/base.py
+++ b/patchwork/settings/base.py
@@ -220,6 +220,7 @@ ENABLE_XMLRPC = False
 ENABLE_REST_API = True
 
 REST_RESULTS_PER_PAGE = 30
+MAX_REST_RESULTS_PER_PAGE = 500
 
 # Set to True to enable redirections or URLs from previous versions
 # of patchwork
-- 
2.11.0

___
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork


Re: title tag in a series list

2018-07-23 Thread Andrew Donnellan

On 23/07/18 22:28, Ali Alnubani wrote:

BTW,
Is it ok that the diff of my previous email was saved by patchwork 
(http://patchwork.ozlabs.org/patch/947699/) without it having 
git-send-email as the x-mailer?


I see that there are no restrictions in the code, should there be?


Yep, that's deliberate. There's enough people who for some reason send 
their patches without using git-send-email. Also not all projects that 
are monitored in patchwork are necessarily git projects, so patchwork 
will look for anything that matches a diff.



--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited

___
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork


RE: title tag in a series list

2018-07-23 Thread Ali Alnubani
BTW,
Is it ok that the diff of my previous email was saved by patchwork 
(http://patchwork.ozlabs.org/patch/947699/) without it having git-send-email as 
the x-mailer?
I see that there are no restrictions in the code, should there be?

Thanks,
Ali

From: Patchwork  On 
Behalf Of Ali Alnubani
Sent: Monday, July 23, 2018 2:48 PM
To: 'patchwork@lists.ozlabs.org' 
Cc: Thomas Monjalon 
Subject: title tag in a series list

Hi,

I'm trying to set the HTML title tag in a series filtered list as the series 
title instead of the project name.
I did something like the following, but it's not working (obviously):

diff --git a/patchwork/templates/patchwork/list.html 
b/patchwork/templates/patchwork/list.html
index 180c560..d7476d6 100644
--- a/patchwork/templates/patchwork/list.html
+++ b/patchwork/templates/patchwork/list.html
@@ -3,7 +3,13 @@
{% load person %}
{% load static %}

-{% block title %}{{project.name}}{% endblock %}
+{% if filters.applied_filters %}
+ {% for filter in filters.applied_filters %}
+  {% if filter.name ==  "Series" %}
+   {% block title %}{{filter.condition}}{% endblock %}
+  {% endif %}
+ {% endfor %}
+{% endif %}
{% block patch_active %}active{% endblock %}

{% block body %}


How can I get this to work?
Any suggestions for a better approach?

Thanks,
Ali
___
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork


title tag in a series list

2018-07-23 Thread Ali Alnubani
Hi,

I'm trying to set the HTML title tag in a series filtered list as the series 
title instead of the project name.
I did something like the following, but it's not working (obviously):

diff --git a/patchwork/templates/patchwork/list.html 
b/patchwork/templates/patchwork/list.html
index 180c560..d7476d6 100644
--- a/patchwork/templates/patchwork/list.html
+++ b/patchwork/templates/patchwork/list.html
@@ -3,7 +3,13 @@
{% load person %}
{% load static %}

-{% block title %}{{project.name}}{% endblock %}
+{% if filters.applied_filters %}
+ {% for filter in filters.applied_filters %}
+  {% if filter.name ==  "Series" %}
+   {% block title %}{{filter.condition}}{% endblock %}
+  {% endif %}
+ {% endfor %}
+{% endif %}
{% block patch_active %}active{% endblock %}

{% block body %}


How can I get this to work?
Any suggestions for a better approach?

Thanks,
Ali
___
Patchwork mailing list
Patchwork@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/patchwork