Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use django utils timezone to make timezone aware #154

Merged

Conversation

varshamenon4
Copy link
Member

This PR fixes a bug which caused an error in audit_trial_is_expired which was happening due to an incompatible comparison in timezone naive and aware datetimes.

Instead of using datetime.now(), we now use timezone.now() from Django utils which makes timezone aware / naive based on the USE_TZ setting. This changes both the instance of this in audit_trial_is_expired and also in the LearningAssistantAuditTrialData's start_date and expiration_date.

This ensures consistency in the comparisons.

Copy link

github-actions bot commented Jan 8, 2025

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  learning_assistant
  __init__.py
  api.py
Project Total  

This report was generated by python-coverage-comment-action

Copy link
Member

@MichaelRoytman MichaelRoytman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! I appreciate your persistence in fixing the timezone issue 💪. Just a quick reminder to also update the CHANGELOG and __init__.py!

tests/test_api.py Show resolved Hide resolved
@varshamenon4 varshamenon4 force-pushed the varshamenon4/fix-use-timezone-now-aware-datetime branch from 6bf5de9 to 0ecc81e Compare January 9, 2025 15:37
@varshamenon4 varshamenon4 merged commit 836e2e9 into main Jan 9, 2025
4 checks passed
@varshamenon4 varshamenon4 deleted the varshamenon4/fix-use-timezone-now-aware-datetime branch January 9, 2025 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants