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

Commit

Permalink
fix(subscriptions/notify_admin): use dateutils parser to prevent an e…
Browse files Browse the repository at this point in the history
…rror

Using strptime throws an error if the passed date is over 23 hours.
So instead we use dateutils.parser. We also pass the day value to the mail template.
  • Loading branch information
velrest committed Dec 16, 2021
1 parent 9e32bdc commit c3a8c6c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions timed/subscription/notify_admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import datetime

from dateutil import parser
from django.conf import settings
from django.core.mail import EmailMultiAlternatives, get_connection
from django.template.loader import get_template, render_to_string
Expand All @@ -13,9 +14,12 @@ def prepare_and_send_email(project, order_duration):

customer = project.customer

duration = datetime.datetime.strptime(order_duration, "%H:%M:%S")
duration = parser.parse(order_duration)
hours_added = datetime.timedelta(
hours=duration.hour, minutes=duration.minute, seconds=duration.second
days=duration.day,
hours=duration.hour,
minutes=duration.minute,
seconds=duration.second,
)
hours_total = hours_added + project.estimated_time

Expand Down

0 comments on commit c3a8c6c

Please sign in to comment.