time team scraping works
This commit is contained in:
@@ -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"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user