app/soc/logic/cleaning.py
changeset 886 f5847f24c56e
parent 867 f4ea0da41915
child 898 adf5b7e98dcf
equal deleted inserted replaced
885:f46b689e19eb 886:f5847f24c56e
    54       raise forms.ValidationError("This user does not exist.")
    54       raise forms.ValidationError("This user does not exist.")
    55   
    55   
    56     return user_entity
    56     return user_entity
    57   return wrapped
    57   return wrapped
    58 
    58 
       
    59 def clean_existing_user_not_equal_to_current(field_name):
       
    60   """Check if the field_name field is a valid user and is not 
       
    61      equal to the current user.
       
    62   """
       
    63 
       
    64   def wrapped(self):
       
    65     
       
    66     clean_user_field = clean_existing_user(field_name)
       
    67     user_entity = clean_user_field(self)
       
    68     
       
    69     current_user_entity = user_logic.logic.getForCurrentAccount()
       
    70     
       
    71     if user_entity.key() == current_user_entity.key():
       
    72       # users are equal
       
    73       raise forms.ValidationError("You cannot enter yourself here")
       
    74     
       
    75     return user_entity
       
    76   return wrapped
       
    77 
    59 
    78 
    60 def clean_feed_url(self):
    79 def clean_feed_url(self):
    61   feed_url = self.cleaned_data.get('feed_url')
    80   feed_url = self.cleaned_data.get('feed_url')
    62 
    81 
    63   if feed_url == '':
    82   if feed_url == '':