Add more flexible form and field spport in LocalSiteAwareModelFormMixin.
Review Request #10409 — Created Feb. 15, 2019 and submitted
LocalSiteAwareModelFormMixin
has been updated to work with a wider
variety of forms. Specifically, those that take in arequest
parameter, which previously was not being passed in to the parent form.
Since there's no reliable way to introspect whether the parent requires
this parameter, and since the mixin itself needs it, we now have a flag
that the form can set to specify it needs this parameter. This will be
required for theIntegrationConfigForm
in a future change.This also improves the field support.
ConditionField
s are now
supported, and will have theirLocalSite
set in order to limit valid
results to those on the selected site. On top of this, the logic for
overriding and then restoring the queryset on fields has been expanded
to do the same with thelocal_site_name
attribute on a field's
RelatedUserWidget
, ensuring everything is back to normal after
validation if not limiting the form to aLocalSite
.
Unit tests pass, both as of this change and with the upcoming work to
moveIntegrationConfigForm
over to this mixin.Manually tested the forms with this mixin.