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
|
@ -365,9 +365,16 @@ class RoundCreateView(LoginRequiredMixin, QuickActionsMixin, generic.CreateView)
|
||||||
initial = super().get_initial()
|
initial = super().get_initial()
|
||||||
initial['equipment'] = self.equipment
|
initial['equipment'] = self.equipment
|
||||||
initial['session'] = self.session
|
initial['session'] = self.session
|
||||||
|
last_round = self.equipment.rounds.filter(session=self.session).last() # type: Round
|
||||||
|
initial['theoretical_max_percentage'] = theoretical_max_percentage
|
||||||
|
|
||||||
|
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['repetition_number'] = self.equipment.default_repetition_number or 12
|
||||||
initial['work_form'] = self.equipment.default_work_form
|
initial['work_form'] = self.equipment.default_work_form
|
||||||
initial['theoretical_max_percentage'] = theoretical_max_percentage
|
|
||||||
proposed_weight = 0
|
proposed_weight = 0
|
||||||
theoretical_max = self.equipment.last_theoretical_max
|
theoretical_max = self.equipment.last_theoretical_max
|
||||||
if theoretical_max:
|
if theoretical_max:
|
||||||
|
|
Loading…
Reference in a new issue