Does not save fit files
This commit is contained in:
@@ -2420,6 +2420,7 @@ class PlannedSession(models.Model):
|
||||
file = tempfile.NamedTemporaryFile(mode='w+b',suffix='.fit',dir=settings.MEDIA_ROOT)
|
||||
filename = file
|
||||
|
||||
|
||||
steps = self.steps
|
||||
|
||||
try:
|
||||
@@ -2433,9 +2434,12 @@ class PlannedSession(models.Model):
|
||||
self.steps = steps
|
||||
fitfile = steps_write_fit(steps)
|
||||
|
||||
|
||||
filelist = fitfile.split('/media/')
|
||||
|
||||
self.fitfile.name = filelist[-1]
|
||||
|
||||
|
||||
# calculate approximate distance
|
||||
if self.steps:
|
||||
sdict, totalmeters, totalseconds = ps_dict_order(self.steps)
|
||||
|
||||
@@ -121,6 +121,7 @@
|
||||
<th>Name</th>
|
||||
<th>Value</th>
|
||||
<th> </th>
|
||||
<th>Edit</th>
|
||||
<th>Delete</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -138,8 +139,11 @@
|
||||
</td>
|
||||
<td> {{ ps.sessionvalue }} </td>
|
||||
<td> {{ ps.sessionunit }} </td>
|
||||
<td>
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/templateedit/"><i class="fas fa-pencil-alt fa-fw"></i></a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/deleteconfirm/">Delete</a>
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/deleteconfirm/"><i class="fas fa-trash-alt fa-fw"></i> Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
</div>
|
||||
<p>
|
||||
<a href="/rowers/sessions/{{ thesession.id }}/deleteconfirm">Delete</a>
|
||||
<a href="/rowers/sessions/{{ thesession.id }}/deleteconfirm"><i class="fas fa-trash-alt fa-fw"></i> Delete</a>
|
||||
</p>
|
||||
<input class="button"
|
||||
action="/rowers/sessions/{{ thesession.id }}/templateedit/" type="submit" value="Save">
|
||||
@@ -65,10 +65,10 @@
|
||||
<td> {{ ps.sessionvalue }} </td>
|
||||
<td> {{ ps.sessionunit }} </td>
|
||||
<td>
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/templateedit/">Edit Library Session</a>
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/templateedit/"><i class="fas fa-pencil-alt fa-fw"></i> </a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/deleteconfirm/">Delete</a>
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/deleteconfirm/"><i class="fas fa-trash-alt fa-fw"></i> </a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
{% if user.is_authenticated and psdict.id.1|is_session_manager:user %}
|
||||
<p>
|
||||
<a href="/rowers/sessions/{{ psdict.id.1 }}/edit/user/{{ rower.user.id }}">
|
||||
Edit Session</a>
|
||||
<i class="fas fa-pencil-alt fa-fw"></i> Edit Session</a>
|
||||
/
|
||||
<a href="/rowers/sessions/{{ psdict.id.1 }}/maketemplate/?next={{ request.path|urlencode }}">Save to Library</a>
|
||||
<a href="/rowers/sessions/{{ psdict.id.1 }}/maketemplate/?next={{ request.path|urlencode }}"><i class="fas fa-books fa-fw"></i> Save to Library</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
<h1>Session {{ psdict.name.1 }}</h1>
|
||||
|
||||
@@ -2235,14 +2235,7 @@ class PlannedSessionDelete(DeleteView):
|
||||
w.plannedsession = None
|
||||
w.save()
|
||||
|
||||
if self.object.fitfile:
|
||||
filelist = self.object.fitfile.name.split('/media')
|
||||
filename = settings.MEDIA_ROOT+'/'+filelist[-1]
|
||||
try:
|
||||
os.remove(filename)
|
||||
except FileNotFoundError:
|
||||
print(filename)
|
||||
self.object.fitfile = None
|
||||
|
||||
|
||||
url = reverse(plannedsessions_view)
|
||||
next = self.request.GET.get('next',url)
|
||||
|
||||
Reference in New Issue
Block a user