Skip to content

Commit

Permalink
Fix token dates field name
Browse files Browse the repository at this point in the history
  • Loading branch information
Xpirix committed Nov 21, 2024
1 parent cac8796 commit a1ab11e
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 8 deletions.
7 changes: 4 additions & 3 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,9 +22,10 @@ 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)),
],
),
]
]
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 @@ -22,9 +22,9 @@ <h2>{% trans "My Tokens" %}</h2>
{% for user_token in object_list %}
<tr class="{% cycle "even" "odd" %}">
<td>{{ user_token.description|default:"-" }}</td>
<td>{{ user_token.token.created_at|local_timezone }}</td>
<td>{{ user_token.created_at|local_timezone }}</td>
{% comment %} <td>{{ user_token.token.expires_at|local_timezone }}</td> {% endcomment %}
<td>{{ user_token.last_used_on|default:"-"|local_timezone }}</td>
<td>{{ user_token.last_used_at|default:"-"|local_timezone }}</td>
<td>
<a class="btn btn-primary btn-mini" href="{% url "user_token_update" user_token.pk %}"
title="{% trans "Edit description" %}"><i class="icon-pencil icon-white"></i></a>&nbsp;
Expand Down

0 comments on commit a1ab11e

Please sign in to comment.