diff --git a/src/authentic2/api_views.py b/src/authentic2/api_views.py index 3606238f9..d195beaf4 100644 --- a/src/authentic2/api_views.py +++ b/src/authentic2/api_views.py @@ -543,7 +543,7 @@ class BaseUserSerializer(serializers.ModelSerializer): 'required': False, } } - exclude = ('user_permissions', 'groups') + exclude = ('user_permissions', 'groups', 'keepalive') class DuplicateUserSerializer(BaseUserSerializer): diff --git a/src/authentic2/csv_import.py b/src/authentic2/csv_import.py index 39d8a6207..e3a375236 100644 --- a/src/authentic2/csv_import.py +++ b/src/authentic2/csv_import.py @@ -273,6 +273,9 @@ class ImportUserForm(BaseUserForm): raise ValidationError(_('Invalid password format or unknown hashing algorithm.')) return password_hash + class Meta: + exclude = ('keepalive',) + class ImportUserFormWithExternalId(ImportUserForm): locals()[SOURCE_NAME] = forms.CharField( diff --git a/src/authentic2/custom_user/migrations/0033_user_keepalive.py b/src/authentic2/custom_user/migrations/0033_user_keepalive.py new file mode 100644 index 000000000..45c94b736 --- /dev/null +++ b/src/authentic2/custom_user/migrations/0033_user_keepalive.py @@ -0,0 +1,18 @@ +# Generated by Django 2.2.26 on 2022-10-06 19:58 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('custom_user', '0032_auto_20220919_1230'), + ] + + operations = [ + migrations.AddField( + model_name='user', + name='keepalive', + field=models.DateTimeField(blank=True, null=True, verbose_name='Keepalive timestamp'), + ), + ] diff --git a/src/authentic2/custom_user/models.py b/src/authentic2/custom_user/models.py index f8138cc76..b15ef1b2b 100644 --- a/src/authentic2/custom_user/models.py +++ b/src/authentic2/custom_user/models.py @@ -235,6 +235,8 @@ class User(AbstractBaseUser): verified_attributes = AttributesDescriptor(verified=True) is_verified = IsVerifiedDescriptor() + keepalive = models.DateTimeField(verbose_name=_('Keepalive timestamp'), null=True, blank=True) + attribute_values = GenericRelation('authentic2.AttributeValue') USERNAME_FIELD = 'username' diff --git a/src/authentic2/manager/forms.py b/src/authentic2/manager/forms.py index 319c04dbf..beead340d 100644 --- a/src/authentic2/manager/forms.py +++ b/src/authentic2/manager/forms.py @@ -180,7 +180,15 @@ class UserEditForm(LimitQuerysetFormMixin, CssClass, BaseUserForm): class Meta: model = User - exclude = ('is_staff', 'groups', 'user_permissions', 'last_login', 'date_joined', 'password') + exclude = ( + 'is_staff', + 'groups', + 'user_permissions', + 'last_login', + 'date_joined', + 'password', + 'keepalive', + ) class UserChangePasswordForm(CssClass, forms.ModelForm): diff --git a/tests/test_all.py b/tests/test_all.py index 167b033b4..e0a2fca78 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -90,6 +90,7 @@ class SerializerTests(TestCase): 'ou': None, 'deactivation': None, 'deactivation_reason': None, + 'keepalive': None, }, }, {