Improving cancel account API endpoint

remotes/origin/github-import
Alejandro Alonso 2017-01-24 08:13:41 +01:00
parent be69b59447
commit 253e7b81d8
1 changed files with 4 additions and 2 deletions

View File

@ -41,6 +41,7 @@ from taiga.auth.tokens import get_token_for_user
from taiga.base.utils.colors import generate_random_hex_color from taiga.base.utils.colors import generate_random_hex_color
from taiga.base.utils.slug import slugify_uniquely from taiga.base.utils.slug import slugify_uniquely
from taiga.base.utils.files import get_file_path from taiga.base.utils.files import get_file_path
from taiga.base.utils.time import timestamp_ms
from taiga.permissions.choices import MEMBERS_PERMISSIONS from taiga.permissions.choices import MEMBERS_PERMISSIONS
from taiga.projects.choices import BLOCKED_BY_OWNER_LEAVING from taiga.projects.choices import BLOCKED_BY_OWNER_LEAVING
from taiga.projects.notifications.choices import NotifyLevel from taiga.projects.notifications.choices import NotifyLevel
@ -273,7 +274,8 @@ class User(AbstractBaseUser, PermissionsMixin):
def cancel(self): def cancel(self):
with advisory_lock("delete-user"): with advisory_lock("delete-user"):
self.username = slugify_uniquely("deleted-user", User, slugfield="username") deleted_user_prefix = "deleted-user-{}".format(timestamp_ms())
self.username = slugify_uniquely(deleted_user_prefix, User, slugfield="username")
self.email = "{}@taiga.io".format(self.username) self.email = "{}@taiga.io".format(self.username)
self.is_active = False self.is_active = False
self.full_name = "Deleted user" self.full_name = "Deleted user"