Esempio n. 1
0
 def to_json(self):
     return {
         'username': self._user.username,
         'email': self._user.email,
         'enabled_days': self.get_enabled_isoweekdays(),
         'minutes_per_day': self._user.minutes_per_day,
         'fitness_level': self._user.fitness_level,
         'experience': self._user.experience,
         'status': StatusState.from_index(self._user.status_state_id).canonical_name,
         'goal': Goal.get_by_id_as_json(self._user.goal_id),
         'gender': GenderType.from_index(self._user.gender_id).canonical_name,
         'age': self._user.age,
         'equipment_ids': self.get_available_equipment_ids(),
         'current_week_in_phase': self._user.current_week_in_phase,
         'total_weeks_in_phase': self._user.total_weeks_in_phase,
         'max_heart_rate': 220 - self._user.age,
         'phase': Phase.get_by_id(self._user.current_phase_id).to_json() if self._user.current_phase_id else None
     }
Esempio n. 2
0
def goals(request):
    return render_to_json(Goal.as_json())
Esempio n. 3
0
 def _start_first_phase(self):
     self._user.current_phase_id = Goal.get_by_id(self.goal_id).start_phase_id
     self._user.current_week_in_phase = 1
     min_length, max_length = PhaseLengthByGoal.get_min_max_phase_length_for_goal_phase(self.goal_id, self._user.current_phase_id)
     self._user.total_weeks_in_phase = random.randint(min_length, max_length)
     self._user.save()
Esempio n. 4
0
 def goal(self):
     return Goal.get_by_id(self.goal_id)
Esempio n. 5
0
 def get_cardio_type_id(self):
     return Goal.get_by_id(self.goal_id).cardio_type_id