Don't crash when changing local domain
authorMagnus Hagander <magnus@hagander.net>
Sun, 24 Feb 2019 11:28:51 +0000 (12:28 +0100)
committerMagnus Hagander <magnus@hagander.net>
Sun, 24 Feb 2019 11:28:51 +0000 (12:28 +0100)
Changes of local part was properly blocked with an error message.
Changing the local domain was blocked but then caused an exception
further down the code.

This has been broken since forever, clearly not something people have
tried, but of course still worth fixing.

pgmailmgr/mailmgr/forms.py

index 766c1f962c49628c528263cc0b3f576a81a0bac1..b541291a93625636513ada90c04e7962a425cad2 100644 (file)
@@ -47,6 +47,8 @@ class VirtualUserForm(forms.ModelForm):
     def clean(self):
         if 'local_part' not in self.cleaned_data:
             return {}
+        if 'local_domain' not in self.cleaned_data:
+            return {}
 
         # Validate that the pattern is allowed
         curs = connection.cursor()
@@ -100,6 +102,8 @@ class ForwarderForm(forms.ModelForm):
     def clean(self):
         if 'local_part' not in self.cleaned_data:
             return {}
+        if 'local_domain' not in self.cleaned_data:
+            return {}
 
         # Validate that the pattern is allowed
         curs = connection.cursor()