]> git.ipfire.org Git - thirdparty/patchwork.git/log
thirdparty/patchwork.git
6 years agoREST: Fix typo in embedded serializers
Stephen Finucane [Fri, 16 Nov 2018 20:17:53 +0000 (21:17 +0100)] 
REST: Fix typo in embedded serializers

This was preventing the v1.1 fields from getting dropped as intended.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #237
6 years agoREST: Handle unset series
Stephen Finucane [Fri, 16 Nov 2018 15:47:43 +0000 (16:47 +0100)] 
REST: Handle unset series

This was introduced in the recent "convert series from N:M to 1:N"
series. We take the opportunity to make the 'create_patch' and
'create_cover' utility methods a little smarter, in that series will
automatically be created for the patch/cover letter unless told not to.
This requires some related changes to other modules.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agosignals: Fix 'series-completed' event
Stephen Finucane [Mon, 29 Oct 2018 15:15:18 +0000 (15:15 +0000)] 
signals: Fix 'series-completed' event

I'm not sure how I ever intended this to work and there were no tests
verifying things. Fix it now and add tests to prevent it regressing.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 76505e91 ("models: Convert Series-Patch relationship to 1:N")
6 years agotests: Add 'store_samples' decorator to 'test_event'
Stephen Finucane [Mon, 29 Oct 2018 00:54:57 +0000 (00:54 +0000)] 
tests: Add 'store_samples' decorator to 'test_event'

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add tests for '/events' resource
Stephen Finucane [Mon, 29 Oct 2018 00:53:40 +0000 (00:53 +0000)] 
tests: Add tests for '/events' resource

This highlights an issue that will be resolved in a future change.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add 'store_samples' decorator to 'test_check'
Stephen Finucane [Sun, 28 Oct 2018 17:40:27 +0000 (17:40 +0000)] 
tests: Add 'store_samples' decorator to 'test_check'

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add 'store_samples' decorator to 'test_comment'
Stephen Finucane [Sun, 28 Oct 2018 17:31:19 +0000 (17:31 +0000)] 
tests: Add 'store_samples' decorator to 'test_comment'

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add 'store_samples' decorator to 'test_series'
Stephen Finucane [Sun, 28 Oct 2018 17:22:20 +0000 (17:22 +0000)] 
tests: Add 'store_samples' decorator to 'test_series'

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add 'store_samples' decorator to 'test_cover'
Stephen Finucane [Sun, 28 Oct 2018 17:14:55 +0000 (17:14 +0000)] 
tests: Add 'store_samples' decorator to 'test_cover'

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add 'store_samples' decorator to 'test_patch'
Stephen Finucane [Sun, 28 Oct 2018 17:14:45 +0000 (17:14 +0000)] 
tests: Add 'store_samples' decorator to 'test_patch'

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add 'store_samples' decorator to 'test_user'
Stephen Finucane [Sun, 28 Oct 2018 15:49:54 +0000 (15:49 +0000)] 
tests: Add 'store_samples' decorator to 'test_user'

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add 'store_samples' decorator to 'test_people'
Stephen Finucane [Sun, 28 Oct 2018 15:36:46 +0000 (15:36 +0000)] 
tests: Add 'store_samples' decorator to 'test_people'

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add 'store_samples' decorator to 'test_project'
Stephen Finucane [Sun, 28 Oct 2018 15:22:22 +0000 (15:22 +0000)] 
tests: Add 'store_samples' decorator to 'test_project'

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add 'store_samples' decorator to 'test_bundle'
Stephen Finucane [Sun, 28 Oct 2018 14:43:31 +0000 (14:43 +0000)] 
tests: Add 'store_samples' decorator to 'test_bundle'

Add the decorator to the 'test_bundle' test class. This involves
splitting up the test cases so that each test case we care about makes
only a single request. We also add a missing test to ensure private
bundles cannot be shown by anyone but the owner.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Add 'store_samples' decorator
Stephen Finucane [Sun, 28 Oct 2018 14:40:31 +0000 (14:40 +0000)] 
tests: Add 'store_samples' decorator

We want to start including sample API requests and responses in our
documentation.  Given that these may get out of date over time, we
should really generate these things dynamically. Create a decorator that
will allow us to do just that.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoREST: Ensure submission exists for comment listing
Stephen Finucane [Sun, 28 Oct 2018 13:31:34 +0000 (13:31 +0000)] 
REST: Ensure submission exists for comment listing

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #225
6 years agoREST: Ensure patch exists for check creation
Stephen Finucane [Sun, 28 Oct 2018 13:31:12 +0000 (13:31 +0000)] 
REST: Ensure patch exists for check creation

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #226
6 years agoREST: Show 'web_url' in embedded series responses
Stephen Finucane [Fri, 26 Oct 2018 20:35:03 +0000 (21:35 +0100)] 
REST: Show 'web_url' in embedded series responses

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #224
Fixes: 9c179bf4c ("REST: Add 'web_url' link to API responses")
6 years agoREST: Add additional documentation
Stephen Finucane [Sat, 20 Oct 2018 22:20:52 +0000 (23:20 +0100)] 
REST: Add additional documentation

As noted in the Django REST Framework docs [1], views that support
multiple methods can and should split their documentation using
'method:' style delimiters. Do just this.

[1] https://www.django-rest-framework.org/topics/documenting-your-api/#documenting-your-views

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoDon't passthrough 'Content-Type: multipart/signed' header
Stephen Finucane [Sun, 4 Nov 2018 14:25:03 +0000 (14:25 +0000)] 
Don't passthrough 'Content-Type: multipart/signed' header

We don't GPG signatures, therefore this header is incorrect. Stop
passing it through.

Test for the other dropped header are also included.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Acked-by: Veronika Kabatova <vkabatov@redhat.com>
Closes: #221
6 years agoUpdate psycopg2-binary from 2.7.5 to 2.7.6
pyup-bot [Fri, 9 Nov 2018 11:57:36 +0000 (11:57 +0000)] 
Update psycopg2-binary from 2.7.5 to 2.7.6

6 years agoUpdate psycopg2-binary from 2.7.5 to 2.7.6
pyup-bot [Fri, 9 Nov 2018 11:57:34 +0000 (11:57 +0000)] 
Update psycopg2-binary from 2.7.5 to 2.7.6

6 years agoUpdate django from 2.1.2 to 2.1.3
pyup-bot [Fri, 2 Nov 2018 09:32:03 +0000 (09:32 +0000)] 
Update django from 2.1.2 to 2.1.3

6 years agoparser: Use 'objects.create' instead of 'save'
Stephen Finucane [Tue, 11 Sep 2018 22:39:54 +0000 (16:39 -0600)] 
parser: Use 'objects.create' instead of 'save'

As noted in the Django documentation [1], this lets us do things in one
step.

[1] https://docs.djangoproject.com/en/dev/topics/db/queries/#creating-objects

Signed-off-by: Stephen Finucane <stephen@that.guru>
Acked-by: Daniel Axtens <dja@axtens.net>
6 years agoREADME: Note latest version of requirements
Stephen Finucane [Tue, 30 Oct 2018 22:04:23 +0000 (22:04 +0000)] 
README: Note latest version of requirements

These were missed previously

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 8eb3719a ("Add support for django-filter 2.0")
Fixes: fab5571e ("Add support for Django REST Framework 3.9")
6 years agodocs: Fix design doc
Stephen Finucane [Tue, 30 Oct 2018 22:01:53 +0000 (22:01 +0000)] 
docs: Fix design doc

These items weren't really headers and shouldn't have been rendered as
such.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoUpdate python-dateutil from 2.7.4 to 2.7.5
pyup-bot [Sat, 27 Oct 2018 20:53:13 +0000 (21:53 +0100)] 
Update python-dateutil from 2.7.4 to 2.7.5

6 years agotravis: Use consistent quote style
Stephen Finucane [Tue, 30 Oct 2018 11:39:54 +0000 (11:39 +0000)] 
travis: Use consistent quote style

It's the little things in life.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotravis: Stop testing PostgreSQL 11
Stephen Finucane [Tue, 30 Oct 2018 11:35:41 +0000 (11:35 +0000)] 
travis: Stop testing PostgreSQL 11

Travis seems to be doing something really weird with PG11 since it was
released a few weeks ago. This is currently breaking our CI and can't
continue. It doesn't seem possible to mark this as an expected failure
so simply remove it. We can re-add this once Travis gains proper support
for this version via their addons.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Suggested-by: Daniel Black <daniel@linux.ibm.com>
Acked-by: Daniel Axtens <dja@axtens.net>
6 years agoviews: no longer import Series in __init__.py
Daniel Axtens [Tue, 30 Oct 2018 13:45:44 +0000 (00:45 +1100)] 
views: no longer import Series in __init__.py

Fix a pep8 error due to an unused import.

Fixes: 780b1a2d07ad ("views: Use select_related, not prefetch_related")
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agoviews: Use select_related, not prefetch_related
Stephen Finucane [Mon, 29 Oct 2018 15:46:39 +0000 (15:46 +0000)] 
views: Use select_related, not prefetch_related

Now that there's a 1:N rather than N:M relationship between series and
patches, we should be using select_related rather than prefetch_related.

Tested-by: Daniel Axtens <dja@axtens.net>
Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #223
Fixes: 76505e91 ("models: Convert Series-Patch relationship to 1:N")
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agoUpdate python-dateutil from 2.7.3 to 2.7.4
pyup-bot [Thu, 25 Oct 2018 19:39:10 +0000 (20:39 +0100)] 
Update python-dateutil from 2.7.3 to 2.7.4

6 years agotrivial: Use implicit string concatenation
Stephen Finucane [Fri, 26 Oct 2018 09:34:34 +0000 (10:34 +0100)] 
trivial: Use implicit string concatenation

While pycodestyle's W504 ("line break after binary operator") error was
recently disabled, it did highlight a number of areas where explicit
string concatenation was being used despite it not be necessary. Fix
these while we're aware of them.

[1] http://pycodestyle.pycqa.org/en/latest/intro.html#error-codes

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotox: Disable W504 ("line break after binary operator")
Stephen Finucane [Fri, 26 Oct 2018 09:39:29 +0000 (10:39 +0100)] 
tox: Disable W504 ("line break after binary operator")

This was introduced in a recent version of 'pycodestyle'. The
documentation notes [1] that it is mutually exclusive with W503, which
we do enforce, suggesting that we disable one or the other. Avoid the
churn and stick to the older rule, which I personally prefer.

[1] http://pycodestyle.pycqa.org/en/latest/intro.html#error-codes

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoREADME: Use pyup.io badge instead of requires.io
Stephen Finucane [Sun, 21 Oct 2018 11:16:15 +0000 (12:16 +0100)] 
README: Use pyup.io badge instead of requires.io

requires.io has an open issue whereby it doesn't consider Python version
in assessing the latest version of a package available. pyup.io also has
the same issue but we've already worked around this by ignoring the
offending lines. Seeing as we're already using that elsewhere, double
down on it.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Update links for django-rest-framework 3.7, 3.8
Stephen Finucane [Thu, 18 Oct 2018 16:46:12 +0000 (17:46 +0100)] 
docs: Update links for django-rest-framework 3.7, 3.8

Don't you hate it when links break? These release notes haven't been
included in a release yet so we can just go ahead and update things.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoAdd support for Django REST Framework 3.9
Stephen Finucane [Thu, 18 Oct 2018 16:45:21 +0000 (17:45 +0100)] 
Add support for Django REST Framework 3.9

As with 3.7 and 3.8, there are no breaking changes we need to be
concerned with here.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotests: Remove 'create_series_patch'
Stephen Finucane [Thu, 6 Sep 2018 14:22:31 +0000 (15:22 +0100)] 
tests: Remove 'create_series_patch'

The 'SeriesPatch' object was recently removed, but the
'create_series_patch' was retained in order to minimize the changes
necessary. This can now be removed and the logic moved to the
'create_patch' and 'create_cover' functions instead.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agomodels: Convert Series-Patch relationship to 1:N
Stephen Finucane [Sat, 19 May 2018 02:42:18 +0000 (03:42 +0100)] 
models: Convert Series-Patch relationship to 1:N

Late in the development of the series feature, it was decided that there
were advantages to allowing an N:M relationship between series and
patches. This would allow us to do things like create complete series
where a sole vN patch was sent to a list rather than the full series.
After some time using series in the wild, it's apparent that such
features are very difficult to implement correctly and will likely never
be implemented. As such, it's time to start cleaning up the mess, paving
the way for things like an improved tagging feature.

There are some significant changes to the model required:

- models.py, migrations/0027, migrations/0028, migrations/0029

  The migrations make the following changes:

  1. - Add 'Patch.series_alt' and 'Patch.number' fields.
  2. - Populate the 'Patch.series_alt' and 'Patch.number' fields from
       their 'SeriesPatch' equivalents.
  3. - Remove the 'SeriesPatch' model.
     - Rename 'Patch.series_alt' to 'Patch.series'.
     - Change 'Series.cover_letter' to a 'OneToOneField' since a cover
       letter can no longer be assigned to multiple series.

  Note that the migrations have to be split into multiple parts as the
  combined migration raises an OperationalError as below.

    (1072, "Key column 'series_alt_id' doesn't exist in table")

  This is due to Django's penchant for creating indexes for newly
  created fields, as noted here: https://stackoverflow.com/q/35158530/

Aside from the model changes, there are numerous other changes required:

- admin.py

  Reflect model changes for the 'PatchInline' inline used by
  'SeriesAdmin'

- api/cover.py, api/patch.py

  Update the 'series' field for the cover letter and patch resources to
  reflect the model changes. A 'to_representation' function is added in
  both cases to post-process this field and make it look like a list
  again. This is necessary to avoid breaking clients.

- parser.py

  Update to reflect the replacement of 'SeriesPatch' with 'Patch'.

- signals.py

  Update to filter on changes to 'Patch' instead of 'SeriesPatch'. This
  requires some reworking due to how we set these fields now, as we can
  no longer receive on 'post_save' signals for 'SeriesPatch' and must
  instead watch for 'pre_save' on 'Patch', which is what we do for
  delegate and state changes on same.

- templates/patchwork/*.html

  Remove logic that handled multiple series in favour of the (simpler)
  single series logic.

- tests/*

  Modify the 'create_series_patch' helper to reflect the removal of the
  'SeriesPatch' model. This entire helper will be removed in a future
  change. Improve some tests to cover edge cases that were highlighted
  during development

Unfortunately, all of the above changes must go in at the same time,
otherwise we end up with either (a) broken views, API etc. or (b) split
brain because we need to keep the new single-series fields alongside the
older multi-series fields and models while we rework the views. It's
unfortunate but there's not much to be done here.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Tested-by: Daniel Axtens <dja@axtens.net>
6 years agotests: Hardcode expected values
Stephen Finucane [Thu, 6 Sep 2018 14:53:09 +0000 (15:53 +0100)] 
tests: Hardcode expected values

Compare against known values to ensure bugs introduced in the function
are caught.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
6 years agotests: Add more tests for series-ified mbox views
Stephen Finucane [Thu, 6 Sep 2018 17:11:55 +0000 (18:11 +0100)] 
tests: Add more tests for series-ified mbox views

Cover some testing gaps identified during the migration from a M:N to a
1:N series-patch relationship, namely:

- Downloading a patch's mbox with dependencies using a numerical series
  ID
- Downloading a series' mbox

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Daniel Axtens <dja@axtens.net>
6 years agotox: Fix issues with 'bashate' target
Stephen Finucane [Sun, 14 Oct 2018 16:37:02 +0000 (17:37 +0100)] 
tox: Fix issues with 'bashate' target

We don't care about too long lines for bash so the error is disabled.

The version marker is removed as it's unnecessary.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoREST: Allow unsetting of delegate
Stephen Finucane [Sun, 14 Oct 2018 14:29:47 +0000 (15:29 +0100)] 
REST: Allow unsetting of delegate

While we recently fixed setting of this field via the API, we didn't
resolve unsetting. Fix this now.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoREST: Allow setting of values using embedded serializers
Stephen Finucane [Thu, 11 Oct 2018 10:47:56 +0000 (11:47 +0100)] 
REST: Allow setting of values using embedded serializers

Unfortunately, the use of embedded serializers for some fields breaks
the ability to update these fields, either via the HTML interface (where
the widget is totally busted) or via a client like 'git-pw'. What we
actually want is to be able to update these fields like normal primary
key but show them using the embedded serializer. We do just this by
using a modified variant of the PrimaryKeyRelatedField and using the
serializers simply for displaying.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #216
6 years agoREST: Validate patch delegate
Stephen Finucane [Thu, 11 Oct 2018 13:53:25 +0000 (14:53 +0100)] 
REST: Validate patch delegate

At present, only users who are maintainers of projects can be delegated
a project. Validate this. This is currently broken due to #216 but that
will be fixed in a future change.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoREST: Don't allow settings of some project fields
Stephen Finucane [Sat, 13 Oct 2018 16:10:49 +0000 (17:10 +0100)] 
REST: Don't allow settings of some project fields

These should only be configurable by superusers as invalid configuration
can break things.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #217
6 years agodocs: Add release notes for recent bug fixes
Stephen Finucane [Sun, 14 Oct 2018 13:32:25 +0000 (14:32 +0100)] 
docs: Add release notes for recent bug fixes

We need to start adding these as part of the bug fix itself.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotemplates: Don't show forced filters
Stephen Finucane [Sat, 29 Sep 2018 21:08:35 +0000 (22:08 +0100)] 
templates: Don't show forced filters

No point in showing a filter that you can't change.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agofilters: Rework code
Stephen Finucane [Sat, 29 Sep 2018 20:40:48 +0000 (21:40 +0100)] 
filters: Rework code

Make extensive use of properties, remove dead code, add documentation
and generally clean this whole thing up.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agofilters: Pre-populate delegate, submitter filters
Stephen Finucane [Sat, 29 Sep 2018 20:11:22 +0000 (21:11 +0100)] 
filters: Pre-populate delegate, submitter filters

This appears to have got lost in the transition to 'selectize.js'. In
brief, this will ensure that a previously selected delegate or submitter
is still enabled post-filtering. For more information, see [1].

[1] https://stackoverflow.com/a/45124779

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #78
6 years agofilters: Return dictionaries
Stephen Finucane [Thu, 27 Sep 2018 14:34:07 +0000 (15:34 +0100)] 
filters: Return dictionaries

This makes it a little easier to figure out what filters are active and
will be used in a future patch.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agosettings: Do configure logging for parsearchive (but differently)
Stephen Finucane [Wed, 10 Oct 2018 10:20:21 +0000 (11:20 +0100)] 
settings: Do configure logging for parsearchive (but differently)

In commit aa266a28, we removed the logging configuration for the
'parsearchive' tool because it was using the same configuration as
'parsemail' and could send an email to administrators for ERROR logs.
While we shouldn't be doing that, we should be configuring _some_ kind
of logging.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agorequirements: Add sqlparse to test requirements
Stephen Finucane [Wed, 10 Oct 2018 09:33:50 +0000 (10:33 +0100)] 
requirements: Add sqlparse to test requirements

This was previously installed as part of 'django-debug-toolbar' [1] but
as this dependency is no longer installed for tests, the dependency is
now missing. Fix this by manually specifying it.

[1] https://github.com/jazzband/django-debug-toolbar/blob/1.10.1/setup.py#L20-L23

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: a7454712 ("Remove django-debug-toolbar from test requirements")
6 years agodocs: Add documentation for django-dbbackup
Stephen Finucane [Tue, 9 Oct 2018 09:59:54 +0000 (10:59 +0100)] 
docs: Add documentation for django-dbbackup

This replaces the older manual backup steps. The section on
'django-debug-toolbar' is updated to match the new 'django-dbbackup'
section.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodoc: Cleanup development installation guide
Stephen Finucane [Thu, 13 Sep 2018 18:30:34 +0000 (12:30 -0600)] 
doc: Cleanup development installation guide

Use literals where possible, don't leave a space between a term and
definition, and note that Python 3.4, not 3.3, is now the minimum
supported version of Python 3.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoRemove django-debug-toolbar from test requirements
Stephen Finucane [Thu, 13 Sep 2018 21:20:42 +0000 (15:20 -0600)] 
Remove django-debug-toolbar from test requirements

This should speed up tests slightly and remove an unnecessary
dependency.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoAdd support for 'django-dbbackup'
Stephen Finucane [Thu, 13 Sep 2018 18:13:35 +0000 (12:13 -0600)] 
Add support for 'django-dbbackup'

'parsemail' and 'parsearchive' are slow. When messing with models and
migrations, it can be very useful to backup the database in its current
state and restore it if/when you mess up. Currently, we've documented
how to do this via some commands run in the shell of the container, but
we can do things easier via an application designed for this purpose:
'django-dbshell'.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Add 'unreleased' to release notes index page
Stephen Finucane [Sat, 6 Oct 2018 21:50:43 +0000 (22:50 +0100)] 
docs: Add 'unreleased' to release notes index page

It's already on the main index page.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoUpdate sphinx_rtd_theme from 0.3.0 to 0.4.2
pyup-bot [Sat, 6 Oct 2018 19:16:17 +0000 (20:16 +0100)] 
Update sphinx_rtd_theme from 0.3.0 to 0.4.2

6 years agoviews: Populate bundles for 'todo' view
Stephen Finucane [Sat, 29 Sep 2018 21:33:36 +0000 (22:33 +0100)] 
views: Populate bundles for 'todo' view

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #213
6 years agodocs: Call out Python 3 dependency for Django 2.0
Stephen Finucane [Sat, 6 Oct 2018 14:06:06 +0000 (15:06 +0100)] 
docs: Call out Python 3 dependency for Django 2.0

Just for those that don't read the Django release notes.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoAdd support for Django 2.1
Stephen Finucane [Thu, 13 Sep 2018 21:47:49 +0000 (15:47 -0600)] 
Add support for Django 2.1

For once, this just works. Yay!

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoAdd support for django-filter 2.0
Stephen Finucane [Thu, 13 Sep 2018 22:08:31 +0000 (16:08 -0600)] 
Add support for django-filter 2.0

This is necessary for Django 2.1 support. We retain support for
django-filter 1.0 and 1.1 as 2.0 is Python 3-only. Thankfully there is
essentially zero cost in doing so for now.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agorequirements: Bump version of django-debug-toolbar to 1.10.1
Stephen Finucane [Thu, 13 Sep 2018 21:43:07 +0000 (15:43 -0600)] 
requirements: Bump version of django-debug-toolbar to 1.10.1

Use the latest and greatest.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotemplates: Avoid recursive call
Stephen Finucane [Mon, 1 Oct 2018 21:36:41 +0000 (22:36 +0100)] 
templates: Avoid recursive call

We had registered an event handler on a checkbox in table header which
would call a function, 'checkboxes', on all checkboxes within that
table. This function, in turn, causes does its work and then triggers
event handlers for all modified checkboxes which include the original
table header checkbox. This resulted in the original event calling
itself recursively.

Resolve this by only modifying the checkboxes in the table body.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 44fe7bae ("js: Allow shift-select of checkboxes")
6 years agotemplates: Remove trailing newlines
Stephen Finucane [Sat, 29 Sep 2018 22:03:08 +0000 (23:03 +0100)] 
templates: Remove trailing newlines

These got added accidentally during merge.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 45fa5c5c ("templates: Move additional email subjects to templates")
6 years agoviews: Add error handling for user registration
Stephen Finucane [Thu, 30 Aug 2018 09:24:33 +0000 (10:24 +0100)] 
views: Add error handling for user registration

This was already present for registration confirmation but missing for
initial registration. Resolve this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotemplates: Remove 'email_sent' attribute
Stephen Finucane [Fri, 7 Sep 2018 11:28:23 +0000 (12:28 +0100)] 
templates: Remove 'email_sent' attribute

Further normalization to ensure all related code paths use similar code.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotemplates: Move additional email subjects to templates
Stephen Finucane [Fri, 7 Sep 2018 11:17:04 +0000 (12:17 +0100)] 
templates: Move additional email subjects to templates

Use a uniform pattern for this stuff.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotemplates: Keep only whole templates in the top-level
Stephen Finucane [Wed, 6 Jun 2018 14:50:49 +0000 (15:50 +0100)] 
templates: Keep only whole templates in the top-level

Again, this should make this a little more understandable as it ensures
a rough mapping exists between views and template names.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotemplates: Rename additional templates
Stephen Finucane [Wed, 6 Jun 2018 14:45:18 +0000 (15:45 +0100)] 
templates: Rename additional templates

Make ALL the things consistent.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agotemplates: Move mails to separate directory
Stephen Finucane [Wed, 6 Jun 2018 14:31:33 +0000 (15:31 +0100)] 
templates: Move mails to separate directory

This makes things a little easier to parse. A couple of templates are
renamed and the 'register.mail' template, which appears to be unused
since commit f1e089f7, is removed.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agosettings: Don't configure logging for parsearchive
Stephen Finucane [Fri, 21 Sep 2018 16:59:48 +0000 (17:59 +0100)] 
settings: Don't configure logging for parsearchive

A recent change added additional ERROR level logs to the 'parsearchive'
tool. This highlighted an issue, whereby we had configured all modules
in 'patchwork.management.command' to email administrators on ERROR logs.
We clearly shouldn't be doing this for the 'parsearchive' command or for
anything other than 'parsemail', so fix this.

Along the way, we remove a now-unnecessary 'extra' argument to one of
the logging calls in 'parsearchive' and resolve a pep8 issue.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 133091da ("parsearchive: Fix logging")
Cc: Daniel Axtens <dja@axtens.net>
6 years agorequirements: Start using fixed versions
Stephen Finucane [Wed, 29 Aug 2018 10:01:41 +0000 (11:01 +0100)] 
requirements: Start using fixed versions

Given that 'tox' doesn't actually read any of these, there's no reason
to use ranges of requirements. Instead, use the latest and greatest for
live instances and rely on tox to validate behavior with older versions.

The selenium dependency, which is no longer required since commit
bab2895f, is removed. The psycopg2 dependency is updated to use
psycopg2-binary, as this avoids the need for the libpg library and
removes a deprecation warning.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Signed-off-by: Daniel Axtens <dja@axtens.net>
6 years agoparser: Handle IntegrityError for cover letters, comments
Stephen Finucane [Wed, 19 Sep 2018 20:03:33 +0000 (21:03 +0100)] 
parser: Handle IntegrityError for cover letters, comments

This was already done for patches but cover letters and comments were
not handled correctly, resulting in errors while parsing archives. While
we're here, we slightly modify how these exceptions are handle. Rather
than simply ignoring them, as we were doing, we raise a custom
exception. This allows us to specifically identify these types of
exceptions, print a log and still skip them (which we want, as seen in
commit d2eb1f6d2).

While we're here, we change from separate create-save calls to a
combined create-save call for both created CoverLetter and Comment
objects. We were already doing this for patches.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoparsearchive: Fix logging
Stephen Finucane [Wed, 19 Sep 2018 18:50:55 +0000 (19:50 +0100)] 
parsearchive: Fix logging

We should use a counter normally, avoid using the counter and emit logs
when more detailed output is requested, and emit nothing when no output
is requested.

In addition, the default logging level for the parser module is set to
'WARNING' to make it less chatty.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoadmin: Configure 'list_select_related', 'get_queryset'
Stephen Finucane [Wed, 12 Sep 2018 21:57:39 +0000 (15:57 -0600)] 
admin: Configure 'list_select_related', 'get_queryset'

This has a significant improvement for the patch and series views.

  /patchwork/patch
    FROM: ~114 queries
    TO: ~14 queries

  /patchwork/series
    FROM: ~210 queries
    TO: ~10 queries

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agoREST: Only list checks for the given patch
Stephen Finucane [Wed, 12 Sep 2018 15:46:56 +0000 (09:46 -0600)] 
REST: Only list checks for the given patch

This is either a regression or it never worked. In any case, fix it and
add a test to ensure it doesn't happen again.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Veronika Kabatova <vkabatov@redhat.com>
Closes: #203
6 years agoRevert "gitignore: Ignore JSON files"
Stephen Finucane [Wed, 19 Sep 2018 21:43:02 +0000 (22:43 +0100)] 
Revert "gitignore: Ignore JSON files"

This reverts commit 76750e9789ad10d45134c1ab59efa586007be984.

The 'dumpdata' command is run infrequently enough, and JSON files are
that common, that we shouldn't really ignore these.

Signed-off-by: Stephen Finucane <stephen@that.guru>
6 years agodocs: Note new requirement to include a SPDX line
Stephen Finucane [Mon, 17 Sep 2018 17:14:05 +0000 (18:14 +0100)] 
docs: Note new requirement to include a SPDX line

Add some wording around the requirement to include this line instead of
the license header. Also note the requirement that all code be licensed
using the 'GPL-2.0-or-later' license and add a CONTRIBUTING document,
which GitHub likes.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Reviewed-by: Veronika Kabatova <vkabatov@redhat.com>
6 years agoUpdate license header
Stephen Finucane [Mon, 17 Sep 2018 10:59:56 +0000 (11:59 +0100)] 
Update license header

The FSF has a new address since 2005 that hasn't been noted in any file
except the COPYING file. Rather than fix these, simply remove the
headers in favour of a SPDX license header. IANAL but the combination of
the header and the COPYING file in source should resolve this issue.

Note that copyright notices are retained.

Signed-off-by: Stephen Finucane <stephen@that.guru>
Closes: #210
Reviewed-by: Veronika Kabatova <vkabatov@redhat.com>
6 years agoRemove '__future__.absolute_import' imports
Stephen Finucane [Mon, 17 Sep 2018 13:56:36 +0000 (14:56 +0100)] 
Remove '__future__.absolute_import' imports

These were added as part of the Python 3 support series but are not
required and can be safely removed.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agotox: Specify doctree directory
Stephen Finucane [Tue, 18 Sep 2018 15:48:01 +0000 (16:48 +0100)] 
tox: Specify doctree directory

Sphinx 1.8 has a change in where it places 'doctree' directories. Rather
than ignore this directory via gitignore, specify where this directory
should go. This will ensure future changes in Sphinx's behavior won't
affect us.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agourls: Remove unused import
Stephen Finucane [Tue, 11 Sep 2018 20:50:03 +0000 (14:50 -0600)] 
urls: Remove unused import

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: 5976cce6 ("urls: Remove references to Django < 1.11")
7 years agoadmin: Remove unused SeriesInline
Stephen Finucane [Tue, 4 Sep 2018 19:15:52 +0000 (20:15 +0100)] 
admin: Remove unused SeriesInline

This was added in commit d67d859f but was never used. Remove it.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agotemplatetags: Remove dead tag
Stephen Finucane [Tue, 4 Sep 2018 19:15:37 +0000 (20:15 +0100)] 
templatetags: Remove dead tag

Nothing appears to be using this so it can be removed.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agourls: Remove references to Django < 1.11
Stephen Finucane [Tue, 4 Sep 2018 19:15:28 +0000 (20:15 +0100)] 
urls: Remove references to Django < 1.11

This was missed in the recent "add support for Django 2.0" series.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agotests: Remove useless todo
Stephen Finucane [Mon, 10 Sep 2018 23:11:46 +0000 (17:11 -0600)] 
tests: Remove useless todo

I'm not sure why I included this in day one: we _want_ to use the
context manager like this.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agodocs: Add release note for Django 1.8 to 1.10 removal
Stephen Finucane [Mon, 10 Sep 2018 23:05:22 +0000 (17:05 -0600)] 
docs: Add release note for Django 1.8 to 1.10 removal

Signed-off-by: Stephen Finucane <stephen@that.guru>
Fixes: e97bd5ca0 ("Remove support for Django 1.8, 1.9, 1.10")
7 years agodocs: Add release note for recent DB optimizations
Stephen Finucane [Mon, 10 Sep 2018 20:44:03 +0000 (14:44 -0600)] 
docs: Add release note for recent DB optimizations

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agomodels: Remove 'latest_series'
Stephen Finucane [Wed, 5 Sep 2018 14:53:32 +0000 (15:53 +0100)] 
models: Remove 'latest_series'

This is only used in a single view (where it probably shouldn't be used)
and some tests. It's an anti-pattern that makes it too easy to shoot
yourself in the foot. Remove it.

Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agoFetch maintainer information in one query
Stewart Smith [Fri, 10 Aug 2018 08:01:06 +0000 (18:01 +1000)] 
Fetch maintainer information in one query

Viewing the /project/ page lists maintainers. Prior to this patch,
this was done in one query to fetch the maintainer IDs, and then one
query per mainatiner to get the name/email address.

Now, with this patch, it's all in one query (yay joins) and saves
a few ms of database queries for displaying the page.

Realistically, this doesn't save us too much time as counting how many
patches are there takes 99% of the database time for this page.

Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
7 years agoBe sensible computing project patch counts
Stewart Smith [Fri, 10 Aug 2018 08:01:05 +0000 (18:01 +1000)] 
Be sensible computing project patch counts

Django actively fights constructing a query that isn't insane.

So, let's go and just execute a raw one. This is all very standard
SQL so should execute everywhere without a problem.

With the dataset of patchwork.ozlabs.org, looking at the /project/
page for qemu-devel would take 13 queries and 1500ms,
with this patch it's down to 11 queries in ~250ms.
For the dataset of the netdev list, it's down to 440ms from 1500ms.

Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
[stephenfin: Handle projects that have no archived patches and those
 with all patches archived]
Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agoOptimise fetching checks when displaying a patch
Stewart Smith [Fri, 10 Aug 2018 08:01:04 +0000 (18:01 +1000)] 
Optimise fetching checks when displaying a patch

Prior to this patch, a typical /patch// query for linuxppc-dev
(which has about half a dozen checks per patch) took around 20 queries
and 16.5ms in the database. About half of those queries were fetching
the checks and who did the check.

We can just do one query to get all that needed information, so we do
that. This brings a page load down to 10 queries in 12ms.

Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
7 years agoAdd covering index to patchwork_submissions for /list/ queries
Stewart Smith [Fri, 10 Aug 2018 08:01:03 +0000 (18:01 +1000)] 
Add covering index to patchwork_submissions for /list/ queries

This gets PostgreSQL to generate *much* better query plans, gaining us
about two orders of magnitude in performance on the /list/ query for the
worst state project on the patchwork.ozlabs.org instance (qemu-devel).

Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
[stephenfin: Regenerate migrations per addition of 0027 in earlier
 patch]
Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agoBe particular over check_set and series prefetch for /list/
Stewart Smith [Fri, 10 Aug 2018 08:01:02 +0000 (18:01 +1000)] 
Be particular over check_set and series prefetch for /list/

At this point it shaves at most 1-2ms off the query time for
/linuxppc-dev/list/

Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
7 years agocheck distinct(user) based on just user_id
Stewart Smith [Fri, 10 Aug 2018 08:01:01 +0000 (18:01 +1000)] 
check distinct(user) based on just user_id

The logic to display the Check(s) on the patch list wants to really do a
DISTINCT(user_id,context) ORDER BY DATE query, but with Django that is
currently a bit Too Hard (at least for me).

But what we can do is from python just use the user_id rather than the
user object itself. Same functionality, no join or prefetching users.

This saves a couple of hundred queries on the linuxppc/list/ view and
makes loading it about 4x faster in terms of time spent in the db.

Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
7 years agoAdd covering index for /list/ query
Stewart Smith [Fri, 10 Aug 2018 08:00:59 +0000 (18:00 +1000)] 
Add covering index for /list/ query

In constructing the list of patches for a project, there are two
main queries that are executed:
1) get a count() of how many patches there are
2) Get the page of results being displayed

In a test dataset of ~11500 LKML patches and ~4000 others, the existing
code would take around 585ms and 858ms with a cold cache and 28ms and
198ms for a warm cache.

By adding a covering index, we get down to 4ms and 255ms for a cold
cache, and 4ms and 143ms for a warm cache!

Additionally, when there's a lot of archived or accepted patches
(I used ~11000 archived out of the 15000 total in my test set)
the query time goes from 28ms and 72ms down to 2ms and 33-40ms!

Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
[stephenfin: Regenerate migrations per addition of 0027 in earlier
 patch]
Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agoFetch all series for patch/cover viewing
Stewart Smith [Fri, 10 Aug 2018 08:00:59 +0000 (18:00 +1000)] 
Fetch all series for patch/cover viewing

e.g. a 10 comment patch goes from 26 queries in 17-20ms down to 20
queries in 12ms.

A 67 comment cover letter goes from 14 queries in 16ms down to 8 queries
in 8ms.

So, effectively, a near 2x perf improvement.

Previously, at several points we were asking for the latest series and
then asking for all the series. Since there just usually aren't *that*
many series, fetch them all and take the first one if we need to.

Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
[stephenfin: Fix typos in the template and ensure patches from all
 series are shown]
Signed-off-by: Stephen Finucane <stephen@that.guru>
7 years agoAdd index for patchwork_comment (submission_id,date)
Stewart Smith [Fri, 10 Aug 2018 08:00:58 +0000 (18:00 +1000)] 
Add index for patchwork_comment (submission_id,date)

This (at least theoretically) should speed up displaying comments
on patches/cover letters. It's an index that will return rows
in-order for the query that we always do ("give me the comments
on this submission in date order"), rather than having to have
the database server do a sort for us.

I haven't been able to benchmark something locally that shows
this is an actual improvement, but I don't have as large data
set as various production instances. The query plan does look
a bit nicer though. Although the benefit of index maintenance
versus how long it takes to sort things is a good question.

Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
[stephenfin: Regenerate migrations per addition of 0027 in earlier
 patch]
Signed-off-by: Stephen Finucane <stephen@that.guru>