Skip to content

Commit

Permalink
8908 fixed comparing time issue (#1187)
Browse files Browse the repository at this point in the history
  • Loading branch information
vysakh-menon-aot authored Sep 27, 2021
1 parent 9caa8ce commit 8d5c9ed
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion api/namex/resources/payment/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,8 +377,14 @@ def post(self, nr_id, payment_action=NameRequestActions.CREATE.value):

elif payment_action == PaymentDAO.PaymentActions.REAPPLY.value:
# TODO: handle this (refund payment and prevent action?)

# the `nr_model.expirationDate` is been set from nro with timezone info
# and `datetime.utcnow()` does not return with timezone info `+00:00`
# replacing timezone info to None in `nr_model.expirationDate` to avoid
# this error: `can't compare offset-naive and offset-aware datetimes`
if nr_model.stateCd != State.APPROVED \
and nr_model.expirationDate + timedelta(hours=NAME_REQUEST_EXTENSION_PAD_HOURS) < datetime.utcnow():
and nr_model.expirationDate.replace(tzinfo=None) + \
timedelta(hours=NAME_REQUEST_EXTENSION_PAD_HOURS) < datetime.utcnow():
msg = f'Extend NR for payment.id={payment.id} nr_model.state{nr_model.stateCd}, nr_model.expires:{nr_model.expirationDate}'
current_app.logger.debug(msg)

Expand Down

0 comments on commit 8d5c9ed

Please sign in to comment.