messages working
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,3 +1,5 @@
|
||||
# cache
|
||||
/django_cache/
|
||||
|
||||
# Compiled python modules.
|
||||
*.pyc
|
||||
|
||||
@@ -27,7 +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
|
||||
#from django.contrib import messages
|
||||
|
||||
# Project
|
||||
# from .models import Profile
|
||||
@@ -46,7 +46,7 @@ tpapilocation = "https://api.trainingpeaks.com"
|
||||
|
||||
from celery import Celery,app
|
||||
import time
|
||||
from async_messages import message_user
|
||||
from async_messages import message_user,messages
|
||||
|
||||
@app.task
|
||||
def addcomment(userid,id):
|
||||
@@ -55,7 +55,7 @@ def addcomment(userid,id):
|
||||
w.notes += '\n the task has run'
|
||||
w.save()
|
||||
u = User.objects.get(id=userid)
|
||||
message_user(u,' The task has run')
|
||||
messages.info(u,' The task has run')
|
||||
return 1
|
||||
|
||||
|
||||
|
||||
@@ -2183,6 +2183,7 @@ def workout_forcecurve_view(request,id=0,workstrokesonly=False):
|
||||
})
|
||||
|
||||
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):
|
||||
|
||||
@@ -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',
|
||||
@@ -280,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,6 +154,17 @@
|
||||
|
||||
<div class="clear"></div>
|
||||
<div class="grid_12">
|
||||
{% 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">
|
||||
|
||||
Reference in New Issue
Block a user