From 915d5e893177ff644b097788350936db13761aaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20Kervella?= Date: Sun, 15 Apr 2018 10:51:05 +0000 Subject: [PATCH] Fix: user.models.User.auto_uid can't be static --- users/migrations/0035_auto_20161018_0046.py | 2 +- users/migrations/0056_auto_20171015_2033.py | 2 +- users/models.py | 11 ++++------- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/users/migrations/0035_auto_20161018_0046.py b/users/migrations/0035_auto_20161018_0046.py index 90387af6..aea0d13d 100644 --- a/users/migrations/0035_auto_20161018_0046.py +++ b/users/migrations/0035_auto_20161018_0046.py @@ -37,6 +37,6 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='user', name='uid_number', - field=models.IntegerField(unique=True, default=users.models.User.auto_uid), + field=models.IntegerField(unique=True, default=users.models.get_fresh_user_uid), ), ] diff --git a/users/migrations/0056_auto_20171015_2033.py b/users/migrations/0056_auto_20171015_2033.py index a47aca6a..90423340 100644 --- a/users/migrations/0056_auto_20171015_2033.py +++ b/users/migrations/0056_auto_20171015_2033.py @@ -32,6 +32,6 @@ class Migration(migrations.Migration): migrations.AlterField( model_name='user', name='uid_number', - field=models.PositiveIntegerField(default=users.models.User.auto_uid, unique=True), + field=models.PositiveIntegerField(default=users.models.get_fresh_user_uid, unique=True), ), ] diff --git a/users/models.py b/users/models.py index 55ae0e8d..f7bfc128 100644 --- a/users/models.py +++ b/users/models.py @@ -187,12 +187,6 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser, (2, 'STATE_ARCHIVE'), ) - # TODO : Use only one of auto_uid and get_fresh_user_uid - @staticmethod - def auto_uid(): - """Renvoie un uid libre""" - return get_fresh_user_uid() - surname = models.CharField(max_length=255) pseudo = models.CharField( max_length=32, @@ -222,7 +216,10 @@ class User(RevMixin, FieldPermissionModelMixin, AbstractBaseUser, state = models.IntegerField(choices=STATES, default=STATE_ACTIVE) registered = models.DateTimeField(auto_now_add=True) telephone = models.CharField(max_length=15, blank=True, null=True) - uid_number = models.PositiveIntegerField(default=auto_uid, unique=True) + uid_number = models.PositiveIntegerField( + default=get_fresh_user_uid, + unique=True + ) rezo_rez_uid = models.PositiveIntegerField( unique=True, blank=True,