app/soc/logic/cleaning.py
changeset 1984 eb02fd5427c5
parent 1962 7c9e517f2089
child 1985 4ff03ca639fd
equal deleted inserted replaced
1983:ba5be8275a75 1984:eb02fd5427c5
   160   def wrapped(self):
   160   def wrapped(self):
   161     """Decorator wrapper method.
   161     """Decorator wrapper method.
   162     """
   162     """
   163     link_id = clean_link_id(field_name)(self)
   163     link_id = clean_link_id(field_name)(self)
   164 
   164 
   165     user_entity = user_logic.getForFields({'link_id': link_id},
   165     user_entity = user_logic.getFromKeyFields({'link_id': link_id})
   166         unique=True)
       
   167 
   166 
   168     if not user_entity:
   167     if not user_entity:
   169       # user does not exist
   168       # user does not exist
   170       raise forms.ValidationError("This user does not exist.")
   169       raise forms.ValidationError("This user does not exist.")
   171 
   170 
   203   def wrapped(self):
   202   def wrapped(self):
   204     """Decorator wrapper method.
   203     """Decorator wrapper method.
   205     """
   204     """
   206     link_id = clean_link_id(field_name)(self)
   205     link_id = clean_link_id(field_name)(self)
   207 
   206 
   208     user_entity = user_logic.getForFields({'link_id': link_id},
   207     user_entity = user_logic.getFromKeyFields({'link_id': link_id})
   209         unique=True)
       
   210 
   208 
   211     if user_entity:
   209     if user_entity:
   212       # user exists already
   210       # user exists already
   213       raise forms.ValidationError("There is already a user with this link id.")
   211       raise forms.ValidationError("There is already a user with this link id.")
   214 
   212 
   428     user_account = cleaned_data.get(account_field)
   426     user_account = cleaned_data.get(account_field)
   429 
   427 
   430     # if both fields were valid do this check
   428     # if both fields were valid do this check
   431     if link_id and user_account:
   429     if link_id and user_account:
   432       # get the user from the link_id in the form
   430       # get the user from the link_id in the form
   433       fields = {'link_id': link_id}
   431 
   434       user_entity = user_logic.getForFields(fields, unique=True)
   432       user_entity = user_logic.getFromKeyFields({'link_id': link_id})
   435 
   433 
   436       # if it's not the user's current account
   434       # if it's not the user's current account
   437       if user_entity.account != user_account:
   435       if user_entity.account != user_account:
   438 
   436 
   439         # get the user having the given account
   437         # get the user having the given account