Skip to content

Commit

Permalink
feat(accounts,ToU): add updated and created to Consent Model
Browse files Browse the repository at this point in the history
Signed-off-by: David Wallace <[email protected]>
  • Loading branch information
MyPyDavid committed Jan 23, 2025
1 parent 8c2a84b commit 3c2a3bc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion rdmo/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class AdditionalFieldValueAdmin(admin.ModelAdmin):

@admin.register(ConsentFieldValue)
class ConsentFieldValueAdmin(admin.ModelAdmin):
readonly_fields = ('user', 'consent')
readonly_fields = ('user', 'consent', 'updated', 'created')

def has_add_permission(self, request, obj=None):
return False
Expand Down
26 changes: 26 additions & 0 deletions rdmo/accounts/migrations/0022_add_created_updated_to_consent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 4.2.17 on 2025-01-23 16:06

from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

dependencies = [
('accounts', '0021_alter_help_text'),
]

operations = [
migrations.AddField(
model_name='consentfieldvalue',
name='created',
field=models.DateTimeField(default=django.utils.timezone.now, editable=False, verbose_name='created'),
preserve_default=False,
),
migrations.AddField(
model_name='consentfieldvalue',
name='updated',
field=models.DateTimeField(default=django.utils.timezone.now, editable=False, verbose_name='updated'),
preserve_default=False,
),
]
3 changes: 2 additions & 1 deletion rdmo/accounts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.dispatch import receiver
from django.utils.translation import gettext_lazy as _

from rdmo.core.models import Model as RDMOTimeStampedModel
from rdmo.core.models import TranslationMixin


Expand Down Expand Up @@ -106,7 +107,7 @@ def __str__(self):
return self.user.username + '/' + self.field.key


class ConsentFieldValue(models.Model):
class ConsentFieldValue(RDMOTimeStampedModel):

user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
consent = models.BooleanField(
Expand Down

0 comments on commit 3c2a3bc

Please sign in to comment.