app/soc/logic/cleaning.py
changeset 2859 391766c2aacf
parent 2787 8408741aee63
child 2927 ac4f93519855
equal deleted inserted replaced
2858:9b59d89e6707 2859:391766c2aacf
   789   access_level = self.cleaned_data[field]
   789   access_level = self.cleaned_data[field]
   790 
   790 
   791   if not has_access(rights, access_level, scope_path, prefix):
   791   if not has_access(rights, access_level, scope_path, prefix):
   792     self._errors[field] = ErrorList([DEF_NO_RIGHTS_FOR_ACL_MSG])
   792     self._errors[field] = ErrorList([DEF_NO_RIGHTS_FOR_ACL_MSG])
   793     del self.cleaned_data[field]
   793     del self.cleaned_data[field]
       
   794 
       
   795 
       
   796 def str2set(string_field):
       
   797   """Clean method for cleaning comma separated strings.
       
   798 
       
   799   Obtains the comma separated string from the form and returns it as
       
   800   a set of strings.
       
   801   """
       
   802 
       
   803   def wrapper(self):
       
   804     """Decorator wrapper method.
       
   805     """
       
   806     cleaned_data = self.cleaned_data
       
   807 
       
   808     string_data = cleaned_data.get(string_field)
       
   809 
       
   810     list_data = []
       
   811     for string in string_data.split(','):
       
   812       string_strip = string.strip()
       
   813       if string_strip and string_strip not in list_data:
       
   814         list_data.append(string_strip)
       
   815 
       
   816     return list_data
       
   817 
       
   818   return wrapper