From 65d604de15c20ff1048896e9c92ab62131014fea Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sun, 23 Jun 2019 15:54:59 +0200 Subject: [PATCH] Reduce number of lines in notes field --- gym/forms.py | 21 +++++++++++++++++++++ gym/views.py | 11 ++--------- 2 files changed, 23 insertions(+), 9 deletions(-) create mode 100644 gym/forms.py diff --git a/gym/forms.py b/gym/forms.py new file mode 100644 index 0000000..4522b78 --- /dev/null +++ b/gym/forms.py @@ -0,0 +1,21 @@ +from django.forms import ModelForm + +from gym.models import Round + + +class RoundForm(ModelForm): + class Meta: + model = Round + fields = [ + "equipment", + "session", + "theoretical_max_percentage", + "chosen_weight", + "repetition_number", + "work_form", + "notes", + ] + + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + self.fields["notes"].widget.attrs["rows"] = 3 diff --git a/gym/views.py b/gym/views.py index 86e952d..76049ee 100644 --- a/gym/views.py +++ b/gym/views.py @@ -7,6 +7,7 @@ from django.shortcuts import get_object_or_404 from django.urls import reverse from django.views import generic +from gym.forms import RoundForm from gym.mixins import SessionResetMixin, QuickActionsMixin from gym.models import Room, Equipment, Setting, Session, Round, TheoreticalMax @@ -454,18 +455,10 @@ class SessionDetailView(LoginRequiredMixin, QuickActionsMixin, generic.DetailVie class RoundCreateView(LoginRequiredMixin, QuickActionsMixin, generic.CreateView): model = Round - fields = [ - "equipment", - "session", - "theoretical_max_percentage", - "chosen_weight", - "repetition_number", - "work_form", - "notes", - ] template_name = "gym/round_edit.html" equipment = None session = None + form_class = RoundForm def get_quick_actions(self): return [