Example #1
0
File: user.py Project: LANJr4D/FRED
 def check_nperms(self, nperms, check_type = 'all'):
     'Returns True if user has NOT permission (has negative permission)'
     result = ((isinstance(nperms, types.StringTypes) and self.has_nperm(nperms)) or 
               (isiterable(nperms) and 
                (check_type == 'all' and self.has_all_nperms(nperms) or
                 check_type == 'one' and self.has_one_nperm(nperms))))
     return result 
Example #2
0
 def check_nperms(self, nperms, check_type='all'):
     'Returns True if user has NOT permission (has negative permission)'
     result = ((isinstance(nperms, types.StringTypes)
                and self.has_nperm(nperms))
               or (isiterable(nperms) and
                   (check_type == 'all' and self.has_all_nperms(nperms)
                    or check_type == 'one' and self.has_one_nperm(nperms))))
     return result
Example #3
0
 def _set_value(self, value):
     if not value:
         self._value = [None] * len(self.fields)
         for field in self.fields:
             field.value = None
         return
     else:
         self._value = value
         if not isiterable(value) and len(value) != len(self.fields):
             raise TypeError(u'value of MultiValueField must be sequence with the same length as a number of fields in multifield (was %s)' % unicode(value))
         for i, val in enumerate(value):
             self.fields[i].value = val
Example #4
0
 def _set_value(self, value):
     if not value:
         self._value = [None] * len(self.fields)
         for field in self.fields:
             field.value = None
     else:
         self._value = value
         if not isiterable(value) and len(value) != len(self.fields):
             raise TypeError(
                 u'value of MultiValueField must be sequence with the same length as a number of fields in multifield (was % s)'
                 % unicode(value))
         for i, val in enumerate(value):
             self.fields[i].value = val
Example #5
0
 def decompress(self, value):
     if value and not isiterable(
             value):  # wrap single non-empty value into list
         return [value]
     else:
         return value
Example #6
0
 def compress(self, data_list):
     if data_list and not isiterable(
             data_list):  # wrap single non-empty value into list
         return [data_list]
     else:
         return data_list