]> git.ipfire.org Git - thirdparty/patchwork.git/commit
models: Split Patch into two models
authorStephen Finucane <stephen.finucane@intel.com>
Fri, 25 Mar 2016 17:29:29 +0000 (17:29 +0000)
committerStephen Finucane <stephen.finucane@intel.com>
Fri, 1 Apr 2016 14:51:54 +0000 (15:51 +0100)
commit86172ccc161b44d68fcbc734f642644c8e1be84a
tree482923c6321068b1dfe5637970d359e25c7a0081
parent6702a0c92b161ba8520857f1259faa83488c7100
models: Split Patch into two models

There are a lot of similarities between cover letters and patches: so
many, in fact, that it would be helpful to occasionally treat them as
the same thing. Achieve this by extracting out the fields that would be
shared between a Patch and a hypothetical cover letter into a "sub
model". This allows us to do cool stuff like assigning comments to both
patches and cover letters or listing both patches and cover letters on
the main screen in a natural way.

The migrations for this are really the only complicated part. There are
three, broken up into schema and data migrations per Django customs,
and they works as follows:

* Rename the 'Patch' model to 'Submission', then create a subclass
  called 'Patch' that includes duplicates of the patch-specific fields
  of Submission (with changed names to prevent conflicts). Rename
  non-patch specific references to the renamed 'Submission' model
  as necessary.
* Duplicate the contents of the patch-specific fields from 'Submission'
  to 'Patch'
* Remove the patch-specific fields from 'Submission', renaming the
  'Patch' model to take their place. Update the patch-specific
  references to point the new 'Patch' model, rather than 'Submission'.

This comes at the cost of an additional JOIN per item on the main
screen, but this seems a small price to pay for the additional
functionality gained. To minimise this, however, caching will be added.

Signed-off-by: Stephen Finucane <stephen.finucane@intel.com>
Signed-off-by: Andy Doan <andy.doan@linaro.org>
14 files changed:
patchwork/admin.py
patchwork/bin/parsemail.py
patchwork/forms.py
patchwork/migrations/0009_add_submission_model.py [new file with mode: 0644]
patchwork/migrations/0010_migrate_data_from_submission_to_patch.py [new file with mode: 0644]
patchwork/migrations/0011_remove_temp_fields.py [new file with mode: 0644]
patchwork/models.py
patchwork/paginator.py
patchwork/settings/base.py
patchwork/tests/test_mboxviews.py
patchwork/tests/test_patchparser.py
patchwork/tests/test_tags.py
patchwork/tests/test_user.py
patchwork/views/__init__.py