grnet / djnro

DjNRO hits the decks of eduroam database management
http://djnro.grnet.gr/
Other
10 stars 21 forks source link

InstServer M2M: fix instid handling in server edit #14

Closed vladimir-mencl-eresearch closed 8 years ago

vladimir-mencl-eresearch commented 8 years ago

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.

zmousm commented 8 years ago

Impressive pivoting through this problem :+1: Thanks!