unfinished, untested
This commit is contained in:
@@ -29,6 +29,10 @@
|
|||||||
|
|
||||||
{% if workouts %}
|
{% if workouts %}
|
||||||
<li class="grid_4">
|
<li class="grid_4">
|
||||||
|
<form enctype="multipart/form-data" method="post">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input name='workouts' type="submit" value="Import selected workouts">
|
||||||
|
<a href="/rowers/workout/nkimport/?selectallnew=true">Select All New</a>
|
||||||
<table width="70%" class="listtable">
|
<table width="70%" class="listtable">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
@@ -44,7 +48,12 @@
|
|||||||
{% for workout in workouts %}
|
{% for workout in workouts %}
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<a href="/rowers/workout/nkimport/{{ workout|lookup:'id' }}/async/">Import</a></td>
|
{% if workout|lookup:'new' == 'NEW' and checknew == 'true' %}
|
||||||
|
<input checked type="checkbox" value={{ workout|lookup:'id' }} name="workoutid">
|
||||||
|
{% else %}
|
||||||
|
<input type="checkbox" value={{ workout|lookup:'id' }} name="workoutid">
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
<td>{{ workout|lookuplong:'name' }}</td>
|
<td>{{ workout|lookuplong:'name' }}</td>
|
||||||
<td class="block" style="width:auto">{{ workout|lookuplong:'starttime' }}</td>
|
<td class="block" style="width:auto">{{ workout|lookuplong:'starttime' }}</td>
|
||||||
<td>{{ workout|lookup:'duration' }} </td>
|
<td>{{ workout|lookup:'duration' }} </td>
|
||||||
@@ -55,6 +64,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</form>
|
||||||
</li>
|
</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li class="grid_4">
|
<li class="grid_4">
|
||||||
|
|||||||
@@ -637,6 +637,35 @@ def workout_nkimport_view(request,userid=0,after=0,before=0):
|
|||||||
|
|
||||||
workouts = workouts[::-1]
|
workouts = workouts[::-1]
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
try:
|
||||||
|
tdict = dict(request.POST.lists())
|
||||||
|
ids = tdict['workoutid']
|
||||||
|
nkids = [int(id) for id in ids]
|
||||||
|
alldata = {}
|
||||||
|
|
||||||
|
for item in res.json()['data']:
|
||||||
|
alldata[item['id']] = item
|
||||||
|
counter = 0
|
||||||
|
for nkid in nkids:
|
||||||
|
csvfilename = 'media/{code}_{nkid}.csv'.format(code=uuid4().hex[:16],nkid=nkid)
|
||||||
|
result = myqueue(
|
||||||
|
queue,
|
||||||
|
handle_nk_async_workout,
|
||||||
|
alldata,
|
||||||
|
r.user.id,
|
||||||
|
r.nktoken,
|
||||||
|
nkid,
|
||||||
|
counter,
|
||||||
|
r.defaulttimezone
|
||||||
|
)
|
||||||
|
counter = counter+1
|
||||||
|
messages.info(request,'Your NK logbook workouts will be imported in the background. It may take a few minutes before it appears.'.format(c2id=c2id))
|
||||||
|
url = reverse('workouts_view')
|
||||||
|
return HttpResponseRedirect(url)
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
breadcrumbs = [
|
breadcrumbs = [
|
||||||
{
|
{
|
||||||
'url':'/rowers/list-workouts/',
|
'url':'/rowers/list-workouts/',
|
||||||
|
|||||||
Reference in New Issue
Block a user