diff --git a/events/tests/test_views.py b/events/tests/test_views.py index d9a978e1..ee17128b 100644 --- a/events/tests/test_views.py +++ b/events/tests/test_views.py @@ -129,7 +129,13 @@ class CSVExportContentTest(MessagePatch, TestCase): participants = self.client.get(self.url).content.decode("utf-8") participants = list(csv.reader(participants.split("\n"))) + toto_registration = participants[1] + + # This is not super nice, but it makes the test deterministic. + if toto_registration[5] == "f & d": + toto_registration[5] = "d & f" + self.assertEqual( ["toto_foo", "toto@a.b", "toto", "foo", "a", "d & f", "hello"], - participants[1], + toto_registration, ) diff --git a/events/views.py b/events/views.py index 71000ed2..248c4284 100644 --- a/events/views.py +++ b/events/views.py @@ -36,14 +36,11 @@ def participants_csv(request, event_id): row = [user.username, user.email, user.first_name, user.last_name] # Options - options_choices = list( - " & ".join( - registration.options_choices.filter(option__id=id).values_list( - "choice", flat=True - ) - ) + all_choices = registration.options_choices.values_list("choice", flat=True) + options_choices = [ + " & ".join(all_choices.filter(option__id=id)) for id in event.options.values_list("id", flat=True).order_by("id") - ) + ] row += options_choices # Extra info extra_info = list(