Private
Public Access
1
0

time team scraping works

This commit is contained in:
Sander Roosendaal
2022-06-25 16:07:11 +02:00
parent 0b88f3c861
commit 44d3dfc919
8 changed files with 172 additions and 8 deletions

View File

@@ -2,6 +2,8 @@ from django.db import models
from django import forms
from django.core.exceptions import ValidationError
import collections
import datetime
from django.utils import timezone
import trueskill
@@ -43,7 +45,7 @@ class athleteForm(forms.ModelForm):
fields = ['first_name','last_name','club','birth_year']
class Crew(models.Model):
athletes = models.ManyToManyField(Athlete)
athletes = models.ManyToManyField(Athlete, related_name='athlete_crews')
name = models.CharField(max_length=200)
def __str__(self):
@@ -90,10 +92,10 @@ class Race(models.Model):
"Cannot have the same crew more than one time in a race"
)
if len(athletes) != len(set(athletes)):
raise ValidationError(
"Cannot have the same athlete in different crews in a race"
)
#if len(athletes) != len(set(athletes)):
# raise ValidationError(
# "Cannot have the same athlete in different crews in a race"
# )
super(Race, self).save(*args, **kwargs)
@@ -208,6 +210,7 @@ class Result(models.Model):
"Cannot have the same crew more than one time in a race"
)
if len(athletes) != len(set(athletes)):
print([item for item, count in collections.Counter(athletes).items() if count>1])
raise ValidationError(
"Cannot have the same athlete in different crews in a race"
)