• 
      

    Add a mixin for ModelForms that allow limiting data to LocalSites.

    Review Request #10364 — Created Dec. 26, 2018 and submitted

    Information

    Review Board
    release-3.0.x
    1255966...

    Reviewers

    This introduces LocalSiteAwareModelFormMixin, which can be mixed into
    any ModelForm that may need to deal with LocalSites. It handles
    validation of any relation fields (such as Many-to-Many/Foreign Key
    choice fields) to ensure that any values selected are compatible with
    the form.

    By default, forms are not tied to any LocalSite. They can create new
    objects or edit existing ones, allowing the changing of a site, the same
    way they do today. Based on the LocalSite field, though, the relation
    fields will be validated to ensure they're on the same site, if a site
    is chosen.

    Forms can be limited to a particular LocalSite during construction. In
    this mode, they can only create or edit instances for that site, and
    relation values can only be chosen if they're bound to that site.

    This ensures consistent, testable behavior that can be plugged into any
    ModelForm. Future changes will begin to migrate some forms over to
    this.

    All unit tests passed.

    Tested this with upcoming changes that convert forms over to using
    this, and RBCommons usage of those forms.

    david
    1. Ship It!
    2. 
        
    chipx86
    Review request changed
    Status:
    Completed
    Change Summary:
    Pushed to release-3.0.x (97d1f67)