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: make audit log timestamps timezone-aware when needed #889

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion terraso_backend/apps/audit_logs/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from datetime import datetime
from enum import Enum

from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.core.paginator import Paginator
from django.db import transaction
Expand Down Expand Up @@ -79,7 +80,12 @@ def log(

if client_time is None:
client_time = datetime.now()
log.client_timestamp = client_time
if settings.USE_TZ:
from django.utils.timezone import make_aware

log.client_timestamp = make_aware(client_time)
else:
log.client_timestamp = client_time

log.metadata = metadata
log.save()
Expand Down
Loading