Skip to content
Snippets Groups Projects
Commit 0c7fafa8 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

export to csv fixed (new line doesn't break csv)

parent 451acd03
No related branches found
No related tags found
1 merge request!5Appointments dev
......@@ -587,7 +587,7 @@ class Appointment(models.Model):
def title(self):
if self.visit.subject.screening_number=="---":
return self.comment.replace("\n", ";")
return self.comment.replace("\n", ";").replace("\r", ";")
else:
title = self.visit.subject.first_name + " " + self.visit.subject.last_name + " type: "
for type in self.appointment_types.all():
......
......@@ -663,7 +663,7 @@ def write_subjects_to_csv(writer):
row = []
for field in subject_fields:
row.append(getattr(subject,field.name))
writer.writerow([unicode(s).encode("utf-8") for s in row])
writer.writerow([unicode(s).replace("\n", ";").replace("\r", ";").encode("utf-8") for s in row])
def write_appointments_to_csv(writer):
appointments_fields = []
......@@ -695,7 +695,7 @@ def write_appointments_to_csv(writer):
for type in appointment.appointment_types.all():
type_string+=type.code+","
row.append(type_string)
writer.writerow([unicode(s).encode("utf-8") for s in row])
writer.writerow([unicode(s).replace("\n", ";").replace("\r", ";").encode("utf-8") for s in row])
def export(request):
return wrap_response(request, 'export/index.html',{})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment