Fix regression that prevented accessing new organisation page
authorJonathan S. Katz <jonathan.katz@excoventures.com>
Wed, 7 Oct 2020 21:59:22 +0000 (17:59 -0400)
committerJonathan S. Katz <jonathan.katz@excoventures.com>
Wed, 7 Oct 2020 21:59:22 +0000 (17:59 -0400)
The addition of the fieldsets did not account for the fields
themselves from being removed from the new organisation form.
The OrganisationForm now removes the appropriate fieldset when
the fields are not available in this form.

pgweb/core/forms.py

index 5b1284f6d22c60508f22512c49568cbb1e62bc79..2b45fd7919d92acecf9d7c6b3c7b48f914c3f6af 100644 (file)
@@ -49,6 +49,8 @@ class OrganisationForm(forms.ModelForm):
         else:
             del self.fields['remove_manager']
             del self.fields['add_manager']
+            # remove the managers fieldset
+            self.fieldsets = [fs for fs in self.fieldsets if fs['id'] != 'managers']
 
         if self.instance and self.instance.pk and self.instance.is_approved:
             # Only allow adding/removing emails on orgs that are actually approved
@@ -56,6 +58,8 @@ class OrganisationForm(forms.ModelForm):
         else:
             del self.fields['remove_email']
             del self.fields['add_email']
+            # remove the emails fieldset
+            self.fieldsets = [fs for fs in self.fieldsets if fs['id'] != 'emails']
 
     def clean_add_email(self):
         if self.cleaned_data['add_email']: