brestok commited on
Commit
ea81bc0
·
1 Parent(s): 6975bfa
cbh/api/calls/utils.py CHANGED
@@ -35,7 +35,7 @@ async def send_customer_booking_email(call: CallModel) -> None:
35
  """
36
  Send a booking email.
37
  """
38
- if not call.event.isRecurring:
39
  return
40
  templates_path = settings.BASE_DIR / "cbh" / "templates" / "emails"
41
  env = Environment(
@@ -63,7 +63,7 @@ async def send_coach_booking_email(call: CallModel) -> None:
63
  """
64
  Send a booking email.
65
  """
66
- if not call.event.isRecurring:
67
  return
68
  templates_path = settings.BASE_DIR / "cbh" / "templates" / "emails"
69
  env = Environment(
 
35
  """
36
  Send a booking email.
37
  """
38
+ if not call.event.isActive:
39
  return
40
  templates_path = settings.BASE_DIR / "cbh" / "templates" / "emails"
41
  env = Environment(
 
63
  """
64
  Send a booking email.
65
  """
66
+ if not call.event.isActive:
67
  return
68
  templates_path = settings.BASE_DIR / "cbh" / "templates" / "emails"
69
  env = Environment(
cbh/api/calls/views.py CHANGED
@@ -113,8 +113,8 @@ async def cancel_call(
113
  await refund_stripe_payment(call.paymentIntentId)
114
 
115
  call = await cancel_call_obj(call)
116
- # asyncio.create_task(send_cancel_customer_email(call))
117
- # asyncio.create_task(send_cancel_coach_email(call))
118
  return CbhResponseWrapper(data=call)
119
 
120
 
@@ -166,13 +166,13 @@ async def stripe_callback(request: Request) -> CbhResponseWrapper:
166
  call = await manage_stripe_event(event)
167
 
168
  if call.customer.status == AccountStatus.PENDING:
169
- asyncio.create_task(send_anonymous_booking_email(call))
170
  else:
171
- asyncio.create_task(send_customer_booking_email(call))
172
 
173
- asyncio.create_task(send_coach_booking_email(call))
174
- asyncio.create_task(send_session_reminder_email(call))
175
- asyncio.create_task(send_session_reminder_coach_email(call))
176
  return CbhResponseWrapper(data=None)
177
 
178
 
 
113
  await refund_stripe_payment(call.paymentIntentId)
114
 
115
  call = await cancel_call_obj(call)
116
+ asyncio.create_task(send_cancel_customer_email(call))
117
+ asyncio.create_task(send_cancel_coach_email(call))
118
  return CbhResponseWrapper(data=call)
119
 
120
 
 
166
  call = await manage_stripe_event(event)
167
 
168
  if call.customer.status == AccountStatus.PENDING:
169
+ await send_anonymous_booking_email(call)
170
  else:
171
+ await send_customer_booking_email(call)
172
 
173
+ await send_coach_booking_email(call)
174
+ await send_session_reminder_email(call)
175
+ await send_session_reminder_coach_email(call)
176
  return CbhResponseWrapper(data=None)
177
 
178
 
cbh/core/email_client.py CHANGED
@@ -42,7 +42,7 @@ class EmailClient:
42
  message.attach(text_part)
43
  message.attach(html_part)
44
 
45
- await aiosmtplib.send(
46
  message,
47
  hostname=self.smtp_server,
48
  port=self.port,
@@ -51,3 +51,4 @@ class EmailClient:
51
  password=self.password,
52
  timeout=30,
53
  )
 
 
42
  message.attach(text_part)
43
  message.attach(html_part)
44
 
45
+ r = await aiosmtplib.send(
46
  message,
47
  hostname=self.smtp_server,
48
  port=self.port,
 
51
  password=self.password,
52
  timeout=30,
53
  )
54
+ print(r)