app/soc/logic/cleaning.py
changeset 1285 d54f2d80f46e
parent 1242 c5ca70606850
child 1287 9b18d612510a
equal deleted inserted replaced
1284:92f7a24d8f42 1285:d54f2d80f46e
   224     if link_id and user_account:
   224     if link_id and user_account:
   225       # get the user from the link_id in the form
   225       # get the user from the link_id in the form
   226       fields = {'link_id': link_id}
   226       fields = {'link_id': link_id}
   227       user_entity = user_logic.logic.getForFields(fields, unique=True)
   227       user_entity = user_logic.logic.getForFields(fields, unique=True)
   228 
   228 
   229       former_accounts = user_entity.former_accounts
   229       # if it's not the user's current account
   230 
       
   231       # if it's not the user's current account or one of his former accounts
       
   232       if user_entity.account != user_account:
   230       if user_entity.account != user_account:
   233 
   231 
   234         # get the user having the given account
   232         # get the user having the given account
   235         fields = {'account': user_account}
   233         fields = {'account': user_account}
   236         user_from_account_entity = user_logic.logic.getForFields(fields, 
   234         user_from_account_entity = user_logic.logic.getForFields(fields, 
   237             unique=True)
   235             unique=True)
   238 
   236 
   239         # if there is a user with the given account or it's a former account
   237         # if there is a user with the given account or it's a former account
   240         if user_from_account_entity or user_logic.logic.isFormerAccount(user_account):
   238         if user_from_account_entity or user_logic.logic.isFormerAccount(user_account):
   241           # raise an error because this email address can't be used
   239           # raise an error because this email address can't be used
   242           raise forms.ValidationError("There is already a user with this email adress.")
   240           raise forms.ValidationError("There is already a user with this email address.")
   243 
   241 
   244     return cleaned_data
   242     return cleaned_data
   245   return wrapper
   243   return wrapper
   246 
   244 
   247 
   245