Projet

Général

Profil

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

Benjamin Dauvergne, 02 novembre 2022 14:22

Télécharger (4,03 ko)

Voir les différences:

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

 src/authentic2/api_views.py                    |  2 +-
 src/authentic2/csv_import.py                   |  3 +++
 .../migrations/0033_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/0033_user_keepalive.py
src/authentic2/api_views.py
543 543
                'required': False,
544 544
            }
545 545
        }
546
        exclude = ('user_permissions', 'groups')
546
        exclude = ('user_permissions', 'groups', 'keepalive')
547 547

  
548 548

  
549 549
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/0033_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', '0032_auto_20220919_1230'),
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
235 235
    verified_attributes = AttributesDescriptor(verified=True)
236 236
    is_verified = IsVerifiedDescriptor()
237 237

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

  
238 240
    attribute_values = GenericRelation('authentic2.AttributeValue')
239 241

  
240 242
    USERNAME_FIELD = 'username'
src/authentic2/manager/forms.py
180 180

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

  
185 193

  
186 194
class UserChangePasswordForm(CssClass, forms.ModelForm):
tests/test_all.py
90 90
                    'ou': None,
91 91
                    'deactivation': None,
92 92
                    'deactivation_reason': None,
93
                    'keepalive': None,
93 94
                },
94 95
            },
95 96
            {
96
-