feat: added generate_random_color function for color field in model, default value set

This commit is contained in:
Chneemann 2025-03-30 19:31:29 +02:00
parent 23233c15e9
commit 144ab73dc8

View file

@ -1,10 +1,13 @@
import uuid
import uuid, random
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, PermissionsMixin, Group, Permission
from django.db import models
def generate_uuid_without_dashes():
return uuid.uuid4().hex
def generate_random_color():
return "#" + "".join(random.choices("0123456789ABCDEF", k=6))
class UserManager(BaseUserManager):
def create_user(self, email, first_name, password=None):
if not email:
@ -34,7 +37,7 @@ class User(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(unique=True)
phone = models.CharField(max_length=20, blank=True, null=True)
initials = models.CharField(max_length=10, blank=True)
color = models.CharField(max_length=20, blank=True)
color = models.CharField(max_length=20, blank=True, default=generate_random_color)
is_online = models.BooleanField(default=False)
is_contact_only = models.BooleanField(default=False)
last_login = models.DateTimeField(blank=True, null=True)