Fix a couple more bugs
[invirt/packages/invirt-web.git] / code / validation.py
index caa8ce2..7eb1b4f 100644 (file)
@@ -241,7 +241,7 @@ def testOwner(user, owner, machine=None):
     return owner
 
 def testContact(user, contact, machine=None):
-    if contact in (None, machine.contact):
+    if contact is None or (machine is not None and contact == machine.contact):
         return None
     if not re.match("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$", contact, re.I):
         raise InvalidInput('contact', contact, "Not a valid email.")