Private
Public Access
1
0

testing tasks and messages

This commit is contained in:
Sander Roosendaal
2017-05-10 07:38:14 +02:00
parent 5857c13330
commit c4ffddfb06
39 changed files with 37 additions and 2 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 209 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 158 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 250 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 164 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 137 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 113 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

View File

@@ -27,6 +27,7 @@ from django.conf import settings
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
from django.contrib import messages
# Project
# from .models import Profile
@@ -43,6 +44,22 @@ from rowsandall_app.settings import (
tpapilocation = "https://api.trainingpeaks.com"
from celery import Celery,app
import time
from async_messages import message_user
@app.task
def addcomment(userid,id):
time.sleep(5)
w = Workout.objects.get(id=id)
w.notes += '\n the task has run'
w.save()
u = User.objects.get(id=userid)
message_user(u,' The task has run')
return 1
# Custom error class - to raise a NoTokenError
class TPNoTokenError(Exception):
def __init__(self,value):

View File

@@ -165,6 +165,7 @@ urlpatterns = [
url(r'^workout/upload/$',views.workout_upload_view),
url(r'^workout/upload/c/(?P<message>\w+.*)$',views.workout_upload_view),
url(r'^workout/(?P<id>\d+)/histo$',views.workout_histo_view),
url(r'^workout/(?P<id>\d+)/task$',views.workout_test_task_view),
url(r'^workout/(?P<id>\d+)/forcecurve$',views.workout_forcecurve_view),
url(r'^workout/(?P<id>\d+)/unsubscribe$',views.workout_unsubscribe_view),
url(r'^workout/(?P<id>\d+)/export/c/(?P<message>\w+.*)/s/(?P<successmessage>\w+.*)$',views.workout_export_view),

View File

@@ -1,8 +1,8 @@
import math
import numpy as np
lbstoN = 4.44822
lbstoN = 4.44822
def serialize_list(value,token=','):

View File

@@ -84,7 +84,7 @@ from rowers.rows import handle_uploaded_file
from rowers.tasks import handle_makeplot,handle_otwsetpower,handle_sendemailtcx,handle_sendemailcsv
from rowers.tasks import (
handle_sendemail_unrecognized,handle_sendemailnewcomment,
handle_sendemailnewresponse,
handle_sendemailnewresponse
)
from scipy.signal import savgol_filter
@@ -2182,6 +2182,22 @@ def workout_forcecurve_view(request,id=0,workstrokesonly=False):
'teams':get_my_teams(request.user),
})
from rowers.tpstuff import addcomment
# Test asynchronous tasking and messaging
@login_required()
def workout_test_task_view(request,id=0):
row = Workout.objects.get(id=id)
if settings.DEBUG:
res = addcomment.delay(request.user.id,row.id)
else:
res = queuelow.enqueue(addcomment,request.user.id,row.id)
url = reverse(workout_edit_view,
kwargs = {
'id':str(id),
})
return HttpResponseRedirect(url)
# Show Stroke power histogram for a workout
@login_required()
def workout_histo_view(request,id=0):

View File

@@ -83,6 +83,7 @@ MIDDLEWARE_CLASSES = [
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'oauth2_provider.middleware.OAuth2TokenMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'async_messages.middleware.AsyncMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
]