Exemple #1
0
    def __init__(self, intensity, user, workout=None, rep=1, time=None, distance_in_miles=None,
                 distance_as_percent=None, rest=None):

        # intensity is the STRING: "easy", "marathon", or "tempo"
        self.intensity = intensity
        # when segment is called from the User class user_id will not need to be passed in
        self.user = user
        # uses instance method from User class
        self.pace = user.paces(self.intensity)
        self.rep = rep
        self.time = time
        if time:
            self.total_time = time * rep
        # explanation of self.distance from time: if the segment was asked
        # self.dist when only time is given it should not return a value. you are
        # running for time specifically. A workout can determine an aprox. of
        # distance of any segment using calc_distance()
        self.rest = rest
        # adds bi-directional accountability, linked to parent instance
        self.workout = None
        # peakmileage in meters
        peakmileage = calculator.miles_to_meters(self.user.weekly_mileage)
        self.distance = None
        if distance_as_percent:
            self.distance = (distance_as_percent * peakmileage)
        # in meters
        if distance_in_miles:
            self.distance = calculator.miles_to_meters(distance_in_miles)
Exemple #2
0
 def __init__(self, user, percent_peak_mileage, plan, workouts, days=6):
     self.user = user
     #  percent_peak_mileage is specified for each TP, must pass in.
     self.percent_peak_mileage = percent_peak_mileage
     # user_id from User class/instance, as class method
     self.peakmileage = calculator.miles_to_meters(user.weekly_mileage)
     self.week_in_meters = (self.percent_peak_mileage * self.peakmileage)
     # self.week_in_miles = (self.percent_peak_mileage * self.peakmileage)
     self.plan = plan
     self.days = days
     self.quality_distance = sum(workout.distance for workout in workouts)
     self.workouts = self.create_remaining_days(workouts)
     for workout in self.workouts:
         workout.week = self
     self.distance = sum(workout.distance for workout in self.workouts)