From 22d5ee5e3f9b082379df349d44045827a29300db Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 5 Apr 2022 16:25:36 +0200 Subject: [PATCH] saveState not working yet --- rowers/models.py | 25 +++++++++++ rowers/templates/stepeditor.html | 71 +++++++++++++++++++++++++------- rowers/views/planviews.py | 32 +++++--------- rowers/views/statements.py | 3 +- static/css/rowsandall2.css | 21 ++++++---- 5 files changed, 107 insertions(+), 45 deletions(-) diff --git a/rowers/models.py b/rowers/models.py index 7624c996..efc43f81 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -2427,6 +2427,31 @@ class PlannedSessionStep(models.Model): notes = models.TextField(default='',max_length=200, blank=True, null=True) color = models.TextField(default='#ddd',max_length=200) + def save(self, *args, **kwargs): + if self.intensity == "Warmup": + self.color = "#ffcccb" + elif self.intensity == "Cooldown": + self.color = '#90ee90' + elif self.intensity == "Rest": + self.color = 'add8e6' + + super(PlannedSessionStep, self).save(*args, **kwargs) + +class StepEditorForm(ModelForm): + class Meta: + model = PlannedSessionStep + fields = [ + 'name', + #'type', + 'durationtype', + 'durationvalue', + 'intensity', + ] + + widgets = { + 'name': forms.Textarea(attrs={'rows':1, 'cols':50}), + } + class PlannedSession(models.Model): diff --git a/rowers/templates/stepeditor.html b/rowers/templates/stepeditor.html index 85a6478f..2d92d0de 100644 --- a/rowers/templates/stepeditor.html +++ b/rowers/templates/stepeditor.html @@ -7,6 +7,15 @@ {% block main %}

Plan Training Steps

+

+ WARNING: This is experimental functionality which may not behave as you + expect. Does not work on smartphones. +

+

+ Drag from Library to Training to add a step to the end. + Drag on top of a training step to insert after it. + Drag out of Training to remove a step. +

Training

@@ -14,7 +23,7 @@

Library

{% for step in steps %} -
+
{{ step.name }}
@@ -22,8 +31,15 @@ {% endfor %}
-
-

Remove

+
+

Add new step

+
+ + {{ form.as_table }} +
+ {% csrf_token %} + +
{% endblock %} @@ -33,11 +49,25 @@