summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAge
* lib: Update DB permissions to reflect model changesStephen Finucane2020-11-28
| | | | | | | These should have been done when we made changes to the model. Signed-off-by: Stephen Finucane <stephen@that.guru> Fixes: ac0e4de9 ("models: Merge 'Patch' and 'Submission'")
* 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
* requirements: Update doc requirementsStephen Finucane2020-10-01
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* requirements: Bump mysqlclient to 2.0.0Stephen Finucane2020-10-01
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* requirements: Bump django-debug-toolbar to 3.1.xStephen Finucane2020-10-01
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* requirements: Bump django-filter to 2.4.0Stephen Finucane2020-10-01
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* Add support for djangorestframework 3.12Stephen Finucane2020-10-01
| | | | | | No changes necessary. Signed-off-by: Stephen Finucane <stephen@that.guru>
* 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
* Add support for Django 3.1Andrew Donnellan2020-08-28
| | | | | Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> Reviewed-by: Stephen Finucane <stephen@that.guru>
* requirements: Update django-filterAndrew Donnellan2020-08-28
| | | | | | | | Update django-filter dependency to a version that's compatible with Django 3.1. Signed-off-by: Andrew Donnellan <ajd@linux.ibm.com> Reviewed-by: Stephen Finucane <stephen@that.guru>
* 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>
* docker: Switch to MariaDB for wider platform supportStewart Smith2020-06-15
| | | | | | | | MySQL docker images only have amd64 arch support MariaDB images have amd64, arm64v8, and ppc64le Signed-off-by: Stewart Smith <stewart@flamingspork.com> 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>
* docs: Bump sphinxcontrib-openapi to 0.7.0Stephen Finucane2020-05-08
| | | | | | | | This picks up an important fix [1] we want for our docs build. [1] https://github.com/sphinx-contrib/openapi/pull/87 Signed-off-by: Stephen Finucane <stephen@that.guru>
* Revert "tox: Add default Django version"Stephen Finucane2020-05-01
| | | | | | | This reverts commit 029aff107ea9950418f9ad3cf44c3ba1ca3ea3ee. It appears this isn't supported by tox either :( Signed-off-by: Stephen Finucane <stephen@that.guru>
* tox: Add default Django versionStephen Finucane2020-04-30
| | | | | | | | | | I occasionally forget myself and run e.g. 'tox -e pyNN' when I want to sanity check something instead of 'tox -e pyNN-djangoMM'. Add fallback Django versions so that this doesn't crash and burn. It's less succict than it could be since tox doesn't seem to support '!django{22,30}' (yet!). 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>
* docker: Ignore postgres data fileStephen Finucane2020-04-26
| | | | Signed-off-by: Stephen Finucane <stephen@that.guru>
* migrations: Squash 0001 to 0040Stephen Finucane2020-04-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that we're moving a new major version, we can squash the migrations we have to date. This coexists alongside the old migrations, which we can remove and replace entirely when we release 4.0, per the advice of the 'squashmigrations' tool. You should commit this migration but leave the old ones in place; the new migration will be used for new installs. Once you are sure all instances of the codebase have applied the migrations you squashed, you can delete them. The 'squashmigrations' tool can't parse the output of 'RunPython' blocks so the output of the tool was less optimized than it could be. As a result, we've manually modified this change to remove the 'RunPython' block and unnecessary 'AlterField' entries. This was done by removing all migrations and generating a new "initial" migration, which was then modified to mark all strings as byte strings (as they were when we were using Python 2 to generate these migrations) so that 0041 would apply cleanly. The main benefit of this change is that it significantly reduces the startup time for unit tests. Executed on my host, the run time for a single test goes from ~ 22 seconds to ~ 14 seconds. This is obviously reduced for additional tests. 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>
* travis: Resolve warnings, info messages from TravisStephen Finucane2020-04-18
| | | | | | | | | | | | | The following were reported by Travis' build config validation: - root: deprecated key 'sudo' (The key `sudo` has no effect anymore.) - env: key 'matrix' is an alias for 'jobs', using 'jobs' - root: key 'matrix' is an alias for 'jobs', using 'jobs' - root: missing 'os', using the default 'linux' Resolve all of the above. 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>
* docs: Update sphinxcontrib-openapiStephen Finucane2020-04-18
| | | | | | | | | No changes necessary, thankfully, though there is a feature gap here that we will need 0.7.0 to close [1] :( [1] https://github.com/sphinx-contrib/openapi/pull/87 Signed-off-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 'relations'Stephen Finucane2020-04-18
| | | | | | | | | | | Two issues here: - 'PATCH /patches/{id}' and 'PUT /patches/{id}' expect a list of integers on the 'related' field - not strings - 'GET /patches' and 'GET /patches/{id}' return a list of embedded patch objects on the 'related' field - not strings 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 'comments'Stephen Finucane2020-04-18
| | | | | | | Each header in the 'headers' field can be either a string or a list value. 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 'bundles'Stephen Finucane2020-04-18
| | | | | | | Errors are reported as a mapping of the field name to an array of errors, not a string. 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>
* docs: Resolve issues with 'patches'Stephen Finucane2020-04-18
| | | | | | | | | | | | | | Four issues to resolve: - The 'tags' field is a key-value mapping, not an array. - Each header in the 'headers' field can be either a string or a list value. - Errors are reported as a mapping of the field name to an array of errors, not a string. - The security type information isn't complete and doesn't account for security types. Skip it for now. Signed-off-by: Stephen Finucane <stephen@that.guru>
* docs: Move common path parameters to parentStephen Finucane2020-04-18
| | | | | | | | | Turns out you don't have to nest common elements under individual routes [1]. Less duplication and more sensible docs = winning. [1] https://swagger.io/specification/#pathItemObject Signed-off-by: Stephen Finucane <stephen@that.guru>
* docs: Make embedded fields nullable by defaultStephen Finucane2020-04-18
| | | | | | | | | | | As discussed at [1], "subtypes can add restrictions, but they cannot relax restrictions that are already in place." These fields need to be marked nullable and then "subclassed" to set non-nullability if required. [1] https://github.com/OAI/OpenAPI-Specification/issues/1368 Signed-off-by: Stephen Finucane <stephen@that.guru>