New round takes defaults from previous one of the same session
This commit is contained in:
parent
2dfd335b04
commit
7f676068f8
1 changed files with 14 additions and 7 deletions
21
gym/views.py
21
gym/views.py
|
@ -365,14 +365,21 @@ class RoundCreateView(LoginRequiredMixin, QuickActionsMixin, generic.CreateView)
|
|||
initial = super().get_initial()
|
||||
initial['equipment'] = self.equipment
|
||||
initial['session'] = self.session
|
||||
initial['repetition_number'] = self.equipment.default_repetition_number or 12
|
||||
initial['work_form'] = self.equipment.default_work_form
|
||||
last_round = self.equipment.rounds.filter(session=self.session).last() # type: Round
|
||||
initial['theoretical_max_percentage'] = theoretical_max_percentage
|
||||
proposed_weight = 0
|
||||
theoretical_max = self.equipment.last_theoretical_max
|
||||
if theoretical_max:
|
||||
proposed_weight = theoretical_max.value * theoretical_max_percentage / 100
|
||||
initial['chosen_weight'] = proposed_weight
|
||||
|
||||
if last_round:
|
||||
initial['repetition_number'] = last_round.repetition_number
|
||||
initial['work_form'] = last_round.work_form
|
||||
initial['chosen_weight'] = last_round.chosen_weight
|
||||
else:
|
||||
initial['repetition_number'] = self.equipment.default_repetition_number or 12
|
||||
initial['work_form'] = self.equipment.default_work_form
|
||||
proposed_weight = 0
|
||||
theoretical_max = self.equipment.last_theoretical_max
|
||||
if theoretical_max:
|
||||
proposed_weight = theoretical_max.value * theoretical_max_percentage / 100
|
||||
initial['chosen_weight'] = proposed_weight
|
||||
|
||||
return initial
|
||||
|
||||
|
|
Loading…
Reference in a new issue