Private
Public Access
1
0

changed age record model

This commit is contained in:
Sander Roosendaal
2017-12-13 08:05:04 +01:00
parent 86a72545e0
commit c43d832151
3 changed files with 15 additions and 9 deletions

1
rowers/.#metrics.py Normal file
View File

@@ -0,0 +1 @@
E408191@CZ27LT9RCGN72.126064:1512983261

View File

@@ -27,7 +27,7 @@ class FavoriteChartAdmin(admin.ModelAdmin):
list_display = ('user','xparam','yparam1','yparam2','plottype','workouttype','reststrokes')
class C2WorldClassAgePerformanceAdmin(admin.ModelAdmin):
list_display = ('sex','weightcategory','agemin','agemax','distance','power','name','season')
list_display = ('sex','weightcategory','age','distance','power','name','season')
class SiteAnnouncementAdmin(admin.ModelAdmin):
list_display = ('announcement','created','modified','expires','dotweet')

View File

@@ -160,12 +160,12 @@ def save_agegroup(df,weightcategory,sex):
power = int(row['Power'])
season = int(row['Season'])
name = row['Name']
distance = int(row['Distance'])
record = C2WorldClassAgePerformance(
agemin = agemin,
agemax = agemax,
age = age,
weightcategory = weightcategory,
sex=sex,
distance = 2000,
distance = distance,
duration = duration,
power = power,
season = season,
@@ -184,8 +184,14 @@ def make_records(readfile):
save_agegroup(male_df,'hwt','male')
save_agegroup(female_lw_df,'lwt','female')
save_agegroup(male_lw_df,'lwt','male')
c2url = 'http://www.concept2.com/indoor-rowers/racing/records/world?machine=1&event=All&gender=All&age=All&weight=All'
def update_records(url=c2url):
dfs = pd.read_html(url,attrs={'class':'views-table'})
df = dfs[0]
df.columns = df.columns.str.strip()
class C2WorldClassAgePerformance(models.Model):
weightcategories = (
('hwt','heavy-weight'),
@@ -205,8 +211,7 @@ class C2WorldClassAgePerformance(models.Model):
max_length=30,
choices=sexcategories)
agemin = models.IntegerField(default=19,verbose_name="Minimum Age")
agemax = models.IntegerField(default=29,verbose_name="Maximum Age")
age = models.IntegerField(default=19,verbose_name="Age")
distance = models.IntegerField(default=2000)
name = models.CharField(max_length=200,blank=True)
@@ -215,10 +220,10 @@ class C2WorldClassAgePerformance(models.Model):
power = models.IntegerField(default=200)
class Meta:
unique_together = ('agemin','agemax','sex','weightcategory','distance')
unique_together = ('age','sex','weightcategory','distance')
def __unicode__(self):
return self.sex+' '+self.weightcategory+' '+self.name+':'+str(self.agemin)+'-'+str(self.agemax)+' ('+str(self.season)+')'
return self.sex+' '+self.weightcategory+' '+self.name+':'+str(self.age)+' ('+str(self.season)+')'
# For future Team functionality
class Team(models.Model):