[PATCH 1/2] REST: Add 'has_version' helper

2019-09-08 Thread Stephen Finucane
We're going to use this functionality elsewhere shortly.

Signed-off-by: Stephen Finucane 
---
 patchwork/api/base.py  | 12 +++-
 patchwork/api/utils.py | 14 ++
 2 files changed, 17 insertions(+), 9 deletions(-)
 create mode 100644 patchwork/api/utils.py

diff --git a/patchwork/api/base.py b/patchwork/api/base.py
index 943afa21..89a43114 100644
--- a/patchwork/api/base.py
+++ b/patchwork/api/base.py
@@ -3,7 +3,6 @@
 #
 # SPDX-License-Identifier: GPL-2.0-or-later
 
-from distutils.version import StrictVersion
 
 from django.conf import settings
 from django.shortcuts import get_object_or_404
@@ -13,6 +12,8 @@ from rest_framework.response import Response
 from rest_framework.serializers import HyperlinkedIdentityField
 from rest_framework.serializers import HyperlinkedModelSerializer
 
+from patchwork.api import utils
+
 
 class LinkHeaderPagination(PageNumberPagination):
 """Provide pagination based on rfc5988.
@@ -90,17 +91,10 @@ class 
BaseHyperlinkedModelSerializer(HyperlinkedModelSerializer):
 instance)
 
 request = self.context.get('request')
-if not request or not request.version:
-# without version information, we have to assume the latest
-return data
-
-requested_version = StrictVersion(request.version)
-
 for version in getattr(self.Meta, 'versioned_fields', {}):
 # if the user has requested a version lower that than in which the
 # field was added, we drop it
-required_version = StrictVersion(version)
-if required_version > requested_version:
+if not utils.has_version(request, version):
 for field in self.Meta.versioned_fields[version]:
 data.pop(field)
 
diff --git a/patchwork/api/utils.py b/patchwork/api/utils.py
new file mode 100644
index ..7d46e846
--- /dev/null
+++ b/patchwork/api/utils.py
@@ -0,0 +1,14 @@
+# Patchwork - automated patch tracking system
+# Copyright (C) 2018 Stephen Finucane 
+#
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+from distutils.version import StrictVersion
+
+
+def has_version(request, version):
+if not request.version:
+# without version information, we have to assume the latest
+return True
+
+return StrictVersion(request.version) >= StrictVersion(version)
-- 
2.21.0

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


[PATCH 0/2] Add writeable 'bundles' API

2019-09-08 Thread Stephen Finucane
Hopefully self-explanatory. This closes another gap with the web UI and
REST API.

Stephen Finucane (2):
  REST: Add 'has_version' helper
  REST: Allow creating, updating, deleting of bundles

 docs/api/schemas/latest/patchwork.yaml| 170 +++-
 docs/api/schemas/patchwork.j2 | 181 +-
 docs/api/schemas/v1.0/patchwork.yaml  |   5 +-
 docs/api/schemas/v1.1/patchwork.yaml  |   5 +-
 docs/api/schemas/v1.2/patchwork.yaml  | 170 +++-
 patchwork/api/base.py |  12 +-
 patchwork/api/bundle.py   |  84 +++-
 patchwork/api/utils.py|  14 ++
 patchwork/models.py   |  11 ++
 patchwork/tests/api/test_bundle.py| 118 +++-
 patchwork/tests/api/utils.py  |  16 +-
 ...pdate-bundle-via-api-2946d8c4e730d545.yaml |   4 +
 12 files changed, 754 insertions(+), 36 deletions(-)
 create mode 100644 patchwork/api/utils.py
 create mode 100644 
releasenotes/notes/update-bundle-via-api-2946d8c4e730d545.yaml

-- 
2.21.0

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


Re: [PATCH 3/3] docker: Use pyenv for Python versions

2019-09-08 Thread Stephen Finucane
On Tue, 2019-09-03 at 18:03 +0100, Stephen Finucane wrote:
> This is slightly slower to initially configure but requires less hacking
> to get the same environment and should be a lot more maintainable (just
> a simple modification to change the Python version).
> 
> Signed-off-by: Stephen Finucane 

This is somewhat more complex than the other two patches in the series,
but I've been playing around with it locally and it seems to do what I
wanted. I've gone ahead and applied this on the assumption that we can
easily revert it if necessary.

Stephen

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


Re: [PATCH 2/3] docker: Simplify MySQL reset

2019-09-08 Thread Stephen Finucane
On Tue, 2019-09-03 at 18:03 +0100, Stephen Finucane wrote:
> Just use the hardcoded configuration.
> 
> Signed-off-by: Stephen Finucane 

Trivial fix. Applied.

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


Re: [PATCH] sql: Fix table lists

2019-09-08 Thread Stephen Finucane
On Sun, 2019-09-08 at 07:13 +, Ali Alnubani wrote:
> Thanks Stephen.
> 
> I see the following section in the docs 
> https://patchwork.readthedocs.io/en/latest/deployment/installation/#mail-transfer-agent-mta:
> """
> This assumes your Postfix process is running as the nobody user. If
> this is not correct (use of postfix user is also common), you should
> change both the username in the createuser command above and
> substitute the username in the grant-all-postgres.sql script with the
> appropriate alternative.
> """
> But I believe that it doesn’t have to be the user running the postfix process,
> It's the permissions defined by postfix's conf default_privs:
> http://www.postfix.org/postconf.5.html#default_privs
> 
> Can you confirm my thought?

To be honest, I'll have to let somone else answer this. I wrote that
quite a long time ago and haven't really touched it since, so I've long
since forgotten the reason I included that /o\ What you've said does
make sense though, so if you've tested it and it works as expected or
you can find a blog that says the same thing, I'd be happy to accept a
patch to correct this.

Sorry I can't be of more help,
Stephen

> Thanks,
> Ali
> 
> > -Original Message-
> > From: Stephen Finucane 
> > Sent: Friday, September 6, 2019 4:31 PM
> > To: Ali Alnubani ; patchwork@lists.ozlabs.org
> > Cc: Thomas Monjalon 
> > Subject: Re: [PATCH] sql: Fix table lists
> > 
> > On Wed, 2019-09-04 at 13:40 +, Ali Alnubani wrote:
> > > The patch adds missing commas in the table lists where missing, and
> > > removes where unnecessary.
> > > This fixes errors such as the following when feeding the script to
> > > psql:
> > > 
> > > ```
> > > psql:lib/sql/grant-all.postgres.sql:37: ERROR:  syntax error at or
> > > near "patchwork_emailconfirmation"
> > > LINE 19:  patchwork_emailconfirmation, ...
> > > ```
> > > 
> > > Fixes: ca0e79d4db34 ("sql: Sort 'grant-all' scripts alphabetically")
> > > 
> > > Signed-off-by: Ali Alnubani 
> > 
> > Nicely done. Applied and backported to stable/2.1.
> > 
> > Thanks!
> > 
> > Stephen

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


[PATCH] requirements: Switch to compatible releases

2019-09-08 Thread Stephen Finucane
In commit ab0c443691, we switched from using commit ranges to fixed
ranges. This was a good idea in so far as it ensures we're providing an
application with dependencies that are guaranteed to work. However,
Patchwork as a project isn't active enough to warrant the continued busy
work effort necessary to keep bumping these versions and it's probably
about time to abandon the experiment. However, rather than switching
back to version ranges, use the compatible releases feature introduced
in PEP 440 [1]. This gives us most of the benefits of ranges but with a
nicer syntax.

[1] https://www.python.org/dev/peps/pep-0440/#compatible-release

Signed-off-by: Stephen Finucane 
Cc: Daniel Axtens 
---
 requirements-dev.txt  | 14 +++---
 requirements-prod.txt | 14 +++---
 requirements-test.txt | 10 +-
 3 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/requirements-dev.txt b/requirements-dev.txt
index 35ead6f9..ee0e10b6 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -1,8 +1,8 @@
-Django==2.2.5; python_version >= '3.5'
-Django==1.11.24; python_version < '3.0'  # pyup: ignore
-djangorestframework==3.9.2
-django-filter==2.1.0; python_version >= '3.5'
-django-filter==1.1.0; python_version < '3.0'  # pyup: ignore
-django-debug-toolbar==1.11
-django-dbbackup==3.2.0
+Django~=2.2; python_version >= '3.5'
+Django~=1.11; python_version < '3.0'  # pyup: ignore
+djangorestframework~=3.9
+django-filter~=2.1; python_version >= '3.5'
+django-filter~=1.1; python_version < '3.0'  # pyup: ignore
+django-debug-toolbar~=1.11
+django-dbbackup~=3.2
 -r requirements-test.txt
diff --git a/requirements-prod.txt b/requirements-prod.txt
index ba950f7a..92b44079 100644
--- a/requirements-prod.txt
+++ b/requirements-prod.txt
@@ -1,7 +1,7 @@
-Django==2.2.5; python_version >= '3.5'
-Django==1.11.24; python_version < '3.0'  # pyup: ignore
-djangorestframework==3.9.2
-django-filter==2.1.0; python_version >= '3.5'
-django-filter==1.1.0; python_version < '3.0'  # pyup: ignore
-psycopg2-binary==2.8.2
-sqlparse==0.3.0
+Django~=2.2; python_version >= '3.5'
+Django~=1.11; python_version < '3.0'  # pyup: ignore
+djangorestframework~=3.9
+django-filter~=2.1; python_version >= '3.5'
+django-filter~=1.1; python_version < '3.0'  # pyup: ignore
+psycopg2-binary~=2.8
+sqlparse~=0.3
diff --git a/requirements-test.txt b/requirements-test.txt
index 0ad3c8aa..ace4ec13 100644
--- a/requirements-test.txt
+++ b/requirements-test.txt
@@ -1,5 +1,5 @@
-mysqlclient==1.3.14
-psycopg2-binary==2.8.2
-sqlparse==0.3.0
-python-dateutil==2.8.0
-openapi-core==0.8.0
+mysqlclient~=1.3.14
+psycopg2-binary~=2.8
+sqlparse~=0.3.0
+python-dateutil~=2.8
+openapi-core~=0.8
-- 
2.21.0

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


Re: [PATCH 1/3] Drop support for Python 3.4, add Python 3.7

2019-09-08 Thread Stephen Finucane
On Tue, 2019-09-03 at 18:03 +0100, Stephen Finucane wrote:
> It's no longer supported upstream and the *second* last Ubuntu LTS
> release provides something newer. Time to move on.
>
> Signed-off-by: Stephen Finucane 

I've applied this albeit with a couple of other fixes I missed
(.travis.yml and a release note) since it was blocking some dependency
updates.

Stephen

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


RE: [PATCH] sql: Fix table lists

2019-09-08 Thread Ali Alnubani
Thanks Stephen.

I see the following section in the docs 
https://patchwork.readthedocs.io/en/latest/deployment/installation/#mail-transfer-agent-mta:
"""
This assumes your Postfix process is running as the nobody user. If this is not 
correct (use of postfix user is also common), you should change both the 
username in the createuser command above and substitute the username in the 
grant-all-postgres.sql script with the appropriate alternative.
"""
But I believe that it doesn’t have to be the user running the postfix process,
It's the permissions defined by postfix's conf default_privs:
http://www.postfix.org/postconf.5.html#default_privs

Can you confirm my thought?

Thanks,
Ali

> -Original Message-
> From: Stephen Finucane 
> Sent: Friday, September 6, 2019 4:31 PM
> To: Ali Alnubani ; patchwork@lists.ozlabs.org
> Cc: Thomas Monjalon 
> Subject: Re: [PATCH] sql: Fix table lists
> 
> On Wed, 2019-09-04 at 13:40 +, Ali Alnubani wrote:
> > The patch adds missing commas in the table lists where missing, and
> > removes where unnecessary.
> > This fixes errors such as the following when feeding the script to
> > psql:
> >
> > ```
> > psql:lib/sql/grant-all.postgres.sql:37: ERROR:  syntax error at or
> > near "patchwork_emailconfirmation"
> > LINE 19:  patchwork_emailconfirmation, ...
> > ```
> >
> > Fixes: ca0e79d4db34 ("sql: Sort 'grant-all' scripts alphabetically")
> >
> > Signed-off-by: Ali Alnubani 
> 
> Nicely done. Applied and backported to stable/2.1.
> 
> Thanks!
> 
> Stephen

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