You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
padelclub_backend/tournaments/models/custom_user.py

60 lines
3.1 KiB

from django.db import models
from django.contrib.auth.models import AbstractUser
from django.utils.timezone import now
from . import club, enums
import uuid
class CustomUser(AbstractUser):
pass
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=True)
last_update = models.DateTimeField(default=now)
email = models.EmailField(unique=True)
umpire_code = models.CharField(max_length=50, blank=True, null=True)
clubs = models.ManyToManyField(club.Club, blank=True)
phone = models.CharField(max_length=15, null=True, blank=True)
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
licence_id = models.CharField(max_length=10, null=True, blank=True)
country = models.CharField(max_length=40, null=True, blank=True)
summons_message_body = models.TextField(blank=True, null=True)
summons_message_signature = models.TextField(blank=True, null=True)
summons_available_payment_methods = models.TextField(blank=True, null=True)
summons_display_format = models.BooleanField(default=False)
summons_display_entry_fee = models.BooleanField(default=False)
summons_use_full_custom_message = models.BooleanField(default=False)
match_formats_default_duration = models.JSONField(blank=True, null=True)
bracket_match_format_preference = models.IntegerField(default=enums.FederalMatchCategory.NINE_GAMES, choices=enums.FederalMatchCategory.choices, null=True, blank=True)
group_stage_match_format_preference = models.IntegerField(default=enums.FederalMatchCategory.NINE_GAMES, choices=enums.FederalMatchCategory.choices, null=True, blank=True)
loser_bracket_match_format_preference = models.IntegerField(default=enums.FederalMatchCategory.NINE_GAMES, choices=enums.FederalMatchCategory.choices, null=True, blank=True)
device_id = models.CharField(max_length=50, null=True, blank=True)
### ### ### ### ### ### ### ### ### ### ### WARNING ### ### ### ### ### ### ### ### ### ###
### WARNING : Any added field MUST be inserted in the method below: fields_for_update() ###
### ### ### ### ### ### ### ### ### ### ### WARNING ### ### ### ### ### ### ### ### ### ###
def fields_for_update():
# returns the list of fields to update without password
return ['id', 'last_update', 'username', 'email', 'umpire_code', 'clubs', 'phone', 'first_name', 'last_name',
'licence_id', 'country',
'summons_message_body', 'summons_message_signature', 'summons_available_payment_methods',
'summons_display_format', 'summons_display_entry_fee',
'summons_use_full_custom_message', 'match_formats_default_duration', 'bracket_match_format_preference',
'group_stage_match_format_preference', 'loser_bracket_match_format_preference', 'device_id']
def __str__(self):
return self.username
def discord_string(self):
return f"{self.username} : {self.first_name} {self.last_name} | {self.email} | {self.phone}"
def event_count(self):
return len(self.event_set.all())
def full_name(self):
return f"{self.first_name} {self.last_name}"