app/soc/logic/cleaning.py
changeset 1088 7ad48d59da3d
parent 1085 0afbdd0905ef
child 1143 b07b7d5b3e27
equal deleted inserted replaced
1087:c6a7f5957b30 1088:7ad48d59da3d
    33 from soc.logic.models import site as site_logic
    33 from soc.logic.models import site as site_logic
    34 from soc.logic.models import user as user_logic
    34 from soc.logic.models import user as user_logic
    35 
    35 
    36 
    36 
    37 def clean_link_id(field_name):
    37 def clean_link_id(field_name):
    38   """Checks if the field_name value is in a valid link ID format. 
    38   """Checks if the field_name value is in a valid link ID format.
    39   """
    39   """
    40   def wrapper(self):
    40   def wrapper(self):
    41     # convert to lowercase for user comfort
    41     # convert to lowercase for user comfort
    42     link_id = self.cleaned_data.get(field_name).lower()
    42     link_id = self.cleaned_data.get(field_name).lower()
    43     if not validate.isLinkIdFormatValid(link_id):
    43     if not validate.isLinkIdFormatValid(link_id):
    44       raise forms.ValidationError("This link ID is in wrong format.")
    44       raise forms.ValidationError("This link ID is in wrong format.")
    45     return link_id
    45     return link_id
       
    46   return wrapper
       
    47 
       
    48 
       
    49 def clean_scope_path(field_name):
       
    50   """Checks if the field_name value is in a valid scope path format.
       
    51   """
       
    52   def wrapper(self):
       
    53     # convert to lowercase for user comfort
       
    54     scope_path = self.cleaned_data.get(field_name).lower()
       
    55     if not validate.isScopePathFormatValid(scope_path):
       
    56       raise forms.ValidationError("This scope path is in wrong format.")
       
    57     return scope_path
    46   return wrapper
    58   return wrapper
    47 
    59 
    48 
    60 
    49 def clean_agrees_to_tos(field_name):
    61 def clean_agrees_to_tos(field_name):
    50   """Checks if there is a ToS to see if it is allowed to leave 
    62   """Checks if there is a ToS to see if it is allowed to leave