From 6c7eef8a1941763d9ad47f50428e30f87213afcd Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Sat, 27 Feb 2021 11:41:59 +0100 Subject: [PATCH] Templates -> Library in many (all?) places --- rowers/models.py | 11 ++++++++++- rowers/templates/plannedsessioncreate.html | 6 +++--- rowers/templates/plannedsessionedit.html | 2 +- rowers/templates/plannedsessionteamcreate.html | 4 ++-- rowers/templates/plannedsessiontemplateedit.html | 6 +++--- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/rowers/models.py b/rowers/models.py index 4cc47bc3..bf9837b7 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -25,6 +25,7 @@ import twitter import re import pytz from django_countries.fields import CountryField +import tempfile from scipy.interpolate import splprep, splev, CubicSpline,interp1d @@ -2385,7 +2386,11 @@ class PlannedSession(models.Model): self.steps_json = json.dumps(steps) if self.steps_json and not self.fitfile: - filename = settings.MEDIA_ROOT+'/session'+encoder.encode_hex(self.id)+'.fit' + if self.pk is not None: + filename = settings.MEDIA_ROOT+'/session'+encoder.encode_hex(self.pk)+'.fit' + else: + file = tempfile.NamedTemporaryFile(mode='w+b',suffix='.fit',dir=settings.MEDIA_ROOT) + filename = file.name steps = json.loads(self.steps_json) steps['filename'] = filename fitfile = steps_write_fit(steps) @@ -2597,6 +2602,7 @@ class PlannedSessionTemplateForm(ModelForm): model = PlannedSession fields = [ 'name', + 'sessionsport', 'sessiontype', 'sessionmode', 'criterium', @@ -2604,6 +2610,8 @@ class PlannedSessionTemplateForm(ModelForm): 'sessionunit', 'course', 'comment', + 'interval_string', + 'fitfile' ] dateTimeOptions = { @@ -2613,6 +2621,7 @@ class PlannedSessionTemplateForm(ModelForm): widgets = { 'comment': forms.Textarea, + 'interval_string':forms.Textarea(attrs={'rows':2, 'cols':50}) } def __init__(self,*args,**kwargs): diff --git a/rowers/templates/plannedsessioncreate.html b/rowers/templates/plannedsessioncreate.html index 4f5b52ef..03c89c2b 100644 --- a/rowers/templates/plannedsessioncreate.html +++ b/rowers/templates/plannedsessioncreate.html @@ -60,7 +60,7 @@ Edit Clone Delete - Template + Library @@ -90,7 +90,7 @@ Delete - Save + Save to Library {% endfor %} @@ -98,7 +98,7 @@
  • -

    Templates

    +

    Session Library

    Click on session name to clone to current period

    diff --git a/rowers/templates/plannedsessionedit.html b/rowers/templates/plannedsessionedit.html index f5e04af5..b3443795 100644 --- a/rowers/templates/plannedsessionedit.html +++ b/rowers/templates/plannedsessionedit.html @@ -111,7 +111,7 @@
  • -

    Templates

    +

    Session Library

    Click on session name to clone to current period

    diff --git a/rowers/templates/plannedsessionteamcreate.html b/rowers/templates/plannedsessionteamcreate.html index e9d3235c..fd0befc0 100644 --- a/rowers/templates/plannedsessionteamcreate.html +++ b/rowers/templates/plannedsessionteamcreate.html @@ -95,7 +95,7 @@ Delete - Save + Save to Library {% endfor %} @@ -105,7 +105,7 @@
  • {% endif %}
  • -

    Templates

    +

    Session Library

    Click on session name to clone to current period

    diff --git a/rowers/templates/plannedsessiontemplateedit.html b/rowers/templates/plannedsessiontemplateedit.html index 34dde816..d063cf6c 100644 --- a/rowers/templates/plannedsessiontemplateedit.html +++ b/rowers/templates/plannedsessiontemplateedit.html @@ -2,7 +2,7 @@ {% load staticfiles %} {% load rowerfilters %} -{% block title %}Update Template Session{% endblock %} +{% block title %}Update Library Session{% endblock %} {% block main %}

    Edit Session Template

    @@ -36,7 +36,7 @@
  • -

    Templates

    +

    Library

    Click on session name to clone to current period

    @@ -65,7 +65,7 @@ {{ ps.sessionvalue }} {{ ps.sessionunit }} - Edit Template + Edit Library Session Delete