Example #1
0
 def _to_string(self, errors):
     if is_string(errors):
         return errors
     if isinstance(errors, dict):
         return sequence_to_str(errors.values())
     if is_sequence(errors):
         return sequence_to_str(errors)
     return None
Example #2
0
def _to_str(value, form_field=None):
    if value is None:
        return u"--"
    if is_sequence(value):
        return sequence_to_str(value)
    if isinstance(value, datetime):
        date_format = DateField.FORMAT_DATE_DICTIONARY.get(
            form_field.date_format) if form_field else DEFAULT_DATE_FORMAT
        return format_date(value, date_format)
    return value
Example #3
0
def _tabulate_data(entity, row, short_code, type):
    id = row['id']
    geocode = row['doc']['geometry'].get('coordinates')
    geocode_string = ", ".join([str(i) for i in geocode]) if geocode is not None else "--"
    location = _format(sequence_to_str(entity.location_path))
    name = _format(entity.value(NAME_FIELD))
    mobile_number = _format(entity.value(MOBILE_NUMBER_FIELD))
    description = _format(entity.value(DESCRIPTION_FIELD))
    return dict(id=id, name=name, short_name=short_code, type=type, geocode=geocode_string, location=location,
                description=description, mobile_number=mobile_number)
Example #4
0
def _tabulate_data(entity, row, short_code, type):
    id = row['id']
    geocode = row['doc']['geometry'].get('coordinates')
    geocode_string = ", ".join([str(i) for i in geocode
                                ]) if geocode is not None else "--"
    location = _format(sequence_to_str(entity.location_path))
    name = _format(entity.value(NAME_FIELD))
    mobile_number = _format(entity.value(MOBILE_NUMBER_FIELD))
    description = _format(entity.value(DESCRIPTION_FIELD))
    return dict(id=id,
                name=name,
                short_name=short_code,
                type=type,
                geocode=geocode_string,
                location=location,
                description=description,
                mobile_number=mobile_number)
Example #5
0
 def convert_to_unicode(self):
     if self.value is None:
         return unicode("")
     return sequence_to_str(self.value) if isinstance(
         self.value, list) else unicode(self.value)
Example #6
0
def _stringify(item):
    if is_sequence(item):
        return sequence_to_str(item)
    return unicode(item)
Example #7
0
def _stringify(item):
    if is_sequence(item):
        return sequence_to_str(item)
    return unicode(item)
Example #8
0
 def _to_string(self, errors):
     if is_string(errors):
         return errors
     if isinstance(errors, dict):
         return sequence_to_str(errors.values())
     return sequence_to_str(errors)