Projet

Général

Profil

0001-models-add-User.keepalive-field-67901.patch

Benjamin Dauvergne, 10 octobre 2022 13:43

Télécharger (4,04 ko)

Voir les différences:

Subject: [PATCH 1/6] models: add User.keepalive field (#67901)

 src/authentic2/api_views.py                    |  2 +-
 src/authentic2/csv_import.py                   |  3 +++
 .../migrations/0032_user_keepalive.py          | 18 ++++++++++++++++++
 src/authentic2/custom_user/models.py           |  2 ++
 src/authentic2/manager/forms.py                | 10 +++++++++-
 tests/test_all.py                              |  1 +
 6 files changed, 34 insertions(+), 2 deletions(-)
 create mode 100644 src/authentic2/custom_user/migrations/0032_user_keepalive.py
src/authentic2/api_views.py
542 542
                'required': False,
543 543
            }
544 544
        }
545
        exclude = ('user_permissions', 'groups')
545
        exclude = ('user_permissions', 'groups', 'keepalive')
546 546

  
547 547

  
548 548
class DuplicateUserSerializer(BaseUserSerializer):
src/authentic2/csv_import.py
273 273
            raise ValidationError(_('Invalid password format or unknown hashing algorithm.'))
274 274
        return password_hash
275 275

  
276
    class Meta:
277
        exclude = ('keepalive',)
278

  
276 279

  
277 280
class ImportUserFormWithExternalId(ImportUserForm):
278 281
    locals()[SOURCE_NAME] = forms.CharField(
src/authentic2/custom_user/migrations/0032_user_keepalive.py
1
# Generated by Django 2.2.26 on 2022-10-06 19:58
2

  
3
from django.db import migrations, models
4

  
5

  
6
class Migration(migrations.Migration):
7

  
8
    dependencies = [
9
        ('custom_user', '0031_profile_email'),
10
    ]
11

  
12
    operations = [
13
        migrations.AddField(
14
            model_name='user',
15
            name='keepalive',
16
            field=models.DateTimeField(blank=True, null=True, verbose_name='Keepalive timestamp'),
17
        ),
18
    ]
src/authentic2/custom_user/models.py
192 192
    verified_attributes = AttributesDescriptor(verified=True)
193 193
    is_verified = IsVerifiedDescriptor()
194 194

  
195
    keepalive = models.DateTimeField(verbose_name=_('Keepalive timestamp'), null=True, blank=True)
196

  
195 197
    attribute_values = GenericRelation('authentic2.AttributeValue')
196 198

  
197 199
    USERNAME_FIELD = 'username'
src/authentic2/manager/forms.py
181 181

  
182 182
    class Meta:
183 183
        model = User
184
        exclude = ('is_staff', 'groups', 'user_permissions', 'last_login', 'date_joined', 'password')
184
        exclude = (
185
            'is_staff',
186
            'groups',
187
            'user_permissions',
188
            'last_login',
189
            'date_joined',
190
            'password',
191
            'keepalive',
192
        )
185 193

  
186 194

  
187 195
class UserChangePasswordForm(CssClass, forms.ModelForm):
tests/test_all.py
88 88
                    'ou': None,
89 89
                    'deactivation': None,
90 90
                    'deactivation_reason': None,
91
                    'keepalive': None,
91 92
                },
92 93
            },
93 94
            {
94
-