Avoid double-patching querysets in LocalSiteAwareModelFormMixin.

Review Request #10482 — Created March 31, 2019 and submitted — Latest diff uploaded

Information

Review Board
release-4.0.x

Reviewers

The mixin for ensuring Local Site restrictions for forms was
double-patching querysets when limiting to a Local Site. The first patch
would happen at form construction time, and the second would happen at
form cleaning time (though this one was temporary). This caused queries
like SELECT ... WHERE local_site_id=1 AND local_site_id=1.

This change fixes that to only patch during form cleaning if it hasn't
already patched at form construction.

It also updates the field accesses to work with newer versions of
Django, and splits a unit test for these restrictions into two to avoid
an ordering difference on the newer versions.

Unit tests pass on Django 1.6 and 1.11 (with other in-progress changes).

Diff Revision 1

This is not the most recent revision of the diff. The latest diff is revision 2. See what's changed.

orig
1
2

Commits

First Last Summary ID Author
Avoid double-patching querysets in LocalSiteAwareModelFormMixin.
The mixin for ensuring Local Site restrictions for forms was double-patching querysets when limiting to a Local Site. The first patch would happen at form construction time, and the second would happen at form cleaning time (though this one was temporary). This caused queries like `SELECT ... WHERE local_site_id=1 AND local_site_id=1`. This change fixes that to only patch during form cleaning if it hasn't already patched at form construction. It also updates the field accesses to work with newer versions of Django, and splits a unit test for these restrictions into two to avoid an ordering difference on the newer versions.
8de47eb231978efa20ee2d9386829d1381f02c88 Christian Hammond
reviewboard/site/mixins.py
reviewboard/webapi/tests/test_webhook.py
Loading...