From 360c52765374a857d891a167216aaf9a675b922d Mon Sep 17 00:00:00 2001 From: Muhammed Zafar Date: Tue, 12 Dec 2023 20:56:29 +0530 Subject: [PATCH] [PATCH] user muid edit bug --- db/user.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/db/user.py b/db/user.py index d3e1401d..6e7269b4 100644 --- a/db/user.py +++ b/db/user.py @@ -48,14 +48,15 @@ def profile_pic(self): return f"{decouple_config('BE_DOMAIN_NAME')}{fs.url(path)}" def save(self, *args, **kwargs): - full_name = f"{self.first_name}{self.last_name or ''}".replace(" ", "").lower()[:85] - self.muid = f"{full_name}@mulearn" - - counter = 0 - while User.objects.filter(muid=self.muid).exists(): - counter += 1 - self.muid = f"{full_name}-{counter}@mulearn" - + if self.muid is None: + full_name = f"{self.first_name}{self.last_name or ''}".replace(" ", "").lower()[:85] + self.muid = f"{full_name}@mulearn" + + counter = 0 + while User.objects.filter(muid=self.muid).exists(): + counter += 1 + self.muid = f"{full_name}-{counter}@mulearn" + return super().save(*args, **kwargs)