]> git.ipfire.org Git - thirdparty/patchwork.git/log
thirdparty/patchwork.git
8 years agopwclient: Force xmlrpc client to return unicode strings
Robin Jarry [Tue, 23 May 2017 13:24:07 +0000 (15:24 +0200)] 
pwclient: Force xmlrpc client to return unicode strings

On python 2, the reference implementation of the XML-RPC unmarshaller
decodes strings to unicode with the selected encoding (utf-8 by default)
but it tries to re-encode the unicode strings to ascii bytes before
returning the values. If it fails, it leaves the value as unicode.

See these links for more details:

  https://hg.python.org/cpython/file/2.7/Lib/xmlrpclib.py#l878
  https://hg.python.org/cpython/file/2.7/Lib/xmlrpclib.py#l180

  https://hg.python.org/cpython/file/3.6/Lib/xmlrpc/client.py#l753

Monkey-patch the internal xmlrpclib._stringify() function only on python
2 to force it to preserve unicode strings. This allows to have similar
behaviour in both python 2 and python 3.

Signed-off-by: Robin Jarry <robin.jarry@6wind.com>
Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREST: Allow filtering by both project ID and linkname v2.0.0-rc2
Stephen Finucane [Thu, 18 May 2017 22:25:26 +0000 (23:25 +0100)] 
REST: Allow filtering by both project ID and linkname

In hindsight, it's a bit odd that we would filter project by linkname by
everything else by ID. Simply support both.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: e27b68a ("REST: Filter on Project.linkname - not Project.pk")
8 years agoUpdate django-debug-toolbar from 1.7 to 1.8
pyup-bot [Fri, 5 May 2017 07:58:13 +0000 (08:58 +0100)] 
Update django-debug-toolbar from 1.7 to 1.8

Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agotox: Don't use exceptions - just warn
Stephen Finucane [Thu, 18 May 2017 20:54:57 +0000 (21:54 +0100)] 
tox: Don't use exceptions - just warn

It seems Django uses deprecated items in Python 3.x, meaning we can't
use this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 9db5cd0 ("tox: Turn deprecation notices into warnings")
8 years agotemplates: Use compat.cycle everywhere
Stephen Finucane [Thu, 18 May 2017 20:40:04 +0000 (21:40 +0100)] 
templates: Use compat.cycle everywhere

We missed this previously and now it's breaking Django 1.6.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 8ae7705 ("templates: Resolve cycle issues with Django 1.10")
8 years agosettings: 'XViewMiddleware' is moved in Django 1.6 too
Stephen Finucane [Thu, 18 May 2017 20:35:58 +0000 (21:35 +0100)] 
settings: 'XViewMiddleware' is moved in Django 1.6 too

This was causing a deprecation warning. Clearly we don't need to special
case Django 1.6 here.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 9db5cd0 ("tox: Turn deprecation notices into warnings")
8 years agomodels: Only set 'base_manager_name' for Django >= 1.10
Stephen Finucane [Thu, 18 May 2017 20:33:00 +0000 (21:33 +0100)] 
models: Only set 'base_manager_name' for Django >= 1.10

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 8585ea5 ("models: Use 'base_manager_name'")
8 years agosettings: Enable 'XFrameOptionsMiddleware'
Stephen Finucane [Thu, 18 May 2017 20:23:59 +0000 (21:23 +0100)] 
settings: Enable 'XFrameOptionsMiddleware'

This provides basic click jacking protection. This was identified using
'manage.py check --deploy'.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREST: Resolve issues with filters
Stephen Finucane [Mon, 15 May 2017 23:13:37 +0000 (00:13 +0100)] 
REST: Resolve issues with filters

Turns out filtering patches using a series string wasn't as easy as we
thought. We need to slugify State.name, but unfortunately that isn't
stored in the database. The tests were hiding this fact as State objects
created by 'tests.utils.create_state' don't have spaces in them.

Override custom versions of both django-filter's 'Filter' class and
the Django 'Form' required by this, and update the tests to prevent a
regression.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 6222574 ("REST: filter patches by state name")
Tested-by: Philippe Pepiot <philippe.pepiot@logilab.fr>
8 years agoREST: Filter on Project.linkname - not Project.pk
Stephen Finucane [Mon, 15 May 2017 23:13:36 +0000 (00:13 +0100)] 
REST: Filter on Project.linkname - not Project.pk

This is what we expect based on the web UI.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREST: Embed nested element bodies instead of URLs
Stephen Finucane [Mon, 15 May 2017 23:13:34 +0000 (00:13 +0100)] 
REST: Embed nested element bodies instead of URLs

In developing a client for the Patchwork REST API, git-pw, it was noted
that it should be possible to embed some information about nested
resources in order to prevent the need for additional requests [1]. It
was seen that this would be particularly beneficial for list operations,
where each element in the N sized list could theoretically require an
additional request for each of the M nested fields, resulting in N * (M
+ 1) total requests.

Upon experimenting with the 2.0 RC1 API, this optimization was found to
be less of a nice-to-have (and possibly something for the 2.1 release)
and more of a must-have, particularly once one took network latency for
each request into account. During testing with 'git-pw', simple list
operations were found to take an average of 31 requests per operation,
of which only one for was the resource endpoint itself ('GET
/api/series'). As each of these requests took ~2 seconds a piece,
listing was essentially broken.

While local caching could be used to offset some of this demand, this
will result in (a) significantly larger, more complex clients or (b)
instances that strain under the load of dumb clients making multiple
requests per operation. Instead, the server should be smarter about
embedding the data that would actually be required by clients.

Resolve the issue by embedding summarized versions of various nested
fields instead of merely linking to them. Nesting is only a single level
deep, to avoid large/complex database queries and with the expectation
that only these basic fields (resource names, dates, etc.) would be
required. These summary serializers are kept in their own module, to
encourage consistent results throughout the API and to prevent circular
import errors.

This will have the side effect of slightly increasing load on the server
due to the additional serialization required. However, this load is
largely mitigated through the avoidance of deeper nesting as noted
above. In addition, any increase in load seen will be a fraction of the
demand that repeat requests will incur. While it would be possible to
make nesting optional (by way of an 'embed' or 'expand' parameter), it
is expected that this would be an atypical request and would result in
far more complicated serialization code.

[1] https://github.com/stephenfin/git-pw/blob/21e0e593/git_pw/patch.py#L88-L89

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREST: Embed 'mbox' parameter in /series
Stephen Finucane [Mon, 15 May 2017 23:13:31 +0000 (00:13 +0100)] 
REST: Embed 'mbox' parameter in /series

This wasn't added in '6deedfb7' but it should have been.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 6deedfb7 ("views: Expose Series mbox")
8 years agoREST: Stop including 'tags' in '/patches'
Stephen Finucane [Mon, 15 May 2017 23:13:29 +0000 (00:13 +0100)] 
REST: Stop including 'tags' in '/patches'

While this is a very helpful field to include, doing so significantly
increases the number of DB queries necessary for listing patches (from
~14 to ~46). Stop including this information until the model itself is
reworked to prevent this issue.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREST: Correct some prefetch, select_related
Stephen Finucane [Mon, 15 May 2017 23:13:27 +0000 (00:13 +0100)] 
REST: Correct some prefetch, select_related

There were two issues here:

- The 'get_queryset' function, rather than the 'queryset' attribute,
  must be overriden when using either the 'prefetch_related' or
  'select_related' functions

- A couple of endpoints contained a 'project' attribute, but this wasn't
  being prefetched. This didn't cause issues in a single-project
  deployment, as used in testing, but will for larger deployments

Resolve both issues.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agotox: Turn deprecation notices into warnings
Stephen Finucane [Thu, 18 May 2017 20:17:48 +0000 (21:17 +0100)] 
tox: Turn deprecation notices into warnings

Django does an excellent job of marking what features are going to
change in upcoming releases through extensive use of the 'warnings' module.

Pass the '-Werror' flag to 'manage.py' in tests, ensuring that any
warnings will result in exceptions instead. This should make upgrades a
mostly painless process going forward.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agocompat: Handle is_authenticated move to property
Stephen Finucane [Thu, 18 May 2017 20:17:46 +0000 (21:17 +0100)] 
compat: Handle is_authenticated move to property

This raises a warning in Django 1.10 and will cause an error in 2.0.

This resolves all issues with Django 1.9.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agosettings: Use 'MIDDLEWARE' for Django >= 1.10
Stephen Finucane [Thu, 18 May 2017 20:17:44 +0000 (21:17 +0100)] 
settings: Use 'MIDDLEWARE' for Django >= 1.10

This raises warnings in Django 1.10 and will be mandatory in Django 2.0.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agocompat: Handle moved 'reverse' function
Stephen Finucane [Thu, 18 May 2017 20:17:43 +0000 (21:17 +0100)] 
compat: Handle moved 'reverse' function

This raises a warning in Django 1.10 and will cause an error in 2.0.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agomodels: Use 'base_manager_name'
Stephen Finucane [Thu, 18 May 2017 20:17:41 +0000 (21:17 +0100)] 
models: Use 'base_manager_name'

This raises warnings in Django 1.10 and will be required in Django 1.11.

We also set 'silence_use_for_related_fields_deprecation' to allow us to
retain the current behavior on versions of Django < 1.10.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agourls: Don't "include" admin URLs
Stephen Finucane [Thu, 18 May 2017 20:17:40 +0000 (21:17 +0100)] 
urls: Don't "include" admin URLs

This raises a warning in Django 1.9 and will cause an error in Django
2.0. Per the documentation [1] it is not even necessary so it can simply
be removed.

This resolves all issues with Django 1.9.

[1] https://docs.djangoproject.com/en/1.11/ref/contrib/admin/\
      #hooking-adminsite-instances-into-your-urlconf

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agomigrations: Explicitly set 'on_delete'
Stephen Finucane [Thu, 18 May 2017 20:17:38 +0000 (21:17 +0100)] 
migrations: Explicitly set 'on_delete'

This raises warnings for Django 1.9 and will be mandatory in Django 2.0.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agomodels: Explicitly set 'on_delete'
Stephen Finucane [Thu, 18 May 2017 20:17:37 +0000 (21:17 +0100)] 
models: Explicitly set 'on_delete'

This raises warnings in Django 1.9 and will be mandatory in Django 2.0.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agosettings: Enable 'SessionAuthenticationMiddleware'
Stephen Finucane [Thu, 18 May 2017 20:17:35 +0000 (21:17 +0100)] 
settings: Enable 'SessionAuthenticationMiddleware'

This raises warnings for Django 1.8 and is mandatory in Django 1.10. It
provides a helpful feature, invalidating a user's session when their
password is changed, and can/should be enabled.

This resolves all issues with Django 1.8.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Don't mention 'default_project' in deployment guide
Stephen Finucane [Thu, 18 May 2017 13:42:19 +0000 (14:42 +0100)] 
docs: Don't mention 'default_project' in deployment guide

The deployment guide currently suggests using the 'default_project'
fixture when deploying a production installation of Patchwork. While one
_could_ use this, it's generally unnecessary given that most people care
about their own projects and not Patchwork.

Resolve this by simply removing any references. The references are
retained for the development installation guide, as they're likely
useful here.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agolib/apache2: Update location to wsgi python script
Florian Fainelli [Thu, 11 May 2017 23:25:30 +0000 (16:25 -0700)] 
lib/apache2: Update location to wsgi python script

Commit 8fe68d96f18e ("wsgi: Move wsgi file to expected location")
relocated lib/apache2/patchwork.wsgi to patchwork/wsgi.py but did not
update the Apache2 example configuration file under
lib/apache2/patchwork.wsgi.conf.

Fixes: 8fe68d96f18e ("wsgi: Move wsgi file to expected location")
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Document Check.context type change
Stephen Finucane [Wed, 10 May 2017 15:19:12 +0000 (11:19 -0400)] 
docs: Document Check.context type change

Check contexts must now be slugs. Document this in the release notes.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agosettings: Enable the REST API by default v2.0.0-rc1
Stephen Finucane [Thu, 4 May 2017 18:51:12 +0000 (19:51 +0100)] 
settings: Enable the REST API by default

The release notes say this is already the case. As the API is now
functionally complete, there's no reason not to toggle this. Make it so.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agolib: Correct typo in uWSGI config file
Stephen Finucane [Thu, 4 May 2017 18:27:58 +0000 (19:27 +0100)] 
lib: Correct typo in uWSGI config file

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reported-by: Philippe Pepiot <philippe.pepiot@logilab.fr>
Fixes: 150f6150 ("lib: Update uWSGI, nginx config files")
8 years agotox: Always recreate docs
Stephen Finucane [Thu, 4 May 2017 18:27:05 +0000 (19:27 +0100)] 
tox: Always recreate docs

The reno extension doesn't seem to trigger an environment rebuild. Force
this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodoc: The REST API can now be used with Django < 1.8
Stephen Finucane [Thu, 4 May 2017 18:26:58 +0000 (19:26 +0100)] 
doc: The REST API can now be used with Django < 1.8

The release notes stated that the REST API was only compatible with
Django 1.8. However, with the merge of commit '646366cc', this is no
longer the case.

We would rather people didn't use these older versions of Django, but
let's not lie.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Add pre-release regex
Stephen Finucane [Thu, 4 May 2017 18:26:51 +0000 (19:26 +0100)] 
docs: Add pre-release regex

...in preparation for 'v2.0.0-rc1'.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Update installation guide for Ubuntu 16.04
Stephen Finucane [Mon, 1 May 2017 23:45:57 +0000 (00:45 +0100)] 
docs: Update installation guide for Ubuntu 16.04

Use the latest LTS version of Ubuntu. This is mostly a simplification of
the guide, which reverts back to single-node configuration and increases
the emphasis on installing system packages rather than using 'pip'.
There are also a series of corrections, mostly around using the Python 3
variants of packages.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agolib: Update uWSGI, nginx config files
Stephen Finucane [Mon, 1 May 2017 23:47:51 +0000 (00:47 +0100)] 
lib: Update uWSGI, nginx config files

The nginx file was a replacement for '/etc/nginx/nginx.conf' instead of
a "site" file, while the uWSGI file referenced the Python 2 plugin
despite the sample deployment guide, which uses this, being Python
3-based. Correct both issues.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREST: Add 'category' filter to '/events'
Stephen Finucane [Wed, 3 May 2017 14:25:07 +0000 (15:25 +0100)] 
REST: Add 'category' filter to '/events'

There doesn't appear to be any reason that this _can't_ be included, and
it does make the resource a little more usable.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agomodels: Series plural name is Series
Philippe Pepiot [Thu, 4 May 2017 09:45:04 +0000 (11:45 +0200)] 
models: Series plural name is Series

By default django use verbose_name + s which lead 'Seriess'
displayed in admin interface.

Signed-off-by: Philippe Pepiot <philippe.pepiot@logilab.fr>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agoREST: filter patches by state name
Philippe Pepiot [Wed, 3 May 2017 11:43:04 +0000 (13:43 +0200)] 
REST: filter patches by state name

Since we display the name of the state in the serialized patch, also
filter by name instead of primary key.

Also this will be consistent with the current documentation examples
(curl 'https://patchwork.example.com/api/patches?state=under-review')

Signed-off-by: Philippe Pepiot <philippe.pepiot@logilab.fr>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agopwclient: Fix silent crash on python 2
Robin Jarry [Tue, 2 May 2017 14:51:51 +0000 (16:51 +0200)] 
pwclient: Fix silent crash on python 2

Replacing sys.stdout and sys.stderr can cause obscure crashes when
trying to write non unicode data. The interpreter is terminated with
SIGINT without any specific error writen on the console.

  rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7f964820e8d0},
  {0x559f50, [], SA_RESTORER, 0x7f964820e8d0}, 8) = 0

This happens easily when there is an untrapped exception which should
lead to printing a traceback on stderr.

The only way to prevent UnicodeEncodeErrors is to make sure that one of
the locale-related environment variables (LC_ALL, LANG, LANGUAGE, etc.)
is set. Python will use the correct encoding accordingly.

Add a note about this on `pwclient --help`. Also, display a help message
when an encoding error occurs.

Fixes: 046419a3bf8f ("pwclient: Fix encoding problems")
Signed-off-by: Robin Jarry <robin.jarry@6wind.com>
Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Misc fixes
Stephen Finucane [Sat, 29 Apr 2017 00:32:23 +0000 (01:32 +0100)] 
docs: Misc fixes

Add release note requirement to contributing and fix some issues with
the development installation guide.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Emphasise the cron job
Stephen Finucane [Sat, 29 Apr 2017 00:13:06 +0000 (01:13 +0100)] 
docs: Emphasise the cron job

Having talked to a few folks deploying Patchwork, it appears not
everyone is aware of/enabling the Patchwork cron job. Emphasise this
feature by moving it to its own section. This section is marked as
optional, given that it's not truly required but is helpful.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Add a configuration guide
Stephen Finucane [Fri, 28 Apr 2017 23:46:55 +0000 (00:46 +0100)] 
docs: Add a configuration guide

This should simplify matters for folks that don't have much experience
with Django. It also serves to highlight the 'ENABLE_REST_API' option.

A release note is also added to capture the rename of
DEFAULT_PATCHES_PER_PAGE that has occurred during this cycle.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREST: Allow users to omit version entirely
Stephen Finucane [Wed, 26 Apr 2017 23:58:04 +0000 (00:58 +0100)] 
REST: Allow users to omit version entirely

This is super handy for debugging/development of Patchwork and Patchwork
clients alike.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREST: Fix versioning
Stephen Finucane [Wed, 26 Apr 2017 23:58:03 +0000 (00:58 +0100)] 
REST: Fix versioning

One of the few remaining warts in the API is versioning. There is some
basic versioning there, but it doesn't work properly as-is. Fix this by
correcting the index endpoint ('/') to use Django REST Framework's
'reverse' function [1], which handles versioning for us [2] and
switching from 'NamespaceVersioning' to 'URLPathVersioning', the latter
of which does the same thing but in a different way.

[1] http://www.django-rest-framework.org/api-guide/reverse/#reverse
[2] http://www.django-rest-framework.org/api-guide/versioning/#reversing-urls-for-versioned-apis
[3] http://www.django-rest-framework.org/api-guide/versioning/#urlpathversioning

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoAdd release note for Mercurial series support
Stephen Finucane [Fri, 28 Apr 2017 22:28:36 +0000 (23:28 +0100)] 
Add release note for Mercurial series support

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoparser: detect mercurial series markers
Philippe Pepiot [Fri, 28 Apr 2017 16:14:42 +0000 (18:14 +0200)] 
parser: detect mercurial series markers

Unlike git, Mercurial series marker uses the format "M of N", handle
this in the subject parser.

Test code original author is Andrew Shadura <andrew.shadura@collabora.co.uk>

Signed-off-by: Philippe Pepiot <philippe.pepiot@logilab.fr>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agorequirements: Test older versions of DRF (v2)
Stephen Finucane [Tue, 4 Apr 2017 21:38:19 +0000 (22:38 +0100)] 
requirements: Test older versions of DRF (v2)

In commit febad055, we attempted to start testing older versions of
Django REST Framework for use with older versions of Django. This work
was later reverted in commit 6f2ddab6 due to issues with 'django-filter'
versions.

There are additional reasons for validating older versions of DRF, such
as supporting the versions provide as part of distributions. It turns
out that those issues aren't such a big deal and can be handled with a
shim. All in all, this means we can and should support these older
versions of Django REST Framework, and that is what we'll do.

Note that the minimum version supported in requirements.txt is not
changed as it's good practice to use the latest available version.
However, that doesn't make it any less supported.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agocompat: Add non-None queryset attribute
Stephen Finucane [Tue, 4 Apr 2017 21:38:18 +0000 (22:38 +0100)] 
compat: Add non-None queryset attribute

Older versions of Django REST Framework's 'RelatedField' did not check
for the presence 'get_queryset' before checking for a 'queryset'
attribute. This was fixed in 3.4.0 [1] and backported to the 3.3 series
in 3.3.3 [2]. However, the fix was not backported to the last release of
3.2 series [3], which is the last release to support Django 1.6. As
such, we must set a 'queryset' attribute, even if it's set to a garbage
value.

[1] ../blob/3.4.0/rest_framework/relations.py#L78-L82
[2] ../blob/3.3.3/rest_framework/relations.py#L78-L82
[3] ../blob/3.2.5/rest_framework/relations.py#L64-L67

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes-bug: #94

8 years agocompat: Handle older versions of django-filter
Stephen Finucane [Tue, 4 Apr 2017 21:38:17 +0000 (22:38 +0100)] 
compat: Handle older versions of django-filter

Recent versions of Django REST Framework (DRF) have deprecated the
'DjangoFilterBackend' filter found in-tree, in favour of an equivalent
implementation found in django-filter. However, we need to support older
versions of DRF for users who want to use system packages.

Seeing as the two implementations are, for all intents and purposes,
essentially the same thing, provide a shim that will allow us to use
both together.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Partial-bug: #94

8 years agodocs: Split API docs into their own section
Stephen Finucane [Wed, 26 Apr 2017 21:45:33 +0000 (22:45 +0100)] 
docs: Split API docs into their own section

Third time lucky. There are two changes:

- Add a new 'clients' section to the usage doc, allowing us to remove a
  lot of the API nitty gritty stuff from the users guide. This makes
  more sense as users don't really care what API method they're using -
  only what application).

- Change the API docs from the developers guide into a quick start
  section, allowing us to greatly expand the REST API docs to include
  information on pagination, authentication, etc.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agorequirements: Remove docs requirements
Stephen Finucane [Wed, 26 Apr 2017 15:06:37 +0000 (16:06 +0100)] 
requirements: Remove docs requirements

This was causing issues in the Docker build and is unnecessary with tox
around. Simply drop this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREADME: Additional link fixes
Stephen Finucane [Sun, 23 Apr 2017 12:32:34 +0000 (13:32 +0100)] 
README: Additional link fixes

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREADME: Fix badges
Stephen Finucane [Sun, 23 Apr 2017 12:31:08 +0000 (13:31 +0100)] 
README: Fix badges

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREADME: Fix broken links
Stephen Finucane [Sun, 23 Apr 2017 12:27:37 +0000 (13:27 +0100)] 
README: Fix broken links

Nested markup doesn't work that well in rST.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Add REST API usage guide
Stephen Finucane [Sun, 23 Apr 2017 12:14:30 +0000 (13:14 +0100)] 
docs: Add REST API usage guide

This details the availability of 'git-pw'. The other API usage and
development guides are updated accordingly.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Migrate release notes to rST
Stephen Finucane [Wed, 22 Mar 2017 23:03:00 +0000 (23:03 +0000)] 
docs: Migrate release notes to rST

This allows us to remove both UPGRADING and CHANGELOG.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoAdd reno for release notes management
Stephen Finucane [Wed, 22 Mar 2017 23:17:27 +0000 (23:17 +0000)] 
Add reno for release notes management

An initial patch to add reno and create a base directory for release
notes.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Remove old Markdown files
Stephen Finucane [Wed, 22 Mar 2017 23:17:25 +0000 (23:17 +0000)] 
docs: Remove old Markdown files

Everything is now ported to rST/Sphinx meaning we can remove the
Markdown versions.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Convert development guide
Stephen Finucane [Wed, 22 Mar 2017 23:17:22 +0000 (23:17 +0000)] 
docs: Convert development guide

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Convert deployment guide
Stephen Finucane [Tue, 18 Apr 2017 20:57:46 +0000 (21:57 +0100)] 
docs: Convert deployment guide

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Covert usage guide
Stephen Finucane [Wed, 22 Mar 2017 23:17:16 +0000 (23:17 +0000)] 
docs: Covert usage guide

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Convert README, index
Stephen Finucane [Wed, 22 Mar 2017 23:17:13 +0000 (23:17 +0000)] 
docs: Convert README, index

We can remove the Markdown README but must keep the index page until all
docs are migrated.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Add skeleton for Sphinx docs
Stephen Finucane [Wed, 22 Mar 2017 23:17:08 +0000 (23:17 +0000)] 
docs: Add skeleton for Sphinx docs

This is mostly the output of 'sphinx-quickstart' with all non-HTML build
cruft removed and Sphinx minimum version set to 1.5. A tox target is
included and the output of the docs build ignored.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoDisplay count of patches
Daniel Axtens [Mon, 27 Mar 2017 05:42:52 +0000 (16:42 +1100)] 
Display count of patches

Minor UI tweak - show the number of patches left in the current
view.

Suggested-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years ago'mpe mode': click to copy patch IDs
Daniel Axtens [Mon, 27 Mar 2017 05:42:51 +0000 (16:42 +1100)] 
'mpe mode': click to copy patch IDs

If 'Show Patch IDs' is turned on in settings, add an extra column
to the patch list, with buttons showing the patch IDs. The buttons
copy the patch IDs to the clipboard.

JavaScript inspired by https://github.com/Triforcey/clip-j and many
many StackOverflow answers.

Suggested-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agoPut download buttons at the top as well
Daniel Axtens [Mon, 27 Mar 2017 05:42:50 +0000 (16:42 +1100)] 
Put download buttons at the top as well

Suggested by a few people.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agoparser: Don't extract diffs from replies
Stephen Finucane [Sun, 9 Apr 2017 15:08:40 +0000 (16:08 +0100)] 
parser: Don't extract diffs from replies

In '2a915efd', a check was added to ensure mails prefixed with 'RE:' or
similar would not be parsed as patches. By time this check actually
happens, any patches had already been extracted from the mail thus these
patches were re-added to the mail content before saving the comment.
Unfortunately, this didn't take into account cases where a patch or diff
was not the last part of a mail but rather located somewhere in the
middle of the content:

    Introduction content
    Diff or patch content ***
    Additional content

This would result in mangling of the mail as the patch would _always_ be
appended to the end:

    Introduction content
    Additional content
    Diff or patch content ***

Handle this by only breaking a mail into a comment and a diff if there
is any possibility that we might want to use that diff.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 2a915efd ("parser: fix wrong parsing of diff comments")
Closes-bug: #95

8 years agoparsearchive: Support maildirs
Stephen Finucane [Sun, 9 Apr 2017 17:14:03 +0000 (18:14 +0100)] 
parsearchive: Support maildirs

At present, the 'parsearchive' command only supports parsing of mboxes.
Expand this to support maildirs. This allows us to rewrite the
'parsemail-bulk' script to deliver much improved performance.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Suggested-by: Daniel Axtens <dja@axtens.net>
8 years agosql: Update permissions on grant-all scripts
Stephen Finucane [Sun, 9 Apr 2017 18:08:49 +0000 (19:08 +0100)] 
sql: Update permissions on grant-all scripts

Allow access to Submission, CoverLetter, Series, SeriesReference and
SeriesPatch.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoCapture stderr for 'git describe'
Stephen Finucane [Thu, 13 Apr 2017 20:48:21 +0000 (21:48 +0100)] 
Capture stderr for 'git describe'

Capture the error messages thrown if git is not installed.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 7b07b71e ("templates: Add Patchwork version")
8 years agoDon't limit selenium to the any MINOR version
pyup-bot [Wed, 8 Mar 2017 12:21:10 +0000 (12:21 +0000)] 
Don't limit selenium to the any MINOR version

8 years agoUpdate djangorestframework from 3.5 to 3.6
pyup-bot [Thu, 9 Mar 2017 15:28:15 +0000 (15:28 +0000)] 
Update djangorestframework from 3.5 to 3.6

8 years agoparser: cut off patch names after 255 characters
Daniel Axtens [Mon, 27 Mar 2017 05:01:13 +0000 (16:01 +1100)] 
parser: cut off patch names after 255 characters

Our model limits the length of patch names to 255 characters.
Enforce this cutoff in the parser, otherwise we throw an
exception and fail to store patches with stupidly long titles.

Reported-by: Russell Currey <ruscur@russell.cc>
Signed-off-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoviews: Link to project from bundle-list
Stephen Finucane [Thu, 23 Mar 2017 13:25:01 +0000 (13:25 +0000)] 
views: Link to project from bundle-list

Simple usability improvement.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoviews: Use bundle-detail for public URLs
Stephen Finucane [Thu, 23 Mar 2017 13:25:00 +0000 (13:25 +0000)] 
views: Use bundle-detail for public URLs

In 'd1c605f', we reworked the 'bundle-list' view to use the new
'Bundle.get_mbox_url' function instead of the 'Bundle.public_url'.
However, these are not the same thing. The latter referred to the
'bundle-detail' view, while the former referred to the 'bundle-mbox'
view.

The easiest fix would be to simply revert that patch. However, it turns
out that 'public_url' isn't actually needed. Commit '5d0140ef' removed a
divide between public and non-public URLs for bundles, meaning we can
actually use an existing function - 'get_absolute_url' - instead.

This also presents the opportunity to clean up the 'bundle-list' page,
favouring a simple public/is-not-public marker and only a single URL.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: d1c605f9 ("views: Stop using Bundle.public_url")
Closes-bug: #92

8 years agoxmlrpc: Remove 'bundle_to_dict'
Stephen Finucane [Thu, 23 Mar 2017 13:24:59 +0000 (13:24 +0000)] 
xmlrpc: Remove 'bundle_to_dict'

Turns out this function is not called anywhere nor has it been called
since being introduced in '83964878'. Given that we're now focused on
the REST API, we can simply remove this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoviews: Support wildcarded 'series' parameter
Stephen Finucane [Tue, 21 Mar 2017 11:30:14 +0000 (11:30 +0000)] 
views: Support wildcarded 'series' parameter

There are many times that we would want to just test against the latest
series. Make this possible by wildcarding, like so:

    GET /patch/{patchID}/mbox/?series=*

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agotemplates: Add "download series" links
Stephen Finucane [Mon, 9 Jan 2017 11:49:03 +0000 (11:49 +0000)] 
templates: Add "download series" links

This will allow users to download entire series including the current
patch. Since a patch can belong to many series a dropdown is used.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agotemplates: Use buttons for patch download links
Stephen Finucane [Mon, 9 Jan 2017 11:12:37 +0000 (11:12 +0000)] 
templates: Use buttons for patch download links

We'll make use of this to enable downloading of patches with mboxes.

In addition, the 'hide' link for patches and cover letters is removed.
There's no way to enable this by default and the use cases are dubious
at best.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agoviews: Expose Series mbox
Stephen Finucane [Mon, 6 Feb 2017 12:36:27 +0000 (12:36 +0000)] 
views: Expose Series mbox

It is possible to download a patch mbox with all dependencies. Now make
it possible to download the entire series. This takes the form of the
following URL when using the default routes:

    /series/{seriesID}/mbox/

Like the equivalent patch and bundle links, this will return a 404 if
'{seriesID}' does not match an existing series' ID. However, a 404 will
also be returned in the series is not complete, as indicated by
Series.total > Series.received_total. You can override this behavior by
providing the 'force' parameter:

    /series/{seriesID}/mbox/?force=1

Note that there are no current plans to provide a series-specific view,
a.k.a.

    /series/{seriesID}/

As a result, this particular URL will continue to return a 404.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agoviews: Add 'series' parameter to '/mbox' endpoint
Stephen Finucane [Mon, 9 Jan 2017 12:23:47 +0000 (12:23 +0000)] 
views: Add 'series' parameter to '/mbox' endpoint

This allows a user to download dependencies for a patch without having
to do it manually. This is primarily aimed at users testing patches.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agoutils: Add 'bundle_to_mbox' helper
Stephen Finucane [Tue, 7 Feb 2017 11:29:59 +0000 (11:29 +0000)] 
utils: Add 'bundle_to_mbox' helper

This includes unit tests to validate correct behavior and prevent
regressions.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agotrivial: Cleanup imports in views
Stephen Finucane [Tue, 7 Feb 2017 11:25:30 +0000 (11:25 +0000)] 
trivial: Cleanup imports in views

Break each import onto its own line and remove 'absolute_import'
imports, which aren't necessary for Python >= 2.7.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agoutils: Move patch_to_mbox to utils module
Stephen Finucane [Tue, 7 Feb 2017 11:17:13 +0000 (11:17 +0000)] 
utils: Move patch_to_mbox to utils module

There's no reason to have this in '__init__.py'.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agoviews: Make 'patch_to_mbox' return a string
Stephen Finucane [Mon, 9 Jan 2017 12:06:14 +0000 (12:06 +0000)] 
views: Make 'patch_to_mbox' return a string

The 'patch_to_mbox' function returns an object which is coverted to a
string in all places where this call occurs. The string conversion
differs between Python 2 and 3 and while it has been updated in one
place, it was missed in two others. Resolve these issues and ensure they
don't happen again by returning strings from 'patch_to_mbox' instead.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agoviews: Use consistent 'list'/'detail' names
Stephen Finucane [Thu, 3 Nov 2016 15:38:39 +0000 (15:38 +0000)] 
views: Use consistent 'list'/'detail' names

The 'setbundles' view is also removed as it's not called by
anything/anyone.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agotrivial: Resolve PEP8 issue
Stephen Finucane [Tue, 4 Apr 2017 11:16:55 +0000 (12:16 +0100)] 
trivial: Resolve PEP8 issue

There's an unused variable.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 9b81f1ae ("REST: Add '/bundle' endpoint")
8 years agoparsemail.sh: Fix usage via stdin.
Ralf Baechle [Tue, 14 Mar 2017 18:09:12 +0000 (19:09 +0100)] 
parsemail.sh: Fix usage via stdin.

Commit e56391f66cb8 ("trivial: Standardize variable naming in scripts")
sneaked in a checked for missing command line arguments in parsemail.sh
which broke typical argument-less usage for mail delivery.  Revert that
again.

Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Reviewed-by: Stephen Finucane <stephen@that.guru>
Fixes: e56391f6 ("trivial: Standardize variable naming in scripts")
8 years agoREST: Add '/bundle' endpoint
Stephen Finucane [Tue, 21 Feb 2017 16:22:41 +0000 (11:22 -0500)] 
REST: Add '/bundle' endpoint

I had initially resisted adding a '/bundle' endpoint to the API as I
wanted to kill this feature in favour of series. However, series are not
a like-for-like replacement for bundles. Among other things, series do
not provide the composability of bundles: bundles can be manually
created, meaning you can use bundles to group not only multiple patches
but also multiple series (or at least the patches in those series).

Seeing as we're not getting rid of this feature, we should expose it via
the API. Bundles are little unusual, in that they can be public or
private, thus, we should only show bundles that are public or belonging
to the currently authenticated user, if any. For now, this is a
read-only endpoint. We may well allow creation of bundles via the API
once we figure out how to do this cleanly.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
8 years agoviews: Allow use of basic auth for bundle mboxes
Stephen Finucane [Sun, 26 Feb 2017 23:57:22 +0000 (23:57 +0000)] 
views: Allow use of basic auth for bundle mboxes

API clients are going to talk using basic auth. We also need to do this
for bundles. The alternative is to provide another endpoint for bundles
in the API but that seems unnecessary.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
8 years agoviews: Stop using Bundle.public_url
Stephen Finucane [Tue, 21 Feb 2017 19:39:07 +0000 (14:39 -0500)] 
views: Stop using Bundle.public_url

We now have 'get_mbox_url' which is consistent with patches. Let's drop
the older one.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
8 years agomodels: Add 'mbox_url' permalink for bundles
Stephen Finucane [Tue, 21 Feb 2017 19:34:56 +0000 (14:34 -0500)] 
models: Add 'mbox_url' permalink for bundles

We're going to use this for downloading mboxes via the REST API.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
8 years agoREST: Prefetch Series.project
Stephen Finucane [Tue, 21 Feb 2017 16:21:11 +0000 (11:21 -0500)] 
REST: Prefetch Series.project

I missed this when testing due to only having a single project. There
will be performance issues on instances using multiple projects.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
8 years agoUpdate psycopg2 from 2.7 to 2.7.x
pyup-bot [Mon, 13 Mar 2017 12:22:45 +0000 (12:22 +0000)] 
Update psycopg2 from 2.7 to 2.7.x

8 years agoPin selenium to latest version 3.3.x
pyup-bot [Mon, 13 Mar 2017 11:37:33 +0000 (11:37 +0000)] 
Pin selenium to latest version 3.3.x

8 years agoUpdate django-debug-toolbar from 1.6 to 1.7
pyup-bot [Sun, 5 Mar 2017 15:49:40 +0000 (15:49 +0000)] 
Update django-debug-toolbar from 1.6 to 1.7

8 years agoUpdate sqlparse from 0.2.2 to 0.2.3
pyup-bot [Fri, 3 Mar 2017 12:45:01 +0000 (12:45 +0000)] 
Update sqlparse from 0.2.2 to 0.2.3

8 years agoCatch Subprocess exceptions
Stephen Finucane [Thu, 2 Mar 2017 12:31:22 +0000 (12:31 +0000)] 
Catch Subprocess exceptions

Apparently different environments raise different return codes. Handle
the invalid return codes thrown by subprocess, presumably related to how
Travis checks out things from git.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: d3e9aee ("Don't catch non-Python 2.7 exceptions")
8 years agoDon't catch non-Python 2.7 exceptions
Stephen Finucane [Wed, 1 Mar 2017 22:22:59 +0000 (22:22 +0000)] 
Don't catch non-Python 2.7 exceptions

The 'FileNotFoundError' exception is only available in Python 3.3+.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 7b07b71e ("templates: Add Patchwork version")
8 years agoREST: Expose '/event' fields in 'payload' field
Stephen Finucane [Tue, 7 Feb 2017 13:13:34 +0000 (13:13 +0000)] 
REST: Expose '/event' fields in 'payload' field

Instead of exposing differing fields depending on the event category,
expose a consistent set of 'id', 'category', 'date' and 'payload'. This
ensures we can loop through events in a somewhat standardized fashion.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Tested-by: Daniel Axtens <dja@axtens.net>
8 years agoREST: Expose events
Stephen Finucane [Mon, 6 Feb 2017 20:04:37 +0000 (20:04 +0000)] 
REST: Expose events

This is a list only endpoint as it's expected that we would kill events
after a certain duration and would have no reason to allow indexing of
past events.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Tested-by: Daniel Axtens <dja@axtens.net>
8 years agodocs: Add events to usage guide
Stephen Finucane [Tue, 24 Jan 2017 14:20:09 +0000 (14:20 +0000)] 
docs: Add events to usage guide

Signed-off-by: Stephen Finucane <stephen@that.guru>
Tested-by: Daniel Axtens <dja@axtens.net>