app/soc/views/site/user/profile.py
changeset 483 70f21691b0e1
parent 482 839740b061ad
child 500 44ea4620c5c0
equal deleted inserted replaced
482:839740b061ad 483:70f21691b0e1
   234     link_name = self.cleaned_data.get('link_name')
   234     link_name = self.cleaned_data.get('link_name')
   235     if not validate.isLinkNameFormatValid(link_name):
   235     if not validate.isLinkNameFormatValid(link_name):
   236       raise forms.ValidationError("This link name is in wrong format.")
   236       raise forms.ValidationError("This link name is in wrong format.")
   237 
   237 
   238     key_name = self.data.get('key_name')
   238     key_name = self.data.get('key_name')
   239     user = models.user.logic.getFromKeyName(key_name)
   239     if key_name:
   240     
   240       key_name_user = user_logic.logic.getFromKeyName(key_name)
   241     linkname_user_exist = models.user.logic.getForFields(
   241 
   242         {'link_name': link_name}, unique=True)
   242       if link_name_user and key_name_user and \
   243         
   243           link_name_user.account != key_name_user.account:
   244     if (user and user.link_name != link_name) and linkname_user_exist:
   244         raise forms.ValidationError("This link name is already in use.")
   245       raise forms.ValidationError("This link name is already in use.")
       
   246 
   245 
   247     return link_name
   246     return link_name
   248 
   247 
   249   def clean_account(self):
   248   def clean_account(self):
   250     form_account = users.User(email=self.cleaned_data.get('account'))
   249     form_account = users.User(email=self.cleaned_data.get('account'))