diff --git a/common/djangoapps/third_party_auth/migrations/0008_auto_20220324_1422.py b/common/djangoapps/third_party_auth/migrations/0008_auto_20220324_1422.py new file mode 100644 index 0000000000..653a9287db --- /dev/null +++ b/common/djangoapps/third_party_auth/migrations/0008_auto_20220324_1422.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.12 on 2022-03-24 14:22 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('third_party_auth', '0007_samlproviderconfig_was_valid_at'), + ] + + operations = [ + migrations.AddField( + model_name='ltiproviderconfig', + name='was_valid_at', + field=models.DateTimeField(blank=True, help_text='Timestamped field that indicates a user has successfully logged in using this configuration at least once.', null=True), + ), + migrations.AddField( + model_name='oauth2providerconfig', + name='was_valid_at', + field=models.DateTimeField(blank=True, help_text='Timestamped field that indicates a user has successfully logged in using this configuration at least once.', null=True), + ), + ] diff --git a/common/djangoapps/third_party_auth/models.py b/common/djangoapps/third_party_auth/models.py index 9686a756e2..f0a37616a3 100644 --- a/common/djangoapps/third_party_auth/models.py +++ b/common/djangoapps/third_party_auth/models.py @@ -223,6 +223,14 @@ class ProviderConfig(ConfigurationModel): ) ) + was_valid_at = models.DateTimeField( + blank=True, + null=True, + help_text=( + "Timestamped field that indicates a user has successfully logged in using this configuration at least once." + ) + ) + prefix = None # used for provider_id. Set to a string value in subclass backend_name = None # Set to a field or fixed value in subclass accepts_logins = True # Whether to display a sign-in button when the provider is enabled @@ -700,14 +708,6 @@ class SAMLProviderConfig(ProviderConfig): blank=True, ) - was_valid_at = models.DateTimeField( - blank=True, - null=True, - help_text=( - "Timestamped field that indicates a user has successfully logged in using this configuration at least once." - ) - ) - def clean(self): """ Standardize and validate fields """ super().clean() diff --git a/common/djangoapps/third_party_auth/tests/test_admin.py b/common/djangoapps/third_party_auth/tests/test_admin.py index 82a93e8db8..c5481a3a09 100644 --- a/common/djangoapps/third_party_auth/tests/test_admin.py +++ b/common/djangoapps/third_party_auth/tests/test_admin.py @@ -64,10 +64,11 @@ class Oauth2ProviderConfigAdminTest(testutil.TestCase): # Remove the icon_image from the POST data, to simulate unchanged icon_image post_data = models.model_to_dict(provider1) del post_data['icon_image'] - # Remove max_session_length and organization. A default null value must be POSTed + # Remove max_session_length, was_valid_at and organization. A default null value must be POSTed # back as an absent value, rather than as a "null-like" included value. del post_data['max_session_length'] del post_data['organization'] + del post_data['was_valid_at'] # Change the name, to verify POST post_data['name'] = 'Another name'