Fixes #764: Encapsulate in double quotes values containing commas when exporting to CSV

This commit is contained in:
Jeremy Stretch
2017-01-04 10:47:00 -05:00
parent 8154ae3685
commit 52567c4ade
5 changed files with 80 additions and 61 deletions

View File

@@ -4,6 +4,7 @@ from django.db import models
from extras.models import CustomFieldModel, CustomFieldValue
from utilities.models import CreatedUpdatedModel
from utilities.utils import csv_format
class TenantGroup(models.Model):
@@ -45,9 +46,9 @@ class Tenant(CreatedUpdatedModel, CustomFieldModel):
return reverse('tenancy:tenant', args=[self.slug])
def to_csv(self):
return ','.join([
return csv_format([
self.name,
self.slug,
self.group.name if self.group else '',
self.group.name if self.group else None,
self.description,
])