diff --git a/src/django_otp/models.py b/src/django_otp/models.py index b9a51d58..08fcbbaf 100644 --- a/src/django_otp/models.py +++ b/src/django_otp/models.py @@ -69,6 +69,12 @@ class Device(models.Model): a device and then ask the user for confirmation. As a rule, built-in APIs that enumerate devices will only include those that are confirmed. + .. attribute:: created_at + + *DateTimeField*: The date and time when the device was added. This field + automatically records the current date and time when a new device instance + is created, aiding in audit and lifecycle management. + .. attribute:: objects A :class:`~django_otp.models.DeviceManager`. @@ -88,6 +94,12 @@ class Device(models.Model): default=True, help_text="Is this device ready for use?" ) + created_at = models.DateTimeField( + auto_now_add=True, + help_text="The date and time when this device was added.", + null=True + ) + objects = DeviceManager() class Meta: diff --git a/src/django_otp/plugins/otp_email/migrations/0006_emaildevice_added_date.py b/src/django_otp/plugins/otp_email/migrations/0006_emaildevice_added_date.py new file mode 100644 index 00000000..3e82de14 --- /dev/null +++ b/src/django_otp/plugins/otp_email/migrations/0006_emaildevice_added_date.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2024-04-04 09:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('otp_email', '0005_emaildevice_last_generated_timestamp'), + ] + + operations = [ + migrations.AddField( + model_name='emaildevice', + name='created_at', + field=models.DateTimeField(auto_now_add=True, help_text='The date and time when this device was added.', null=True), + ), + ] diff --git a/src/django_otp/plugins/otp_static/migrations/0003_staticdevice_added_date.py b/src/django_otp/plugins/otp_static/migrations/0003_staticdevice_added_date.py new file mode 100644 index 00000000..ea26e85c --- /dev/null +++ b/src/django_otp/plugins/otp_static/migrations/0003_staticdevice_added_date.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2024-04-04 09:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('otp_static', '0002_throttling'), + ] + + operations = [ + migrations.AddField( + model_name='staticdevice', + name='created_at', + field=models.DateTimeField(auto_now_add=True, help_text='The date and time when this device was added.', null=True), + ), + ] diff --git a/src/django_otp/plugins/otp_totp/migrations/0003_totpdevice_added_date.py b/src/django_otp/plugins/otp_totp/migrations/0003_totpdevice_added_date.py new file mode 100644 index 00000000..985a9069 --- /dev/null +++ b/src/django_otp/plugins/otp_totp/migrations/0003_totpdevice_added_date.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.7 on 2024-04-04 09:28 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('otp_totp', '0002_auto_20190420_0723'), + ] + + operations = [ + migrations.AddField( + model_name='totpdevice', + name='created_at', + field=models.DateTimeField(auto_now_add=True, help_text='The date and time when this device was added.', null=True), + ), + ]