diff --git a/src/pretix/helpers/filenames.py b/src/pretix/helpers/filenames.py new file mode 100644 index 0000000000..637a439627 --- /dev/null +++ b/src/pretix/helpers/filenames.py @@ -0,0 +1,28 @@ +# +# This file is part of pretix (Community Edition). +# +# Copyright (C) 2014-2020 Raphael Michel and contributors +# Copyright (C) 2020-2021 rami.io GmbH and contributors +# +# This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General +# Public License as published by the Free Software Foundation in version 3 of the License. +# +# ADDITIONAL TERMS APPLY: Pursuant to Section 7 of the GNU Affero General Public License, additional terms are +# applicable granting you additional permissions and placing additional restrictions on your usage of this software. +# Please refer to the pretix LICENSE file to obtain the full terms applicable to this work. If you did not receive +# this file, see . +# +# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more +# details. +# +# You should have received a copy of the GNU Affero General Public License along with this program. If not, see +# . +# +import re + +from text_unidecode import unidecode + + +def safe_for_filename(val): + return re.sub('[^a-zA-Z0-9-_. ]+', '_', unidecode(val)) diff --git a/src/pretix/plugins/checkinlists/exporters.py b/src/pretix/plugins/checkinlists/exporters.py index df4a45dae4..03b1c9627f 100644 --- a/src/pretix/plugins/checkinlists/exporters.py +++ b/src/pretix/plugins/checkinlists/exporters.py @@ -62,6 +62,7 @@ from pretix.base.timeframes import ( resolve_timeframe_to_datetime_start_inclusive_end_exclusive, ) from pretix.control.forms.widgets import Select2 +from pretix.helpers.filenames import safe_for_filename from pretix.helpers.templatetags.jsonfield import JSONExtract from pretix.plugins.reports.exporters import ReportlabExportMixin @@ -435,7 +436,7 @@ class CSVCheckinList(CheckInListMixin, ListExporter): return self._fields def iterate_list(self, form_data): - cl = self.event.checkin_lists.get(pk=form_data['list']) + self.cl = cl = self.event.checkin_lists.get(pk=form_data['list']) questions = list(Question.objects.filter(event=self.event, id__in=form_data['questions'])) @@ -612,7 +613,7 @@ class CSVCheckinList(CheckInListMixin, ListExporter): yield row def get_filename(self): - return '{}_checkin'.format(self.event.slug) + return '{}_checkin_{}'.format(self.event.slug, safe_for_filename(self.cl.name)) class CheckinLogList(ListExporter):