Example #1
0
 def to_python(self, value):
     if utils.is_str(value):
         if value:
             value = [int(x) for x in value.strip('[]').split(',') if x]
         else:
             value = []
     return value
Example #2
0
def coerce_value(value):
    if value is None:
        return []
    if utils.is_str(value):
        if value:
            value = [int(x) for x in value.strip('[]').split(',') if x]
        else:
            value = []
    elif isinstance(value, list):
        return [int(x) for x in value]
    return value
Example #3
0
 def render(self, name, value, attrs=None):
     if attrs is None:
         attrs = {}
     if utils.is_str(value):
         value = [int(i) for i in value.split(',') if i]
     if not value or value == range(7):
         value = [str(x[0]) for x in self.choices]
     if all([x in value for x in range(5)]):
         value.append('0,1,2,3,4')
     if 5 in value and 6 in value:
         value.append('5,6')
     if 'class' not in attrs:
         attrs['class'] = ""
     attrs['class'] += " advanced-weekday-field"
     result = super(ToggleCheckboxes, self).render(name, value, attrs)
     result = result.replace(" Weekends</label></li>",
                             " Weekends</label></li></ul><ul>")
     return mark_safe(result)
Example #4
0
 def get_db_prep_value(self, value, connection=None, prepared=False):
     if not utils.is_str(value):
         value = ",".join([str(x) for x in value or []])
     return value