Private
Public Access
1
0

basic plan page and edit macro cycle

This commit is contained in:
Sander Roosendaal
2018-09-08 17:21:35 +02:00
parent a99ac4f5b3
commit 7774f4159f
5 changed files with 171 additions and 5 deletions

View File

@@ -992,7 +992,7 @@ class TrainingPlan(models.Model):
firstname = self.rower.user.first_name
lastname = self.rower.user.last_name
stri = u'Training Plan for {first_name} {last_name} {s} - {e}: {n}'.format(
stri = u'Training Plan for {firstname} {lastname} {s} - {e}: {n}'.format(
s = startdate.strftime('%Y-%m-%d'),
e = enddate.strftime('%Y-%m-%d'),
firstname = firstname,
@@ -1031,7 +1031,8 @@ class TrainingPlan(models.Model):
m.save()
createmacrofillers(self)
else:
createmacrofillers(self)
class TrainingPlanForm(ModelForm):
class Meta:
@@ -1070,10 +1071,20 @@ def createmacrofillers(plan):
plan = plan
).order_by("-startdate")
if not cycles:
macr = TrainingMacroCycle(
startdate = plan.startdate,
enddate = plan.enddate,
type='filler',
name='Filler'
)
macr.save()
thedate = plan.enddate
while cycles:
if cycles[0].enddate < thedate:
macr = TrainingMacroCycle(
plan=plan,
startdate = cycles[0].enddate+datetime.timedelta(days=1),
enddate = thedate,
type='filler',
@@ -1095,6 +1106,15 @@ class TrainingMacroCycle(models.Model):
choices=cycletypechoices,
max_length=150)
def __unicode__(self):
stri = 'Macro Cycle - {n} ({sd} - {ed})'.format(
n = self.name,
sd = self.startdate,
ed = self.enddate,
)
return stri
def save(self, *args, **kwargs):
if self.enddate < self.startdate:
startdate = self.startdate
@@ -1132,6 +1152,15 @@ class TrainingMacroCycle(models.Model):
meso.save()
class TrainingMacroCycleForm(ModelForm):
class Meta:
model = TrainingMacroCycle
fields = ['name','startdate','enddate']
widgets = {
'startdate': AdminDateWidget(),
'enddate': AdminDateWidget()
}
class TrainingMesoCycle(models.Model):
plan = models.ForeignKey(TrainingMacroCycle)
@@ -1143,6 +1172,14 @@ class TrainingMesoCycle(models.Model):
type = models.CharField(default='filler',
choices=cycletypechoices,
max_length=150)
def __unicode__(self):
stri = 'Meso Cycle - {n} ({sd} - {ed})'.format(
n = self.name,
sd = self.startdate,
ed = self.enddate,
)
return stri
class TrainingMicroCycle(models.Model):
@@ -1155,6 +1192,14 @@ class TrainingMicroCycle(models.Model):
type = models.CharField(default='filler',
choices=cycletypechoices,
max_length=150)
def __unicode__(self):
stri = 'Micro Cycle - {n} ({sd} - {ed})'.format(
n = self.name,
sd = self.startdate,
ed = self.enddate,
)
return stri
# Needs some error checking