[PATCH] Add help text to project and patch_project fields
Stephen Finucane
stephen at that.guru
Sun Sep 30 08:23:13 AEST 2018
On Sat, 2018-09-29 at 01:24 +1000, Daniel Axtens wrote:
> vkabatov at redhat.com writes:
>
> > From: Veronika Kabatova <vkabatov at redhat.com>
> >
> > Duplication of the field to avoid performance issues caused some
> > unexpected results when moving patches between projects in the admin
> > interface. It's easy to change the "project" field and click save,
> > instead of double checking which field needs to be modified and kept in
> > sync with the one being changed. This lead to patch showing correct
> > project in the API and patch detail in the web UI, but the patch itself
> > was listed in the wrong project when looking at the patch listings.
> >
> > Because of the discussions of the denormalization of the tables, trying
> > to code automatic modification of the other field if one is being
> > changed seems like too much work for very little benefit. What we can do
> > instead is mention this dependency in fields' help text. Modification of
> > the project is not an everyday task so it shouldn't put too much burden
> > on the users and this simple reminder can prevent unexpected breakage
> > and bug reports.
> >
>
> Acked-by: Daniel Axtens <dja at axtens.net>
> > Signed-off-by: Veronika Kabatova <vkabatov at redhat.com>
>
> Stephen, I think this should go to stable/2.1. Thoughts?
I don't think it can. I haven't checked yet but I'm pretty sure this
requires a migration and we can't backport those.
Rather than doing this, could we not just override the 'save' function
to always save the other field?
Stephen
> Regards,
> Daniel
>
> > ---
> > patchwork/models.py | 12 ++++++++++--
> > 1 file changed, 10 insertions(+), 2 deletions(-)
> >
> > diff --git a/patchwork/models.py b/patchwork/models.py
> > index a043844d..e30a9739 100644
> > --- a/patchwork/models.py
> > +++ b/patchwork/models.py
> > @@ -350,7 +350,11 @@ class FilenameMixin(object):
> > class Submission(FilenameMixin, EmailMixin, models.Model):
> > # parent
> >
> > - project = models.ForeignKey(Project, on_delete=models.CASCADE)
> > + project = models.ForeignKey(Project, on_delete=models.CASCADE,
> > + help_text='If modifying this field on Patch, '
> > + 'don\'t forget to modify the "Patch project" '
> > + 'field appropriately as well to ensure proper '
> > + 'functionality!')
> >
> > # submission metadata
> >
> > @@ -405,7 +409,11 @@ class Patch(Submission):
> >
> > # duplicate project from submission in subclass so we can count the
> > # patches in a project without needing to do a JOIN.
> > - patch_project = models.ForeignKey(Project, on_delete=models.CASCADE)
> > + patch_project = models.ForeignKey(Project, on_delete=models.CASCADE,
> > + help_text='"Project" field needs to be '
> > + 'kept in sync and changed manually in '
> > + 'case of modifications to ensure proper '
> > + 'functionality!')
> >
> > objects = PatchManager()
> >
> > --
> > 2.17.1
> >
> > _______________________________________________
> > Patchwork mailing list
> > Patchwork at lists.ozlabs.org
> > https://lists.ozlabs.org/listinfo/patchwork
>
> _______________________________________________
> Patchwork mailing list
> Patchwork at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/patchwork
More information about the Patchwork
mailing list