From 292a48aaea12f18e71f00e7dfae0d313eb168cfb Mon Sep 17 00:00:00 2001 From: Lova Andriarimalala <43842786+Xpirix@users.noreply.github.com> Date: Mon, 18 Nov 2024 13:10:10 +0300 Subject: [PATCH] Use UTC timezone for now --- qgis-app/api/migrations/0001_initial.py | 5 +++-- qgis-app/api/models.py | 8 ++++++-- qgis-app/api/permissions.py | 2 +- qgis-app/api/templates/user_token_list.html | 4 ++-- qgis-app/settings_docker.py | 4 ++++ 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/qgis-app/api/migrations/0001_initial.py b/qgis-app/api/migrations/0001_initial.py index 950f36b..e25acfc 100644 --- a/qgis-app/api/migrations/0001_initial.py +++ b/qgis-app/api/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 4.2.16 on 2024-09-12 07:16 +# Generated by Django 4.2.16 on 2024-11-18 03:02 from django.conf import settings from django.db import migrations, models @@ -22,7 +22,8 @@ class Migration(migrations.Migration): ('is_blacklisted', models.BooleanField(default=False)), ('is_newly_created', models.BooleanField(default=False)), ('description', models.CharField(blank=True, help_text="Describe this token so that it's easier to remember where you're using it.", max_length=512, null=True, verbose_name='Description')), - ('last_used_on', models.DateTimeField(blank=True, null=True, verbose_name='Last used on')), + ('created_at', models.DateTimeField(auto_now_add=True, verbose_name='Created at')), + ('last_used_at', models.DateTimeField(blank=True, null=True, verbose_name='Last used at')), ('token', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='token_blacklist.outstandingtoken')), ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), ], diff --git a/qgis-app/api/models.py b/qgis-app/api/models.py index 6db86a9..3129e17 100644 --- a/qgis-app/api/models.py +++ b/qgis-app/api/models.py @@ -25,8 +25,12 @@ class UserOutstandingToken(models.Model): blank=True, null=True, ) - last_used_on = models.DateTimeField( - verbose_name=_("Last used on"), + created_at = models.DateTimeField( + verbose_name=_("Created at"), + auto_now_add=True, + ) + last_used_at = models.DateTimeField( + verbose_name=_("Last used at"), blank=True, null=True ) \ No newline at end of file diff --git a/qgis-app/api/permissions.py b/qgis-app/api/permissions.py index 491634c..bfaa8f0 100644 --- a/qgis-app/api/permissions.py +++ b/qgis-app/api/permissions.py @@ -50,7 +50,7 @@ def has_permission(self, request, view): if not user: return False user_token = UserOutstandingToken.objects.get(token__pk=token_id, user=user) - user_token.last_used_on = datetime.datetime.now() + user_token.last_used_at = datetime.datetime.now() user_token.save() request.user_token = user_token return True diff --git a/qgis-app/api/templates/user_token_list.html b/qgis-app/api/templates/user_token_list.html index d94cd0f..f04112f 100644 --- a/qgis-app/api/templates/user_token_list.html +++ b/qgis-app/api/templates/user_token_list.html @@ -21,8 +21,8 @@

{% trans "My Tokens" %}

{% for user_token in object_list %} {{ user_token.description|default:"-" }} - {{ user_token.token.created_at }} UTC - {{ user_token.last_used_on|default:"-" }}{% if user_token.last_used_on %} UTC{% endif %} + {{ user_token.created_at }} UTC + {{ user_token.last_used_at|default:"-" }}{% if user_token.last_used_at %} UTC{% endif %}   diff --git a/qgis-app/settings_docker.py b/qgis-app/settings_docker.py index aa29517..c4a4846 100644 --- a/qgis-app/settings_docker.py +++ b/qgis-app/settings_docker.py @@ -249,3 +249,7 @@ 'order': 4, } ] + +# Set the default timezone +USE_TZ = False +TIME_ZONE = 'UTC' \ No newline at end of file