From 7d70cd265594e9a93ee530d14e6f41701e609064 Mon Sep 17 00:00:00 2001 From: jkuner Date: Sat, 14 Oct 2023 23:07:54 +0200 Subject: [PATCH] flake8 adaptations. --- amivapi/events/emails.py | 27 ++++++++++++++------------- amivapi/tests/events/test_emails.py | 14 ++++++++++---- amivapi/utils.py | 9 ++++++--- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/amivapi/events/emails.py b/amivapi/events/emails.py index 969054ad..5853ec26 100644 --- a/amivapi/events/emails.py +++ b/amivapi/events/emails.py @@ -67,19 +67,20 @@ def notify_signup_accepted(event, signup, waiting_list=False): # Time is a required property for ics calendar events if time_start: - calendar_invite = get_calendar_invite('events_accepted_calendar_invite', dict( - title_en=(title_en or title_de), - event_id=event_id, - time_start=time_start, - time_end=time_end, - time_now_utc=time_now_utc, - description_en=(description_en or description_de or ''), - reply_to_email=reply_to_email, - location=location, - signup_additional_info_en=(signup_additional_info_en or - signup_additional_info_de or - ''), - )) + calendar_invite = ( + get_calendar_invite('events_accepted_calendar_invite', dict( + title_en=(title_en or title_de), + event_id=event_id, + time_start=time_start, + time_end=time_end, + time_now_utc=time_now_utc, + description_en=(description_en or description_de or ''), + reply_to_email=reply_to_email, + location=location, + signup_additional_info_en=(signup_additional_info_en or + signup_additional_info_de or + ''), + ))) else: calendar_invite = None diff --git a/amivapi/tests/events/test_emails.py b/amivapi/tests/events/test_emails.py index 6748ea81..c04188da 100644 --- a/amivapi/tests/events/test_emails.py +++ b/amivapi/tests/events/test_emails.py @@ -237,13 +237,19 @@ def test_no_nones_in_emails(self): def test_no_nones_calendar_invite(self): """Test that the calendar invite is added. - Calendar invites require a start and end time, which are non-required properties. + Calendar invites require a start and end time, + which are non-required properties. """ event = self.new_object('events', spots=100, selection_strategy='fcfs', allow_email_signup=True, - time_start=datetime.datetime.strptime('2019-01-01T00:00:00Z', '%Y-%m-%dT%H:%M:%SZ'), - time_end=datetime.datetime.strptime('2019-01-01T01:00:00Z', '%Y-%m-%dT%H:%M:%SZ'), - description_en='Description\nSpanning\nmultiple\nlines.',) + time_start=datetime.datetime.strptime( + '2019-01-01T00:00:00Z', + '%Y-%m-%dT%H:%M:%SZ'), + time_end=datetime.datetime.strptime( + '2019-01-01T01:00:00Z', + '%Y-%m-%dT%H:%M:%SZ'), + description_en=('Description\nSpanning\n' + + 'multiple\nlines.'),) user = self.new_object('users') diff --git a/amivapi/utils.py b/amivapi/utils.py index 10f30be9..9b9e25e2 100644 --- a/amivapi/utils.py +++ b/amivapi/utils.py @@ -76,7 +76,8 @@ def get_id(item): def mail_from_template( - to, subject, template_name, template_args, reply_to=None, calendar_invite=None + to, subject, template_name, template_args, reply_to=None, + calendar_invite=None ): """Send a mail to a list of recipients by using the given jinja2 template. @@ -116,7 +117,8 @@ def get_calendar_invite(template_name, template_args): for key, value in template_args.items(): if isinstance(value, str): template_args[key] = value.replace('\n', '\\n') - calendar_invite = render_template('{}.ics'.format(template_name), **template_args) + calendar_invite = render_template('{}.ics'.format(template_name), + **template_args) return calendar_invite @@ -169,7 +171,8 @@ def mail(to, subject, text, html=None, reply_to=None, calendar_invite=None): if calendar_invite is not None: calendar_mime = MIMEText(calendar_invite, 'calendar', "utf-8") calendar_mime['Content-Disposition'] = ( - 'attachment; filename="invite.ics"; charset="utf-8"; method=PUBLISH') + 'attachment; filename="invite.ics"; ' + + 'charset="utf-8"; method=PUBLISH') msg.attach(calendar_mime) msg['Subject'] = subject