Skip to content
  • Vladimir Mencl's avatar
    InstServer M2M: fix instid handling in server edit · fa23dd2c
    Vladimir Mencl authored
    Fix issue: editing and saving an InstServer by an inst admin drops all other Inst associations
    
    Fix: remove field['instid'] overrides
    
    Subsequent issue: this allows arbitrary edits of the list of institutions IF
    the user changes the display:none style in browser.
    
    Fix: exclude ['instid'] from the form
    
    Subsequent issue: this breaks validation relying on instid
    
    Attempted fix: access instid from model instance, not from cleaned_data: self.instance.instid.all()
    Reason for not using this fix: breaks on creating a new server:
    
        ValueError: "<InstServer: Server: , Type: None>" needs to have a value for field "instserver" before this many-to-many relationship can be used.
    
    Alternate fix: hint the list of institutions to the ModelForm out-of-band (via inst_list attribute)
    
    Additional fix: add the institution to the InstServer AFTER saving.
    fa23dd2c