]> git.ipfire.org Git - thirdparty/patchwork.git/log
thirdparty/patchwork.git
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>
8 years agodocs: Resolve some issues with the 'usage' guide
Stephen Finucane [Tue, 24 Jan 2017 13:51:28 +0000 (13:51 +0000)] 
docs: Resolve some issues with the 'usage' guide

The headings in this file were all over the place. Resolve this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 86100924 ("docs: Provide overview document")
Tested-by: Daniel Axtens <dja@axtens.net>
8 years agosignals: Add callbacks for events
Stephen Finucane [Tue, 18 Oct 2016 20:12:05 +0000 (21:12 +0100)] 
signals: Add callbacks for events

When models are modified, fire signal handlers to create the relevant
events.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Tested-by: Daniel Axtens <dja@axtens.net>
8 years agomodels: Add 'Event' model
Stephen Finucane [Tue, 18 Oct 2016 20:12:04 +0000 (21:12 +0100)] 
models: Add 'Event' model

Events record Patch-related things like initial creation, state
transitions, delegation assigning etc.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Tested-by: Daniel Axtens <dja@axtens.net>
8 years agomodels: Modify behavior of Series.received_all
Stephen Finucane [Mon, 6 Feb 2017 19:58:41 +0000 (19:58 +0000)] 
models: Modify behavior of Series.received_all

At the moment, Series.received_all is only true is the number of patches
received exactly matches the expected number of patches. However, there
are cases where there may in fact be more patches in the final series
than expected. For example, one could send patches with a subject of
'PATCH 5/4' in-reply-to an original four patch series. The parser
handles this correctly, so the 'received_all' property should too.

We still need to support patterns like '5/n', which are in use and do
not appear to be supported since 'c21b305'. This can be done at a later
stage.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Tested-by: Daniel Axtens <dja@axtens.net>
8 years agomodels: Move signal to 'signals'
Stephen Finucane [Tue, 18 Oct 2016 20:12:03 +0000 (21:12 +0100)] 
models: Move signal to 'signals'

Additional signals are going to be added shortly and they shouldn't
pollute 'models.py'.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Tested-by: Daniel Axtens <dja@axtens.net>
8 years agoREST: allow fetching of subject prefixes
Daniel Axtens [Tue, 21 Feb 2017 05:45:29 +0000 (16:45 +1100)] 
REST: allow fetching of subject prefixes

Some mailing lists accept patches for multiple projects, and use
a subject prefix to differentiate the projects.

Therefore, for snowpatch, it's useful to be able to fetch the
subject prefixes.

Export subject prefixes in the REST API.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Tested-by: Russell Currey <ruscur@russell.cc>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agotemplates: Add Patchwork version
Stephen Finucane [Sat, 19 Nov 2016 18:31:34 +0000 (18:31 +0000)] 
templates: Add Patchwork version

This is managed using a combination of hardcoded string, for
installations from tarball, and 'git describe', for installations from
a Git repo.

This includes installing Git in the Docker environment, to enable this
in the development environment.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Acked-by: Daniel Axtens <dja@axtens.net>
8 years agotemplates: Add API status to about page
Stephen Finucane [Sat, 19 Nov 2016 18:31:33 +0000 (18:31 +0000)] 
templates: Add API status to about page

This is useful given that these APIs can be disabled, and likely will
be for deployments where django-rest-framework is not available.

The version is currently hardcoded, but this will be resolved in a
future change.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agourls: Move 'help/about' to 'about'
Stephen Finucane [Sat, 19 Nov 2016 18:31:32 +0000 (18:31 +0000)] 
urls: Move 'help/about' to 'about'

This is the standard URL for such pages. This involves removing the
pwclient help page, but this is migrated to the project summary page
and detailed in the documentation.

Permanent redirects are included to prevent dead links.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agodocs: Clarify docker instructions
Stephen Finucane [Tue, 7 Feb 2017 21:48:10 +0000 (21:48 +0000)] 
docs: Clarify docker instructions

It's possible to run 'manage.py' commands when using the Docker
container but this is not documented anywhere. Clarify this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Acked-by: Daniel Axtens <dja@axtens.net>
8 years agoREST: Only call prefetch_related from a method
Stephen Finucane [Tue, 7 Feb 2017 22:11:24 +0000 (22:11 +0000)] 
REST: Only call prefetch_related from a method

Calling prefetch_related on a class-level queryset variable doesn't do
anything and is a mistake. Correct this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
8 years agomodels: Make series.project nullable
Stephen Finucane [Tue, 7 Feb 2017 21:56:18 +0000 (21:56 +0000)] 
models: Make series.project nullable

This is reflected in the migration but not the model.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: c1d8a0d ("Fix series.project migration logic")
Reviewed-by: Andy Doan <andy.doan@linaro.org>
8 years agoREST: Resolve issues with since, until filters
Stephen Finucane [Tue, 7 Feb 2017 21:53:55 +0000 (21:53 +0000)] 
REST: Resolve issues with since, until filters

It would appear that object-based mixins don't work with django-filter's
FilterSet. This should probably be fixed upstream, but for now let's
live with the extra duplication.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 0fc32337 ("REST: Integrate django-filter support")
Reviewed-by: Andy Doan <andy.doan@linaro.org>
8 years agosettings: Wildcard 'ALLOWED_HOSTS' settings
Stephen Finucane [Tue, 7 Feb 2017 21:47:16 +0000 (21:47 +0000)] 
settings: Wildcard 'ALLOWED_HOSTS' settings

Django 1.10.3, 1.9.11 and 1.8.16 changed default behavior for
ALLOWED_HOSTS to prevent DNS rebinding attacks [1]. Unfortunately this
also means we can't access the development Docker or Vagrant installs
by IP address. Sidestep the issue by wildcarding the 'ALLOWED_HOSTS'
setting for development, thus allowing connections from any IP.

[1] https://docs.djangoproject.com/en/1.10/ref/settings/#allowed-hosts

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agoREADME: Add "Mailing List, Meet CI" slides
Stephen Finucane [Sun, 12 Feb 2017 23:16:44 +0000 (23:16 +0000)] 
README: Add "Mailing List, Meet CI" slides

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREST: Limit max page size
Stephen Finucane [Tue, 7 Feb 2017 21:46:35 +0000 (21:46 +0000)] 
REST: Limit max page size

If this isn't set it's possible to set any page size. Let's restrict
this to the value set in settings.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Cc: Andy Doan <andy.doan@linaro.org>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
8 years agoPin psycopg2 to latest version 2.7
pyup-bot [Wed, 1 Mar 2017 15:30:27 +0000 (15:30 +0000)] 
Pin psycopg2 to latest version 2.7

8 years agoREST: Don't iterate through models at class level
Stephen Finucane [Tue, 7 Feb 2017 10:59:11 +0000 (10:59 +0000)] 
REST: Don't iterate through models at class level

This causes two issues. Firstly, on fresh installs you see the following
error message:

  "Table 'patchwork.patchwork_state' doesn't exist"

Secondly, any new states created when the process is running will not be
reflected in the API until the server process is restarted.

Resolve this issue by moving the step into a method, thus ensuring it's
continuously refreshed. It doesn't seem possible to add tests to prevent
this regressing but some similarly useful tests are included to at least
validate the behavior of that field.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Tested-By: Denis Laxalde <denis@laxalde.org>
Fixes: a2993505 ("REST: Make 'Patch.state' editable")
Closes-bug: #67
Closes-bug: #80

8 years agoImprove documentation of delegation rules
Stephen Finucane [Tue, 7 Feb 2017 21:45:56 +0000 (21:45 +0000)] 
Improve documentation of delegation rules

Per feedback from FOSDEM, this is still confusing some people. Clarify
things.

You might think we could just strip of the offending prefixes but that
might not always be the thing to do. Other VCSs don't include these
prefixes and both 'a' and 'b' are valid folder names. The risk of false
positives might be small, but it's enough to discourage us from doing
this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Thomas Monjalon <thomas.monjalon@6wind.com>
8 years agoFix double use of mail directory in parsemail-batch.sh
Daniel Axtens [Wed, 8 Feb 2017 04:16:58 +0000 (15:16 +1100)] 
Fix double use of mail directory in parsemail-batch.sh

2d142b2c0a27 ("bin: Run scripts through shellcheck") changes an
ls to a find. find output includes the directory name, unlike ls.
This breaks the script, because it prepends the mail directory
later on.

Remove the prepending in the script - leave it exclusively to find.

Signed-off-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: stephen@that.guru
Fixes: 2d142b2c0a27 ("bin: Run scripts through shellcheck")
8 years agotox: Add 'bashate' target
Stephen Finucane [Wed, 4 Jan 2017 13:14:33 +0000 (13:14 +0000)] 
tox: Add 'bashate' target

This is not as powerful as Shellcheck (yet), but it's Python and
therefore installable in a virtualenv.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agotrivial: Standardize variable naming in scripts
Stephen Finucane [Fri, 2 Dec 2016 10:42:44 +0000 (10:42 +0000)] 
trivial: Standardize variable naming in scripts

Just so we can interact with them as expected.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agobin: Run scripts through shellcheck
Stephen Finucane [Fri, 2 Dec 2016 10:36:58 +0000 (10:36 +0000)] 
bin: Run scripts through shellcheck

This mostly results in the addition of quotes to prevent globbing.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agotools: Run scripts through shellcheck
Stephen Finucane [Fri, 2 Dec 2016 10:27:10 +0000 (10:27 +0000)] 
tools: Run scripts through shellcheck

This mostly results in the addition of quotes to prevent globbing.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agodocs: fix links to installation pages
Denis Laxalde [Wed, 1 Feb 2017 09:38:51 +0000 (10:38 +0100)] 
docs: fix links to installation pages

Signed-off-by: Denis Laxalde <denis@laxalde.org>
Reviewed-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: fix links to "contributing" page
Denis Laxalde [Wed, 1 Feb 2017 09:38:50 +0000 (10:38 +0100)] 
docs: fix links to "contributing" page

Signed-off-by: Denis Laxalde <denis@laxalde.org>
Reviewed-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: link to deployment/development installation page in index
Denis Laxalde [Wed, 1 Feb 2017 09:38:49 +0000 (10:38 +0100)] 
docs: link to deployment/development installation page in index

Previous links are broken.

Signed-off-by: Denis Laxalde <denis@laxalde.org>
Reviewed-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agoFix series.project migration logic
Andy Doan [Wed, 25 Jan 2017 20:17:29 +0000 (14:17 -0600)] 
Fix series.project migration logic

The migration logic seems slightly off for 2 reasons:

1) If you already have series objects in your database, then adding a
non-nullable foreign key to projects will fail.

2) This may just be a remnant of my development database, but I had
series entries with no patches.

I think part #1 is *required*. I'm not totally sure about #2, but it
seems safe.

Signed-off-by: Andy Doan <andy.doan@linaro.org>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agoREST API: add "project" to series filter
Andy Doan [Wed, 25 Jan 2017 20:17:03 +0000 (14:17 -0600)] 
REST API: add "project" to series filter

It would be nice to allow users to filter on the project they are
interested in.

Signed-off-by: Andy Doan <andy.doan@linaro.org>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agomigrations: Don't use 'noop'
Stephen Finucane [Mon, 23 Jan 2017 09:07:29 +0000 (09:07 +0000)] 
migrations: Don't use 'noop'

The 'noop' operation was introduced in Django 1.8, meaning this
operation won't work on Django 1.7. Travis caught this, though I don't
know how it was missed locally.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: e3cbe493 ("models: Add 'project' field to Series")
8 years agorequirements: Add django-filter to dev reqs
Stephen Finucane [Mon, 23 Jan 2017 09:05:39 +0000 (09:05 +0000)] 
requirements: Add django-filter to dev reqs

Forgot to add this to development requirements.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 6f2ddab6 ("Revert 'requirements: Test older versions of DRF'")
8 years agoRevert "requirements: Test older versions of DRF"
Stephen Finucane [Sun, 22 Jan 2017 22:33:51 +0000 (22:33 +0000)] 
Revert "requirements: Test older versions of DRF"

This partially reverts commit febad055fb6609369f1a465a5eec323549c5c065.
While Django REST Framework works with Django 1.6 and 1.7, the versions
of Django Filters that provide DRF integration do not [1]. It doesn't
really make sense to enable only partial REST API support (i.e. no
filtering) for users with older Django versions and this approach will
cause far too much confusion among users. Better to just drop REST API
support for users with these insecure versions and encourage them to
update to supported versions of Django should they wish to use these
features.

[1] https://github.com/carltongibson/django-filter/blob/0.15.0/CHANGES.rst

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 0fc32337 ("REST: Integrate django-filter support")
8 years agodocs: Provide overview document
Stephen Finucane [Thu, 3 Nov 2016 13:37:25 +0000 (13:37 +0000)] 
docs: Provide overview document

This details the various top level elements that Patchwork exposes.
This could be stored as source code documentation, but then users would
need to look at the source.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Bring import of archives up to top-level
Stephen Finucane [Fri, 4 Nov 2016 15:17:35 +0000 (15:17 +0000)] 
docs: Bring import of archives up to top-level

This applies whether you're using the Docker-, Vagrant- or manual-
based installation methods.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREST: Integrate ordering
Stephen Finucane [Fri, 30 Dec 2016 12:14:19 +0000 (12:14 +0000)] 
REST: Integrate ordering

Order by way of the 'order' parameter on many endpoints.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREST: Integrate searching
Stephen Finucane [Mon, 14 Nov 2016 00:05:37 +0000 (00:05 +0000)] 
REST: Integrate searching

Search by way of the 'q' parameter on many endpoints.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREST: Integrate django-filter support
Stephen Finucane [Fri, 11 Nov 2016 23:19:32 +0000 (23:19 +0000)] 
REST: Integrate django-filter support

This mostly works out of the box, thanks to Django REST Framework.
Mostly unique fields, like name or email, are excluded as these will be
handled separately.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREST: Expose 'Series.project'
Stephen Finucane [Fri, 6 Jan 2017 16:34:06 +0000 (16:34 +0000)] 
REST: Expose 'Series.project'

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
8 years agomodels: Add 'project' field to Series
Stephen Finucane [Fri, 6 Jan 2017 15:51:05 +0000 (15:51 +0000)] 
models: Add 'project' field to Series

This is helpful for filtering. We use RunPython because folks are likely
to have few if any Series objects existing yet. In addition, we update
the unique constraints for SeriesReference as it's now possible to
handle messages with duplicate message IDs.

The update is included in parser to ensure this applies immediately.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
8 years agoPin sqlparse to latest version 0.2.2
pyup-bot [Wed, 4 Jan 2017 09:18:14 +0000 (09:18 +0000)] 
Pin sqlparse to latest version 0.2.2

8 years agodocs: Update swagger definition
Stephen Finucane [Wed, 16 Nov 2016 23:25:00 +0000 (23:25 +0000)] 
docs: Update swagger definition

There are a couple of changes needed:

- Add the '/users' endpoint
- Add PATCH support for the '/projects' endpoint
- Add information on authentication
- Clean up some documentation
- Remove some non-implemented parameters

This is still not complete, but it bears a lot closer resemblence to
reality now.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREST: Add '/series' endpoint
Stephen Finucane [Fri, 4 Nov 2016 14:17:46 +0000 (14:17 +0000)] 
REST: Add '/series' endpoint

Adopt a hybrid approach, by adding an additional series endpoint to the
existing patch endpoint:

    /series/${series_id}/
    /patches/${patch_id}/

This is based on the approach described here:

    http://softwareengineering.stackexchange.com/a/275007/106804

This is necessary due to the N:N mapping of series and patches: it's
possible for a patch to belong to many series, and a series usually
contains many patches. This means it is not possible to rely on the
patch endpoint alone.

It is also necessary to add a cover letter endpoint, such that the
series body can include this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREST: Add maintainers to '/projects'
Stephen Finucane [Thu, 24 Nov 2016 14:45:45 +0000 (14:45 +0000)] 
REST: Add maintainers to '/projects'

This is in the UI. Expose it in the API.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agoREST: Add id field to all endpoints
Stephen Finucane [Thu, 24 Nov 2016 14:16:34 +0000 (14:16 +0000)] 
REST: Add id field to all endpoints

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agotests: Standardize validation of REST API JSON
Stephen Finucane [Wed, 23 Nov 2016 17:22:12 +0000 (17:22 +0000)] 
tests: Standardize validation of REST API JSON

Standardize how the JSON bodies of REST API responses is validated.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
8 years agotests: Rework REST API tests
Stephen Finucane [Wed, 16 Nov 2016 22:43:57 +0000 (22:43 +0000)] 
tests: Rework REST API tests

- Combine anonymous user tests with authenticated user tests
- Rename and simplify some tests
- Improve documentation

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
8 years agoREST: Make 'User.first_name', 'last_name' editable
Stephen Finucane [Thu, 17 Nov 2016 01:00:04 +0000 (01:00 +0000)] 
REST: Make 'User.first_name', 'last_name' editable

In an ideal world, everything that can be done with the UI should also
be doable from the command line. The first and last names of the User
are low-value fields to allow customization of, but they are easily
implmented and move us towards the above goal.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
8 years agoREST: Make 'Patch.state' editable
Stephen Finucane [Wed, 23 Nov 2016 15:53:50 +0000 (15:53 +0000)] 
REST: Make 'Patch.state' editable

The 'Patch.state' field is exposed by the API, but is not editable.
Tests exist that suggest the field is editable, but they lie as they
don't actually validate the field is changed (it hasn't). Make this
field editable, using a custom field type to allow said user to submit a
string representation of the state rather than an integer id.

This has the side effect of changing the output representation of the
'state' field for the '/patches' endpoint to a slugified representation,
i.e.:

    "state": "under-review",

Instead of:

    "state": "Under review",

The same slugified representation will be used in PATCH requests. This
seems more consistent with how APIs generally do this stuff making it a
"good thing" (TM).

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agoREST: Use generic views instead of ViewSets
Stephen Finucane [Thu, 24 Nov 2016 12:55:42 +0000 (12:55 +0000)] 
REST: Use generic views instead of ViewSets

ViewSet provide an easy way to define an API, but they don't offer much
flexibility. To get them to work as expected, a lot of hacks were
required. Generic views provide a more verbose, but ultimately easier to
understand, version. Using generic views lets us remove the dependency
of drf-nested-routers, bringing us back down to two main dependencies.
It also lets us remove the AuthenticatedReadOnly permission class, as
the DRF provides a similar permission class that can be used with
generic views.

The main user facing change is that invalid methods, such as POST on an
endpoint that doesn't allow object creation, will now return a HTTP 405
(Method Not Allowed) error code rather than the HTTP 403 (Forbidden)
error code previously returned. This is the semantically correct option
and should have been used all along.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agoREST: Resolve performance issues with tags
Stephen Finucane [Fri, 28 Oct 2016 18:02:41 +0000 (19:02 +0100)] 
REST: Resolve performance issues with tags

The list comprehension used to generate a list of tags resulted in a
significant number of duplicated queries. Resolve this by copying the
approach taken to minimize patch queries in the UI.

This changes the output of the response in two ways. First, counts for
all tag patches are now shown, even if the count is 0. Secondly, a
dictionary is returned, with the tag name as the key, rather than a
list. As such, the output for a typical patch is transformed from:

    [
      {
        'name': 'Reviewed-by',
        'count': 1
      }
    ]

to

    {
      'Reviewed-by': 1
      'Acked-by': 0,
      'Tested-by': 0
    }

How this is achieved is a little hacky, but reworked tags are on the
post-v2.0 which will allow this to be resolved.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREST: Make use of the 'source' property
Stephen Finucane [Fri, 28 Oct 2016 17:29:49 +0000 (18:29 +0100)] 
REST: Make use of the 'source' property

This is apparently the correct way to rename fields, and will ensure a
future API version that supports writes will work correctly.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
8 years agoREST: Explicitly define fields
Stephen Finucane [Wed, 23 Nov 2016 19:41:12 +0000 (19:41 +0000)] 
REST: Explicitly define fields

Explicitly define included fields (using 'Meta.fields') rather than
those that should be excluded (using 'Meta.exclude'). This ensure fields
that are exposed by the API don't change unless we explicitly change
them

The only side-effect of this change should be a consistent ordering of
the output - the ordering used in the 'Meta.fields' will be consistently
used, thus ordering is now important and some fields are moved around
to reflect this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
8 years agoREST: Use SerializerMethod field
Stephen Finucane [Wed, 23 Nov 2016 19:35:40 +0000 (19:35 +0000)] 
REST: Use SerializerMethod field

Use 'SerializerMethodField' to override how we generate fields, rather
than hacking the 'to_representation' method. This is the more idiomatic
way to do this.

The Meta class for the Project and Patch serializers are moved to the
bottom of the serializers and some variables renamed, both for
consistency's sake.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoREST: Remove '_url' suffixes
Stephen Finucane [Thu, 24 Nov 2016 09:33:53 +0000 (09:33 +0000)] 
REST: Remove '_url' suffixes

This was a design decision made when implementing the REST API. The
idea was that these items were URLs to related objects and should be
indicated as such. However, this was a faulty assumption as the
Patchwork API, unlike other some other APIs (GitHub), does not also
include a full representation of said objects, like so:

    {
      "url": "http://localhost:8000/api/1.0/patches/1/",
      ...
      "delegate_url": "http://localhost:8000/api/1.0/users/1",
      "delegate": {
        "url": "http://localhost:8000/api/1.0/users/1/",
        "username": "admin",
        "first_name": "",
        "last_name": "",
        "email": ""
      }
    }

Since there is no intention to support this design yet, there isn't
really any reason to fight django-rest-framework in appending these
suffixes. Simply remove them. This changes the output for most endpoints
from something like this:

    {
      "url": "http://localhost:8000/api/1.0/patches/1",
      ...
      "delegate_url": "http://localhost:8000/api/1.0/users/1"
    }

to:

    {
      "url": "http://localhost:8000/api/1.0/patches/1",
      ...
      "delegate": "http://localhost:8000/api/1.0/users/1"
    }

This will affect all endpoints with nested resources.

Note that the API version is not bumped as the API is still considered
unreleased.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Andy Doan <andy.doan@linaro.org>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years agoREST: Create 'api' directory
Stephen Finucane [Mon, 31 Oct 2016 18:23:29 +0000 (18:23 +0000)] 
REST: Create 'api' directory

Move all REST API-related code into an 'api' directory. This allows us
to break the existing files into endpoint-based files and will allow us
to split the API into a different Django app in the future. This
involves simply shuffling code around for now, so there no functional
changes introduced.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
8 years ago.gitignore: Ignore mbox files
Stephen Finucane [Fri, 23 Dec 2016 18:51:19 +0000 (18:51 +0000)] 
.gitignore: Ignore mbox files

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agodocs: Highlight UID issue
Stephen Finucane [Fri, 23 Dec 2016 18:51:18 +0000 (18:51 +0000)] 
docs: Highlight UID issue

This occurs on Fedora 24, Fedora 25. There was a brief mention of it in
the docker-compose file but no resolution was offered.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agopwclient: support 3-way merge
Matthias Brugger [Tue, 20 Dec 2016 10:49:38 +0000 (11:49 +0100)] 
pwclient: support 3-way merge

Add support for the 3-way merge in git-am.
This can be done via
  - the commandline
  - the global option section
  - the per-project section

Signed-off-by: Matthias Brugger <mbrugger@suse.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agobin/pwclient: accept alternate http_proxy forms
Yann E. MORIN [Thu, 22 Dec 2016 21:09:32 +0000 (22:09 +0100)] 
bin/pwclient: accept alternate http_proxy forms

The forms for http_proxy (and the likes) is not very well defined nor
documented in any authoritaive place. However, there are two common
forms:  http://host:port  or  http://host:port/

Currently, the code chokes on the latter (e.g. with
http_proxy=http://127.0.0.1:8080/ ):

    [...]
      File "/usr/lib/python2.7/httplib.py", line 792, in _get_hostport
        raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
    httplib.InvalidURL: nonnumeric port: '8080/'

Chop off any slash character in the port definition to accept the second
form. If there is no '/' in there, it still works.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: Stephen Finucane <stephenfinucane@hotmail.com>
8 years agoforms: 'False' != False
Stephen Finucane [Fri, 23 Dec 2016 19:40:59 +0000 (19:40 +0000)] 
forms: 'False' != False

Forms cast boolean values to strings, and attempting to coerce using the
'bool' function does not correctly return them to true boolean values.
Correct this by doing a string comparison instead.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 0abde97aa ("forms: Use TypedChoiceField")
8 years agotests: Set 'date' when bulk creating patches
Stephen Finucane [Fri, 23 Dec 2016 20:21:56 +0000 (20:21 +0000)] 
tests: Set 'date' when bulk creating patches

Apparently Django 1.8+ changed how patches with identical 'date' fields
were ordered, meaning tests that worked on these versions failed on
previous versions.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: ed5e93242 ("tests: Add rudimentary pagination tests")
8 years agotests: Replace 'force_login' with 'login'
Stephen Finucane [Fri, 23 Dec 2016 19:14:24 +0000 (19:14 +0000)] 
tests: Replace 'force_login' with 'login'

The former is only available in Django 1.9+.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: ed5e93242 ("tests: Add rudimentary pagination tests")
8 years agoxmlrpc: Expose patch hash to patch_get
Florian Fainelli [Tue, 13 Dec 2016 18:47:37 +0000 (10:47 -0800)] 
xmlrpc: Expose patch hash to patch_get

Expose the patch object hash value to xmlrpc::patch_get. This is
particuarly helpful if some patche(s) have been submitted several times
but changed from e.g: RFC to a proper official patch submission. The
hash would typically be identical, but numbers would not.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
8 years agoforms: Trivial reshuffling of file
Stephen Finucane [Sat, 19 Nov 2016 14:02:32 +0000 (14:02 +0000)] 
forms: Trivial reshuffling of file

Group all "optional" fields.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoforms: Use TypedChoiceField
Stephen Finucane [Sat, 19 Nov 2016 14:02:31 +0000 (14:02 +0000)] 
forms: Use TypedChoiceField

This resolves a TODO.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoforms: Remove duplication
Stephen Finucane [Sat, 19 Nov 2016 14:02:30 +0000 (14:02 +0000)] 
forms: Remove duplication

DelegateField and OptionalDelegateField were basically duplicates of
other fields. Make use of parameters and remove them.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoforms: Remove unused args in forms
Stephen Finucane [Sat, 19 Nov 2016 14:02:29 +0000 (14:02 +0000)] 
forms: Remove unused args in forms

There were a couple of forms that offered configurabilty, but this
configurability wasn't used anywhere. Simplify things and remove any
related code.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agotests: Add rudimentary pagination tests
Stephen Finucane [Sat, 19 Nov 2016 14:02:28 +0000 (14:02 +0000)] 
tests: Add rudimentary pagination tests

This should improve coverage and prevent regressions. The 'ppp' header
is removed as this is a non-standard header and not accessible from
a browser.

Signed-off-by: Stephen Finucane <stephen@that.guru>
8 years agoviews: Include 'List-Id' in mbox
Stephen Finucane [Sat, 19 Nov 2016 19:32:10 +0000 (19:32 +0000)] 
views: Include 'List-Id' in mbox

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