Merge branch 'feature/asynchronous' into develop
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
||||
# cache
|
||||
/django_cache/
|
||||
|
||||
# Compiled python modules.
|
||||
*.pyc
|
||||
|
||||
|
Before Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 149 KiB |
|
Before Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 209 KiB |
|
Before Width: | Height: | Size: 138 KiB |
|
Before Width: | Height: | Size: 158 KiB |
|
Before Width: | Height: | Size: 158 KiB |
|
Before Width: | Height: | Size: 250 KiB |
|
Before Width: | Height: | Size: 115 KiB |
|
Before Width: | Height: | Size: 28 KiB |
|
Before Width: | Height: | Size: 164 KiB |
|
Before Width: | Height: | Size: 137 KiB |
|
Before Width: | Height: | Size: 121 KiB |
|
Before Width: | Height: | Size: 25 KiB |
|
Before Width: | Height: | Size: 85 KiB |
|
Before Width: | Height: | Size: 42 KiB |
|
Before Width: | Height: | Size: 115 KiB |
|
Before Width: | Height: | Size: 113 KiB |
|
Before Width: | Height: | Size: 125 KiB |
|
Before Width: | Height: | Size: 193 KiB |
|
Before Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 86 KiB |
|
Before Width: | Height: | Size: 136 KiB |
|
Before Width: | Height: | Size: 21 KiB |
|
Before Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 149 KiB |
|
Before Width: | Height: | Size: 113 KiB |
|
Before Width: | Height: | Size: 56 KiB |
|
Before Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 66 KiB |
BIN
brochure WEB.pdf
@@ -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,messages
|
||||
|
||||
@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)
|
||||
messages.info(u,' The task has run')
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
# Custom error class - to raise a NoTokenError
|
||||
class TPNoTokenError(Exception):
|
||||
def __init__(self,value):
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import math
|
||||
import numpy as np
|
||||
|
||||
lbstoN = 4.44822
|
||||
|
||||
lbstoN = 4.44822
|
||||
|
||||
|
||||
def serialize_list(value,token=','):
|
||||
|
||||
@@ -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,23 @@ def workout_forcecurve_view(request,id=0,workstrokesonly=False):
|
||||
'teams':get_my_teams(request.user),
|
||||
})
|
||||
|
||||
from rowers.tpstuff import addcomment
|
||||
from django.contrib import messages
|
||||
# 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):
|
||||
|
||||
@@ -70,6 +70,8 @@ AUTHENTICATION_BACKENDS = (
|
||||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = [
|
||||
# 'django.middleware.cache.UpdateCacheMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.gzip.GZipMiddleware',
|
||||
# 'htmlmin.middleware.HtmlMinifyMiddleware',
|
||||
'htmlmin.middleware.MarkRequestMiddleware',
|
||||
@@ -83,6 +85,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',
|
||||
]
|
||||
@@ -279,6 +282,16 @@ SESSION_ENGINE = "django.contrib.sessions.backends.cache"
|
||||
SERVER_EMAIL='admin@rowsandall.com'
|
||||
ADMINS = [('Sander','roosendaalsander@gmail.com')]
|
||||
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
|
||||
'LOCATION': 'localhost:11211',
|
||||
'TIMEOUT': 900,
|
||||
}
|
||||
}
|
||||
|
||||
CACHE_MIDDLEWARE_ALIAS = 'default'
|
||||
CACHE_MIDDLEWARE_SECONDS = 900
|
||||
|
||||
# email stuff
|
||||
|
||||
|
||||
@@ -49,6 +49,12 @@ TEMPLATE_DEBUG = DEBUG
|
||||
|
||||
ALLOWED_HOSTS = ['localhost']
|
||||
|
||||
CACHES = {
|
||||
'default': {
|
||||
'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
|
||||
'LOCATION': 'C:/python/rowsandallapp/django_cache',
|
||||
}
|
||||
}
|
||||
|
||||
# Application definition
|
||||
|
||||
|
||||
@@ -154,7 +154,18 @@
|
||||
|
||||
<div class="clear"></div>
|
||||
<div class="grid_12">
|
||||
{% block message %}
|
||||
{% if messages %}
|
||||
{% for message in messages %}
|
||||
{% if message.level == DEFAULT_MESSAGE_LEVELS.ERROR %}
|
||||
<p class="message">
|
||||
{% else %}
|
||||
<p class="successmessage">
|
||||
{% endif %}
|
||||
{{ message }}
|
||||
</p>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% block message %}
|
||||
{% if message %}
|
||||
<p class="message">
|
||||
{{ message }}
|
||||
|
||||