summaryrefslogtreecommitdiff
path: root/patchwork
Commit message (Collapse)AuthorAge
* forms: Use a captcha on the registration form.add-captchaChristopher Baines2021-02-27
| | | | This should help avoid spam registration requests.
* templates: Use form.as_table in registration template.Christopher Baines2021-02-27
| | | | | This should make changes to the registration form easier. I'm particularly thinking about adding in the Django simple math captcha.
* api: do not fetch every patch in a patch detail view 404 (v2)Stephen Finucane2021-02-24
| | | | | | | | | | | Commit 08c5856 fixed an issue whereby a 404 on the aforementioned URL could result in a large DB query due to DRF attempting to populate the 'related' list box with all patches on the instance. That was accidentally reverted in commit fe07f30. "Unrevert" this change. Signed-off-by: Stephen Finucane <stephen@that.guru> Fixes: fe07f30 ("Remove 'PatchRelationSerializer'") Closes: #397
* docs: Refresh the guide for Ubuntu 20.04Stephen Finucane2021-02-20
| | | | | | | Nothing changes wrt package names, which is nice. We take the opportunity to clarify some wording, however. Signed-off-by: Stephen Finucane <stephen@that.guru>
* models: Use parent model to get comment's 'list_archive_url'Stephen Finucane2021-02-20
| | | | | | | | | | | We were attempting to retrieve the 'list_archive_url' attribute from the 'PatchComment' or 'CoverComment' instances, rather than the parent 'Patch' and 'Cover' object, respectively. Correct this and add plenty of tests to prevent this regressing. Signed-off-by: Stephen Finucane <stephen@that.guru> Fixes: 02ffb1315 ("models: Add list archive lookup") Closes: #391
* urls: Convert to flask-style URL patternsStephen Finucane2021-02-20
| | | | | | | | | | These are easier to grok that the old regex based paths, though three of these are retained as an alternative to creating custom path converters [1]. [1] https://docs.djangoproject.com/en/3.0/topics/http/urls/#registering-custom-path-converters Signed-off-by: Stephen Finucane <stephen@that.guru>
* tests: Trivial formatting fixesStephen Finucane2021-02-20
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* urls: Support sha256-based tokensStephen Finucane2021-02-20
| | | | | | | | | | | | | | | | | | | Django 3.1 changed the default hashing algorithm used for things like password reset tokens from SHA-1 to SHA-256. As noted in the release notes [1], this is configurable via the 'DEFAULT_HASHING_ALGORITHM' transitional setting, but that's only intended to allow upgrades of multiple instances in a HA deployment and shouldn't be used post upgrade. Instead, we need to fix our URLs to support the longer tokens generated by SHA-256. Long term, we want to replace these regex-based routes with the simpler flask-style template string routes. That's not really backportable so we'll do that separately. [1] https://docs.djangoproject.com/en/3.1/releases/3.1/#default-hashing-algorithm-settings Signed-off-by: Stephen Finucane <stephen@that.guru> Closes: #394
* tests: Fix compatibility with openapi_core 0.13.7Stephen Finucane2021-02-20
| | | | | | | | | | | It seems the 'openapi_core.schema.schemas.models.Format' mechanism of defining custom formatters was deprecated in openapi_core 0.12.0 but we never noticed. They've finally broken it in 0.13.7. Switch to the new thing, 'openapi_core.unmarshalling.schemas.formatters.Formatter', which expects a slightly different format. Signed-off-by: Stephen Finucane <stephen@that.guru> Closes: #395
* Post-release version bumpStephen Finucane2020-12-13
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* Release 3.0.0Stephen Finucane2020-12-13
| | | | | | | Major version bump because of Python 2.7 removal and the unfortunately large DB migration. Signed-off-by: Stephen Finucane <stephen@that.guru>
* REST: Null out previous, current relation infoStephen Finucane2020-12-13
| | | | | | | | | | | | | | | | | These fields don't work like we expect them to. Because we're linking to a non-idempotent entity, an instance of 'relation', what we're storing in either of these fields is subject to change as patches are added and removed. This makes the information pretty much useless after the fact. It's best to just state the patch and request that people query the information themselves if necessary. We don't want to remove the field entirely from the API - that would be a truly breaking change - so instead we null it out like we do for patch tags. In a v2 API (i.e. a major version bump) we can remove this entirely. A small bug with the schema generation is corrected. Signed-off-by: Stephen Finucane <stephen@that.guru> Related: #379
* Remove 'PatchRelationSerializer'Stephen Finucane2020-12-13
| | | | | | | | | | | | | | | | | This wasn't writeable for reasons I haven't been able to figure out. However, it's not actually needed: the 'PatchSerializer' can do the job just fine, given enough information. This exposes a bug in DRF, which has been reported upstream [1]. While we wait for that fix, or some variant of it, to be merged, we must monkey patch the library. [1] https://github.com/encode/django-rest-framework/issues/7550 [2] https://github.com/encode/django-rest-framework/pull/7574 Signed-off-by: Stephen Finucane <stephen@that.guru> Reported-by: Ralf Ramsauer <ralf.ramsauer@oth-regensburg.de> Closes: #379 Cc: Daniel Axtens <dja@axtens.net> Cc: Rohit Sarkar <rohitsarkar5398@gmail.com>
* tests: Add tests for 'patch-relation-changed' eventsStephen Finucane2020-12-13
| | | | | | | | | | | | | | | | | | | | | This event is rather odd. If you have two patches then the way a relation is created is by creating a 'PatchRelation' instance and then setting the 'related' attribute on the first patch followed by the second patch. Because the event uses the 'Patch' model's 'pre_save' signal, we'll only see events for the patch being currently saved. This means no event will be raised for the first patch and only one event, the one for the second patch, will be raised when the second patch is being added to the relationship. In hindsight, the structure of the event is off. We should have had something like a 'patch-added-to-relationship' and a 'patch-removed-from-relationship' event, both with the same fields: 'project', 'actor', 'patch' and 'related', the latter of which would have listed all of the _other_ patches in the relationship. Sadly, this is an API change which means we can't do it now. We may well wish to do so in the future though. Signed-off-by: Stephen Finucane <stephen@that.guru>
* tests: Rework 'create_relation' helperStephen Finucane2020-12-13
| | | | | | | | This wasn't actually creating just a patch relation object - it was also creating patches, which is something we already have an explicit helper for. Clean this thing up. Signed-off-by: Stephen Finucane <stephen@that.guru>
* views/patch: Set correct encoding for patchesToke Høiland-Jørgensen2020-12-11
| | | | | | | | | | | The patch_mbox view returns text/plain data without specifying a character set, which means clients will assume the default of iso-8559-1 as defined in the HTTP/1.1 standard. Since the data being returned is in fact utf-8 encoded, set the encoding accordingly in the HTTP Content-Type header. Reported-by: Jakub Kicinski <kuba@kernel.org> Suggested-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org> Signed-off-by: Toke Høiland-Jørgensen <toke@toke.dk>
* parser: Update reference to PatchCommentStephen Finucane2020-11-28
| | | | | | | | | | | | | Commit 0686a736fbf6d869bd31bd135ba38080ac96de22 split out 'CoverLetter' from the old 'Submission' model, removing the common 'Comment' model in favour of distinct 'CoverComment' and 'PatchComment' models in the process. Unfortunately we misssed some references to the old model in the 'patchwork.parser' module. Correct these now, adding unit tests to prevent regressions. Signed-off-by: Stephen Finucane <stephen@that.guru> Fixes: 0686a736 ("models: Split 'CoverLetter' from 'Submission'") Closes: #384
* models: Validate Project.linkname does not contain forward slashThomas Bracht Laumann Jespersen2020-10-01
| | | | | | | | | | | | | | | | | | | | | | | | | | I started by creating a project that contained a forward slash (importing patches from https://lists.sr.ht/~sircmpwn/sr.ht-dev/) and it fails to render the "projects" main page. The specific error reads: NoReverseMatch at / Reverse for 'patch-list' with keyword arguments '{'project_id': 'foo/bar'}' not found. 1 pattern(s) tried: ['project/(?P<project_id>[^/]+)/list/$'] which appears to explicitly disallow forward slashes. So I think it makes sense to validate that project linkname doesn't contain forward slahes. This implementation uses the validate_unicode_slug validator instead of just rejecting inputs that contain forward slashes. Signed-off-by: Thomas Bracht Laumann Jespersen <t@laumann.xyz> Signed-off-by: Stephen Finucane <stephen@that.guru> Closes: #380
* settings: Add context processor django.template.context_processors.requestAndrew Donnellan2020-08-28
| | | | | | | | | Django 3.1 adds a new admin sidebar feature that requires the django.template.context_processors.request context processor to be enabled in the settings. Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> Reviewed-by: Stephen Finucane <stephen@that.guru>
* urls: Update url pattern functionsAndrew Donnellan2020-08-28
| | | | | | | | | Django 3.1 deprecates django.conf.urls.url() as an alias for django.urls.re_path(). Also switch to using django.urls.include() rather than django.conf.urls.include(). Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> Signed-off-by: Stephen Finucane <stephen@that.guru>
* templates: Replace ifequal and ifnotequal with ifAndrew Donnellan2020-08-28
| | | | | | | | Django 3.1 deprecates the ifequal and ifnotequal tags, for removal in 4.0. Replace all occurrences of ifequal and ifnotequal with if. Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> Reviewed-by: Stephen Finucane <stephen@that.guru>
* management: introduce replacerelations commandRohit Sarkar2020-08-10
| | | | | | | | | | | | | The replacerelations script is used to ingest relations into Patchwork's patch database. A patch groups file is taken as input, which on each line contains a space separated list of patchwork ids denoting a relation. All the existing relations in Patchwork's database are removed and the relations read from the patch groups file are ingested. Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com> [dja: pep8, drop relations directory as empty dirs don't get stored by git, comment about how lines are generated.] Signed-off-by: Daniel Axtens <dja@axtens.net>
* admin: fix series queryJan Remmet2020-05-25
| | | | | | | remove typo from search_fields. Signed-off-by: Jan Remmet <j.remmet@phytec.de> Signed-off-by: Stephen Finucane <stephen@that.guru>
* migrations: Moved squashed migrationStephen Finucane2020-04-26
| | | | | | | | This should have been in the 'patchwork/migrations' directory, not 'migrations. Signed-off-by: Stephen Finucane <stephen@that.guru> Fixes: 9bb5caec ("migrations: Squash 0001 to 0040")
* migrations: Resolve issues with other DB backends for 0042, 0043Stephen Finucane2020-04-26
| | | | | | | | | | 0042 was using MySQL-specific SQL to delete entries in the 'patchwork_comment' table that were associated with entries in the 'patchwork_coverletter' table, while 0043 only considered MySQL and PostgrSQL when attempting to copy fields from 'patchwork_patch' to 'patchwork_submission'. Both issues are resolved. Signed-off-by: Stephen Finucane <stephen@that.guru>
* models: Trivial post-merge cleanupStephen Finucane2020-04-26
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* models: Merge 'Patch' and 'Submission'Stephen Finucane2020-04-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Oh, the follies of youth. Time to undo the damage of 2.0.0, specifically commit 86172ccc16, which split Patch into two separate models using concrete inheritance. As noted previously, this introduced a large number of unavoidable JOINs across large tables and the performance impacts these introduce are blocking other features we want, such as improved tagging functionality. To combine these two models, we must do the following: - Update any references to the 'Patch' model to point to the 'Submission' model instead - Move everything from 'Patch' to 'Submission', including both fields and options - Delete the 'Patch' model - Rename the 'Submission' model to 'Patch' With this change, our model "hierarchy" goes from: Submission Patch PatchComment Cover CoverComment To a nice, flat: Patch PatchComment Cover CoverComment I expect this migration to be intensive, particularly for MySQL users who will see their entire tables rewritten. Unfortunately I don't see any way to resolve this in an easier manner. Signed-off-by: Stephen Finucane <stephen@that.guru>
* models: Split 'CoverLetter' from 'Submission'Stephen Finucane2020-04-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We want to get rid of the split between 'Patch' and 'Submission' because of the cost of using JOINs basically everywhere we use 'Patch'. Before we do that, we need to move the other users of 'Submission' to other models and other models that rely on these users sharing the common 'Submission' base. For the former, there is only one user, 'CoverLetter', while for the latter there is only the 'Comment' model. As a result, we must do the following: - Create a new 'Cover' model - Create a new 'CoverComment' model - Move everything from 'CoverLetter' to 'Cover' and all entries associated with a 'CoverLetter' from 'Comment' to 'CoverComment' - Delete the 'CoverLetter' model - Rename the 'Comment' model to 'PatchComment' This means our model "hierarchy" goes from: Submission Patch CoverLetter Comment To: Submission Patch PatchComment Cover CoverComment A future change will flatten the 'Submission' and 'Patch' model. Note that this actually highlighted a bug in Django, which has since been reported upstream [1]. As noted there, the issue stems from MySQL's refusal to remove an index from a foreign key when DB constraints are used and the workaround is to remove the foreign key constraint before altering the indexes and then re-add the constraint after. [1] https://code.djangoproject.com/ticket/31335 Signed-off-by: Stephen Finucane <stephen@that.guru>
* Revert "Be sensible computing project patch counts"Stephen Finucane2020-04-26
| | | | | | | | | | | | | | | This reverts commit cfcf2f2a80ac0709f1a5fd9aa212c8403daa5a18. This will no longer be necessary once we remove the Patch-Submission split. Revert it now to avoid needing to rejig this later. Conflicts: patchwork/views/project.py NOTE(stephenfin): Conflicts are due to commit 880ec8c5 ("Fetch maintainer information in one query") which changed nearby lines. Signed-off-by: Stephen Finucane <stephen@that.guru>
* Remove unnecessary references to Submission modelStephen Finucane2020-04-26
| | | | | | | We want to drop this in future changes. Start by removing any unnecessary references. Signed-off-by: Stephen Finucane <stephen@that.guru>
* trivial: Rename 'CoverLetter' references to 'Cover'Stephen Finucane2020-04-26
| | | | | | | We're going to be doing some model surgery shortly. Do the necessary renaming of variables ahead of this. Signed-off-by: Stephen Finucane <stephen@that.guru>
* forms: Remove LoginFormStephen Finucane2020-04-23
| | | | | | This should have been removed in commit f1e089f773. Signed-off-by: Stephen Finucane <stephen@that.guru>
* parser: don't trigger database IntegrityErrors on duplicate coverlettersJeremy Kerr2020-04-18
| | | | | | | | | As we've done for the Patch and Comment models, this change prevents database errors from duplicate CoverLetters. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stephen Finucane <stephen@that.guru> [stephenfin: Add release note]
* parser: don't trigger database IntegrityErrors on duplicate commentsJeremy Kerr2020-04-18
| | | | | | | | As we've done for the Patch model, this change prevents database errors from duplicate Comments. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Reviewed-by: Stephen Finucane <stephen@that.guru>
* parser: prevent IntegrityErrorsJeremy Kerr2020-04-18
| | | | | | | | | | | Currently, the parser relies on causing (and catching) IntegrityErrors on patch insert to catch duplicate (msgid,project) mails. This change performs an atomic select -> insert instead. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stephen Finucane <stephen@that.guru> [stephenfin: Remove 'expectedFailure' marker again]
* tests: ensure we don't see database errors during duplicate insertJeremy Kerr2020-04-18
| | | | | | | | | | | | Currently, the parser causes IntegrityErrors while inserting duplicate patches; these tend to pollute database logs. This change adds a check, which currently fails, to ensure we do not cause errors during a duplicate patch parse. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Stephen Finucane <stephen@that.guru> [stephenfin: Add 'expectedFailure' marker to keep all tests green]
* tests: Add duplicate mail testJeremy Kerr2020-04-18
| | | | | | | | Test that we get the correct DuplicateMailError from parsing the same mail twice. Signed-off-by: Jeremy Kerr <jk@ozlabs.org> Reviewed-by: Stephen Finucane <stephen@that.guru>
* parser: Don't crash when From: is list email but has weird mangle formatAndrew Donnellan2020-04-18
| | | | | | | | | | | | | | | | | | | | get_original_sender() tries to demangle DMARC-mangled From headers, in the case where the email's From address is the list address. It knows how to handle Google Groups and Mailman style mangling, where the original submitter's name will be turned into e.g. "Andrew Donnellan via linuxppc-dev". If an email has the From header set to the list address but has a name that doesn't include " via ", we'll throw an exception because stripped_name hasn't been set. Sometimes this is because the list name is seemingly empty, resulting in a mangled name like "Andrew Donnellan via" without the space after "via" that we detect. Handle this as well as we can instead, and add a test. Fixes: 8279a84238c10 ("parser: Unmangle From: headers that have been mangled for DMARC purposes") Reported-by: Jeremy Kerr <jk@ozlabs.org> Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> Reviewed-by: Stephen Finucane <stephen@that.guru>
* tests: Switch to openapi-core 0.13.xStephen Finucane2020-04-18
| | | | | | | | | | | | | We've done the necessary work here already so this is a relatively easy switchover. However, we do have to work around an issue whereby the first possible matching route is used rather than the best one [1]. In addition, we have to install from master since there are fixes missing from the latest release, 0.13.3. Hopefully both issues will be resolved in a future release. [1] https://github.com/p1c2u/openapi-core/issues/226 Signed-off-by: Stephen Finucane <stephen@that.guru>
* tests: Drop Django 1.x supportStephen Finucane2020-04-18
| | | | | | | | openapi-core 0.13.x has added support for Django validation. Before we migrate to that version and presumably remove most of this code, remove the stuff that is *definitely* dead. Signed-off-by: Stephen Finucane <stephen@that.guru>
* docs: Resolve issues with 'events'Stephen Finucane2020-04-18
| | | | | | | | | | | | | | Four things to change here: - The response is any array that can contain any type of event, not one of them. - The 'actor' field is nullable. - The 'cover' field of the 'cover-created' event is an embedded cover letter, not a string. - The specifications for the 'current_delegate' and 'previous_delegate' fields of the 'patch-delegated' field were apparently invalid. Signed-off-by: Stephen Finucane <stephen@that.guru>
* docs: Resolve issues with 'patches'Stephen Finucane2020-04-18
| | | | | | | | | | Two issues: - Errors are reported as a mapping of the field name to an array of errors, not a string. - We were attempting to validate an invalid request. Signed-off-by: Stephen Finucane <stephen@that.guru>
* docs: Resolve issues with 'covers'Stephen Finucane2020-04-18
| | | | | | | | | | | Two issues to correct: - Each header in the 'headers' field can be either a string or a list value. - We state that the 'content' field will always have content but our tests were configuring otherwise. Signed-off-by: Stephen Finucane <stephen@that.guru>
* docs: Resolve issues with 'projects'Stephen Finucane2020-04-18
| | | | | | | | | Two issues here: - The ID in '/projects/{id}' can be either an integer or a string. - We were attempting to validate an invalid request. Signed-off-by: Stephen Finucane <stephen@that.guru>
* REST: Allow update of bundle without patchesStephen Finucane2020-04-18
| | | | | | | | | | Presently, when updating a patch we assume that patches are provided. This isn't necessary - you might just want to make it public - and isn't enforced by the API itself. However, because we make this assumption, we see a HTTP 500. Resolve the issue and add tests to prevent a regression. Signed-off-by: Stephen Finucane <stephen@that.guru> Resolves: #357
* api: allow filtering patches and covers by msgidDaniel Axtens2020-04-14
| | | | | | | | | | | | | | | | | | | | In the process of fixing the previous bug, I realised that: a) /api/patches/msgid is a perfectly reasonable thing to attempt b) We have no way of finding a patch by message id in the API We can't actualy make /api/patches/msgid work because it may not be unique, but we can add a filter. I'm shoehorning this into stable/2.2, even though it's technically an API change: it's minor, not incompatible and in hindsight a glaring hole. Cc: Michael Ellerman <mpe@ellerman.id.au> Tested-by: Jeremy Kerr <jk@ozlabs.org> Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com> Reviewed-by: Stephen Finucane <stephen@that.guru> Signed-off-by: Daniel Axtens <dja@axtens.net>
* api: do not fetch every patch in a patch detail view 404Daniel Axtens2020-04-14
| | | | | | | | | | | | | | | | | | | | | | | mpe and jk and sfr found that the OzLabs server was melting due to some queries downloading every patch. Turns out if you 404 the patch detail view in the API, d-r-f attempts to render a listbox with every single patch to fill in the 'related' field. The bundle API also has a similar field. Replace the multiple selection box with a text field. You can still (AIUI) populate the relevant patch IDs manually. This is the recommended approach per https://www.django-rest-framework.org/topics/browsable-api/#handling-choicefield-with-large-numbers-of-items Reported-by: Jeremy Kerr <jk@ozlabs.org> Reported-by: Michael Ellerman <mpe@ellerman.id.au> Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Tested-by: Jeremy Kerr <jk@ozlabs.org> Server-no-longer-on-fire-by: Jeremy Kerr <jk@ozlabs.org> Reviewed-by: Stephen Finucane <stephen@that.guru> Signed-off-by: Daniel Axtens <dja@axtens.net>
* Additional Python 2.7 cleanupsStephen Finucane2020-04-09
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* tests: Close XML-RPC client when doneStephen Finucane2020-04-09
| | | | | | | | | | | | | | | | | | This resolves the following irritating warnings that were popping up on Python 3.7 and 3.8 and were silenced on 3.6: /usr/lib/python3.7/unittest/suite.py:107: ResourceWarning: unclosed <socket.socket ...> Note that we need to use a subclass because the 'ServerProxy' class, rather annoyingly, does not expose a 'close()' method. Instead, you're expected to use a context manager, which isn't useful from the context of a 'setUp' call. We could call '__enter__' and '__exit__' manually but this seems cleaner. Also note that 'Server' was an alias of 'ServerProxy' [1], and we're taking the opportunity to switch here. [1] https://docs.python.org/3/library/xmlrpc.client.html#xmlrpc.client.ServerProxy Signed-off-by: Stephen Finucane <stephen@that.guru>
* Remove __future__ importsStephen Finucane2020-04-09
| | | | | | | | All of these are defaults in Python 3 [1]. [1] https://docs.python.org/3.6/library/__future__.html Signed-off-by: Stephen Finucane <stephen@that.guru>