Avoid double-patching querysets in LocalSiteAwareModelFormMixin.
Review Request #10482 — Created March 31, 2019 and submitted
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
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).
F811 redefinition of unused 'test_post_all_repositories_not_same_local_site' from line 132
Fixed a duplicate test name and re-ran all tests.
Revision 2 (+158 -52)
Checks run (2 succeeded)