standards can be downloaded and deactivated
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from rowers.models import StandardCollection,CourseStandard
|
||||
from rowers.models import StandardCollection,CourseStandard, VirtualRaceResult,IndoorVirtualRaceResult
|
||||
|
||||
import pandas as pd
|
||||
import arrow
|
||||
@@ -10,7 +10,8 @@ def save_scoring(name,user,filename,id=0,notes=""):
|
||||
collection.save()
|
||||
standards = CourseStandard.objects.filter(standardcollection=collection)
|
||||
for standard in standards:
|
||||
standard.delete()
|
||||
standards.delete()
|
||||
|
||||
else:
|
||||
try:
|
||||
collection = StandardCollection.objects.get(id=id)
|
||||
@@ -19,8 +20,11 @@ def save_scoring(name,user,filename,id=0,notes=""):
|
||||
collection.save()
|
||||
standards = CourseStandard.objects.filter(standardcollection=collection)
|
||||
for standard in standards:
|
||||
print(standard,collection)
|
||||
standard.delete()
|
||||
records1 = VirtualRaceResult.objects.filter(entrycategory=standard)
|
||||
records2 = IndoorVirtualRaceResult.objects.filter(entrycategory=standard)
|
||||
if records1.count()+records2.count() == 0:
|
||||
standard.delete()
|
||||
|
||||
|
||||
except StandardCollection.DoesNotExist:
|
||||
return 0
|
||||
@@ -30,6 +34,22 @@ def save_scoring(name,user,filename,id=0,notes=""):
|
||||
except:
|
||||
return 0
|
||||
|
||||
df.rename(
|
||||
columns={
|
||||
'name':'Name',
|
||||
'agemax':'MaxAge',
|
||||
'agemin':'MinAge',
|
||||
'adaptiveclass':'AdaptiveClass',
|
||||
'coursedistance':'CourseDistance',
|
||||
'coursetime':'CourseStandard',
|
||||
'boatclass':'BoatClass',
|
||||
'boattype':'BoatType',
|
||||
'sex':'Gender',
|
||||
'weightclass':'WeightClass',
|
||||
'skillclass':'SkillClass',
|
||||
},
|
||||
inplace=True)
|
||||
|
||||
df = df.drop_duplicates(['Name'])
|
||||
|
||||
for index, row in df.iterrows():
|
||||
@@ -60,9 +80,9 @@ def save_scoring(name,user,filename,id=0,notes=""):
|
||||
|
||||
try:
|
||||
boatclass = row['BoatClass']
|
||||
if boatclass.lower() in ['standard','olympic','normal']:
|
||||
if boatclass.lower() in ['standard','olympic','normal','water']:
|
||||
boatclass = 'water'
|
||||
elif boatclass.lower() in ['erg','c2','concept','static']:
|
||||
elif boatclass.lower() in ['erg','c2','concept','static','rower']:
|
||||
boatclass = 'rower'
|
||||
elif boatclass.lower() in ['dynamic']:
|
||||
boatclass = 'dynamic'
|
||||
@@ -115,23 +135,43 @@ def save_scoring(name,user,filename,id=0,notes=""):
|
||||
except KeyError:
|
||||
skillclass = 'Open'
|
||||
|
||||
# some testing
|
||||
standard = CourseStandard(
|
||||
name=name,
|
||||
coursedistance=coursedistance,
|
||||
referencespeed=referencespeed,
|
||||
coursetime=coursetime,
|
||||
agemin=agemin,
|
||||
agemax=agemax,
|
||||
boatclass=boatclass,
|
||||
boattype=boattype,
|
||||
sex=sex,
|
||||
weightclass=weightclass,
|
||||
adaptiveclass=adaptiveclass,
|
||||
skillclass=skillclass,
|
||||
standardcollection = collection,
|
||||
)
|
||||
# finding existing standard
|
||||
existingstandards = CourseStandard.objects.filter(name=name,standardcollection=collection)
|
||||
#print(existingstandards,collection)
|
||||
if existingstandards:
|
||||
existingstandards.update(
|
||||
name=name,
|
||||
coursedistance=coursedistance,
|
||||
referencespeed=referencespeed,
|
||||
coursetime=coursetime,
|
||||
agemin=agemin,
|
||||
agemax=agemax,
|
||||
boatclass=boatclass,
|
||||
boattype=boattype,
|
||||
sex=sex,
|
||||
weightclass=weightclass,
|
||||
adaptiveclass=adaptiveclass,
|
||||
skillclass=skillclass,
|
||||
standardcollection = collection,
|
||||
)
|
||||
else:
|
||||
#print('not')
|
||||
standard = CourseStandard(
|
||||
name=name,
|
||||
coursedistance=coursedistance,
|
||||
referencespeed=referencespeed,
|
||||
coursetime=coursetime,
|
||||
agemin=agemin,
|
||||
agemax=agemax,
|
||||
boatclass=boatclass,
|
||||
boattype=boattype,
|
||||
sex=sex,
|
||||
weightclass=weightclass,
|
||||
adaptiveclass=adaptiveclass,
|
||||
skillclass=skillclass,
|
||||
standardcollection = collection,
|
||||
)
|
||||
|
||||
standard.save()
|
||||
standard.save()
|
||||
|
||||
return collection.id
|
||||
|
||||
Reference in New Issue
Block a user