Adds the last participation if the last created event was not find

bracket-feature
Laurent 9 months ago
parent b868bc197f
commit 935547c44d
  1. 9
      tournaments/models/custom_user.py

@ -1,4 +1,5 @@
from django.db import models from django.db import models
from django.apps import apps
from django.contrib.auth.models import AbstractUser from django.contrib.auth.models import AbstractUser
from . import club, enums from . import club, enums
import uuid import uuid
@ -63,4 +64,12 @@ class CustomUser(AbstractUser):
latest_event = self.event_set.order_by('-creation_date').first() latest_event = self.event_set.order_by('-creation_date').first()
if latest_event and latest_event.club: if latest_event and latest_event.club:
return latest_event.club.name return latest_event.club.name
if self.licence_id:
PlayerRegistration = apps.get_model('tournaments', 'PlayerRegistration')
player_registration = PlayerRegistration.objects.filter(licence_id=self.licence_id).order_by('team_registration__registration_date').first()
try:
return player_registration.team_registration.tournament.event.club.name
except AttributeError:
return None
return None return None

Loading…
Cancel
Save