Skip to content

Commit

Permalink
Use UTC timezone for now
Browse files Browse the repository at this point in the history
  • Loading branch information
Xpirix committed Nov 18, 2024
1 parent f3f0304 commit 292a48a
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
5 changes: 3 additions & 2 deletions qgis-app/api/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)),
],
Expand Down
8 changes: 6 additions & 2 deletions qgis-app/api/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
2 changes: 1 addition & 1 deletion qgis-app/api/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions qgis-app/api/templates/user_token_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ <h2 class="title is-4">{% trans "My Tokens" %}</h2>
{% for user_token in object_list %}
<tr>
<td class="has-text-centered">{{ user_token.description|default:"-" }}</td>
<td class="has-text-centered">{{ user_token.token.created_at }} UTC</td>
<td class="has-text-centered">{{ user_token.last_used_on|default:"-" }}{% if user_token.last_used_on %} UTC{% endif %}</td>
<td class="has-text-centered">{{ user_token.created_at }} UTC</td>
<td class="has-text-centered">{{ user_token.last_used_at|default:"-" }}{% if user_token.last_used_at %} UTC{% endif %}</td>
<td class="has-text-centered">
<a class="button is-success is-outlined is-small" href="{% url "user_token_update" user_token.pk %}"
title="{% trans "Edit description" %}"><span class="icon"><i class="fas fa-pencil-alt"></i></span></a>&nbsp;
Expand Down
4 changes: 4 additions & 0 deletions qgis-app/settings_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,7 @@
'order': 4,
}
]

# Set the default timezone
USE_TZ = False
TIME_ZONE = 'UTC'

0 comments on commit 292a48a

Please sign in to comment.