django.utils.timezone.utc alias is removed

This commit is contained in:
Joel Falknau
2025-03-04 11:59:37 +10:00
parent cc8f53af12
commit 826198e5a7
3 changed files with 16 additions and 17 deletions

View File

@@ -1,13 +1,12 @@
import datetime
import logging
import os
from datetime import datetime, timedelta, timezone
from django.contrib import messages
from django.contrib.auth.decorators import login_required, permission_required
from django.contrib.auth.models import User
from django.core.exceptions import ObjectDoesNotExist, ValidationError
from django.shortcuts import get_object_or_404, redirect, render
from django.utils import timezone
from django.utils.crypto import get_random_string
from django.utils.translation import gettext_lazy as _
@@ -135,7 +134,7 @@ def fatlink_statistics_corp_view(request, corpid, year=None, month=None):
stat_list.sort(key=lambda stat: (stat.n_fats, stat.avg_fat), reverse=True)
context = {'fatStats': stat_list, 'month': start_of_month.strftime("%B"), 'year': year, 'previous_month': start_of_previous_month, 'corpid': corpid}
if datetime.datetime.now() > start_of_next_month:
if datetime.datetime.now(timezone.utc) > start_of_next_month:
context.update({'next_month': start_of_next_month})
return render(request, 'fleetactivitytracking/fatlinkstatisticscorpview.html', context=context)
@@ -174,7 +173,7 @@ def fatlink_statistics_view(request, year=None, month=None):
stat_list.sort(key=lambda stat: (stat.n_fats, stat.avg_fat), reverse=True)
context = {'fatStats': stat_list, 'month': start_of_month.strftime("%B"), 'year': year, 'previous_month': start_of_previous_month}
if datetime.datetime.now() > start_of_next_month:
if datetime.datetime.now(timezone.utc) > start_of_next_month:
context.update({'next_month': start_of_next_month})
return render(request, 'fleetactivitytracking/fatlinkstatisticsview.html', context=context)
@@ -202,7 +201,7 @@ def fatlink_personal_statistics_view(request, year=None):
monthlystats = [(i + 1, datetime.date(year, i + 1, 1).strftime("%h"), monthlystats[i]) for i in range(12)]
if datetime.datetime.now() > datetime.datetime(year + 1, 1, 1):
if datetime.datetime.now(timezone.utc) > datetime.datetime(year + 1, 1, 1):
context = {'user': user, 'monthlystats': monthlystats, 'year': year, 'previous_year': year - 1, 'next_year': year + 1}
else:
context = {'user': user, 'monthlystats': monthlystats, 'year': year, 'previous_year': year - 1}
@@ -272,7 +271,7 @@ def click_fatlink_view(request, token, fat_hash=None):
if character_online["online"] is True:
fatlink = get_object_or_404(Fatlink, hash=fat_hash)
if (timezone.now() - fatlink.fatdatetime) < datetime.timedelta(seconds=(fatlink.duration * 60)):
if (datetime.now(timezone.utc) - fatlink.fatdatetime) < timedelta(seconds=(fatlink.duration * 60)):
if character:
# get data
location = c.Location.get_characters_character_id_location(character_id=token.character_id).result()