Fix bug/enhancement #210: Generate a random hex color for a new users

remotes/origin/enhancement/email-actions
David Barragán Merino 2014-03-19 20:34:39 +01:00
parent 6af88277e6
commit 93035ca646
1 changed files with 7 additions and 1 deletions

View File

@ -8,9 +8,15 @@ from django.contrib.auth.models import UserManager, AbstractUser
from taiga.base.utils.slug import slugify_uniquely from taiga.base.utils.slug import slugify_uniquely
from taiga.base.notifications.models import WatcherMixin from taiga.base.notifications.models import WatcherMixin
import random
def generate_random_hex_color():
return "#{:06x}".format(random.randint(0,0xFFFFFF))
class User(AbstractUser, WatcherMixin): class User(AbstractUser, WatcherMixin):
color = models.CharField(max_length=9, null=False, blank=True, default="#669933", color = models.CharField(max_length=9, null=False, blank=True, default=generate_random_hex_color,
verbose_name=_("color")) verbose_name=_("color"))
description = models.TextField(null=False, blank=True, description = models.TextField(null=False, blank=True,
verbose_name=_("description")) verbose_name=_("description"))