Skip to content

Commit

Permalink
Merge branch 'dev' into dev-server
Browse files Browse the repository at this point in the history
  • Loading branch information
shaheenhyderk committed Dec 12, 2023
2 parents 235b04d + 8775b91 commit 416a7bd
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions db/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,17 @@ def profile_pic(self):
path = f'user/profile/{self.id}.png'
if fs.exists(path):
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.pk 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)


Expand Down

0 comments on commit 416a7bd

Please sign in to comment.