app/soc/views/site/user/profile.py
changeset 483 70f21691b0e1
parent 482 839740b061ad
child 500 44ea4620c5c0
--- a/app/soc/views/site/user/profile.py	Sat Nov 15 16:17:11 2008 +0000
+++ b/app/soc/views/site/user/profile.py	Sat Nov 15 21:46:23 2008 +0000
@@ -236,13 +236,12 @@
       raise forms.ValidationError("This link name is in wrong format.")
 
     key_name = self.data.get('key_name')
-    user = models.user.logic.getFromKeyName(key_name)
-    
-    linkname_user_exist = models.user.logic.getForFields(
-        {'link_name': link_name}, unique=True)
-        
-    if (user and user.link_name != link_name) and linkname_user_exist:
-      raise forms.ValidationError("This link name is already in use.")
+    if key_name:
+      key_name_user = user_logic.logic.getFromKeyName(key_name)
+
+      if link_name_user and key_name_user and \
+          link_name_user.account != key_name_user.account:
+        raise forms.ValidationError("This link name is already in use.")
 
     return link_name