1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Addded is_expired property to Token

This commit is contained in:
Jeremy Stretch
2017-03-07 23:30:31 -05:00
parent 26225aff57
commit 6be465fe9b
2 changed files with 8 additions and 2 deletions

View File

@@ -4,6 +4,7 @@ import os
from django.contrib.auth.models import User
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils import timezone
@python_2_unicode_compatible
@@ -33,3 +34,9 @@ class Token(models.Model):
def generate_key(self):
# Generate a random 160-bit key expressed in hexadecimal.
return binascii.hexlify(os.urandom(20)).decode()
@property
def is_expired(self):
if self.expires is not None and timezone.now() > self.expires:
return True
return False