chore: created by key changed (#4389)

This commit is contained in:
Bavisetti Narayan 2024-05-07 19:22:00 +05:30 committed by GitHub
parent a40517015b
commit d946c51ef1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 3 deletions

View File

@ -447,7 +447,7 @@ class IssueViewSet(BaseViewSet):
) )
datetime_fields = ["created_at", "updated_at"] datetime_fields = ["created_at", "updated_at"]
issues = user_timezone_converter( issues = user_timezone_converter(
issue_queryset, datetime_fields, request.user.user_timezone issues, datetime_fields, request.user.user_timezone
) )
return Response(issues, status=status.HTTP_200_OK) return Response(issues, status=status.HTTP_200_OK)

View File

@ -8,14 +8,14 @@ def user_timezone_converter(queryset, datetime_fields, user_timezone):
if isinstance(queryset, dict): if isinstance(queryset, dict):
queryset_values = [queryset] queryset_values = [queryset]
else: else:
queryset_values = list(queryset.values()) queryset_values = list(queryset)
# Iterate over the dictionaries in the list # Iterate over the dictionaries in the list
for item in queryset_values: for item in queryset_values:
# Iterate over the datetime fields # Iterate over the datetime fields
for field in datetime_fields: for field in datetime_fields:
# Convert the datetime field to the user's timezone # Convert the datetime field to the user's timezone
if item[field]: if field in item and item[field]:
item[field] = item[field].astimezone(user_tz) item[field] = item[field].astimezone(user_tz)
# If queryset was a single item, return a single item # If queryset was a single item, return a single item