Skip to content

Commit

Permalink
fix: make audir log timestamps timezone-aware when needed (#889)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulschreiber authored Oct 12, 2023
1 parent 8b799ff commit b619a7d
Showing 1 changed file with 7 additions and 1 deletion.
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

0 comments on commit b619a7d

Please sign in to comment.