Private
Public Access
1
0

create plannedsession view v1.0

This commit is contained in:
Sander Roosendaal
2018-02-05 21:36:11 +01:00
parent cdf18058b9
commit ba334554eb
5 changed files with 127 additions and 37 deletions

View File

@@ -668,6 +668,8 @@ class GeoPoint(models.Model):
# of multiple GeoPoint instances
def half_year_from_now():
return timezone.now()+timezone.timedelta(days=182)
# models related to training planning - draft
@@ -676,7 +678,7 @@ class TrainingTarget(models.Model):
rower = models.ForeignKey(Rower)
name = models.CharField(max_length=150,blank=True)
date = models.DateField(
default=timezone.now()+datetime.timedelta(days=182))
default=half_year_from_now)
notes = models.TextField(max_length=300,blank=True)
class TrainingTargetForm(ModelForm):
@@ -705,13 +707,14 @@ class TrainingTargetForm(ModelForm):
# although such a TrainingGoal could have automatically calculated
# values without needing the user to assign
class TrainingPlan(models.Model):
rower = models.ForeignKey(Rower)
name = models.CharField(max_length=150,blank=True)
target = models.ForeignKey(TrainingTarget,blank=True)
startdate = models.DateField(default=timezone.now)
enddate = models.DateField(
default=timezone.now()+datetime.timedelta(days=182))
default=half_year_from_now)
class TrainingPlanForm(ModelForm):
class Meta:
@@ -738,7 +741,7 @@ class TrainingMacroCycle(models.Model):
name = models.CharField(max_length=150,blank=True)
startdate = models.DateField(default=timezone.now)
enddate = models.DateField(
default=timezone.now()+datetime.timedelta(days=182))
default=half_year_from_now)
notes = models.TextField(max_length=300,blank=True)
type = models.CharField(default='filler',
choices=cycletypechoices,
@@ -749,7 +752,7 @@ class TrainingMesoCycle(models.Model):
name = models.CharField(max_length=150,blank=True)
startdate = models.DateField(default=timezone.now)
enddate = models.DateField(
default=timezone.now()+datetime.timedelta(days=182))
default=half_year_from_now)
notes = models.TextField(max_length=300,blank=True)
type = models.CharField(default='filler',
choices=cycletypechoices,
@@ -761,7 +764,7 @@ class TrainingMicroCycle(models.Model):
name = models.CharField(max_length=150,blank=True)
startdate = models.DateField(default=timezone.now)
enddate = models.DateField(
default=timezone.now()+datetime.timedelta(days=182))
default=half_year_from_now)
notes = models.TextField(max_length=300,blank=True)
type = models.CharField(default='filler',
choices=cycletypechoices,
@@ -816,7 +819,8 @@ class PlannedSession(models.Model):
name = models.CharField(max_length=150,blank=True)
comment = models.TextField(max_length=300,blank=True)
comment = models.TextField(max_length=300,blank=True,
)
startdate = models.DateField(default=timezone.now,
verbose_name='Start Date')
@@ -826,7 +830,8 @@ class PlannedSession(models.Model):
sessiontype = models.CharField(default='session',
choices=sessiontypechoices,
max_length=150)
max_length=150,
verbose_name='Session Type')
sessionvalue = models.IntegerField(default=60,verbose_name='Value')
@@ -855,31 +860,11 @@ class PlannedSession(models.Model):
sessionmode = models.CharField(default='distance',
choices=sessionmodechoices,
max_length=150)
max_length=150,
verbose_name='Session Mode')
hasranking = models.BooleanField(default=False)
class PlannedSessionForm(ModelForm):
class Meta:
model = PlannedSession
fields = ['startdate',
'enddate',
'sessiontype',
'sessionmode',
'sessionvalue',
'sessionunit',
'comment',
]
widgets = {
'comment': forms.Textarea,
'startdate': SelectDateWidget(
years=range(
timezone.now().year-1,timezone.now().year+1)),
'enddate': SelectDateWidget(
years=range(
timezone.now().year-1,timezone.now().year+1)),
}
def __unicode__(self):
name = self.name
@@ -893,6 +878,30 @@ class PlannedSessionForm(ModelForm):
)
return stri
class PlannedSessionForm(ModelForm):
class Meta:
model = PlannedSession
fields = ['startdate',
'enddate',
'name',
'sessiontype',
'sessionmode',
'sessionvalue',
'sessionunit',
'comment',
]
widgets = {
'comment': forms.Textarea,
'startdate': SelectDateWidget(
years=range(
timezone.now().year-1,timezone.now().year+2)),
'enddate': SelectDateWidget(
years=range(
timezone.now().year-1,timezone.now().year+2)),
}
# Workout
class Workout(models.Model):