Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
flake8 adaptations.
Browse files Browse the repository at this point in the history
  • Loading branch information
kunerj committed Oct 14, 2023
1 parent bc2ec80 commit 7d70cd2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
27 changes: 14 additions & 13 deletions amivapi/events/emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 10 additions & 4 deletions amivapi/tests/events/test_emails.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
9 changes: 6 additions & 3 deletions amivapi/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7d70cd2

Please sign in to comment.