Search form and pagination
This commit is contained in:
@@ -5,6 +5,8 @@ from rowingdata import cumcpdata,histodata
|
|||||||
|
|
||||||
from rowingdata import rowingdata as rrdata
|
from rowingdata import rowingdata as rrdata
|
||||||
|
|
||||||
|
from django.utils import timezone
|
||||||
|
|
||||||
from bokeh.plotting import figure, ColumnDataSource, Figure,curdoc
|
from bokeh.plotting import figure, ColumnDataSource, Figure,curdoc
|
||||||
from bokeh.models import CustomJS,Slider
|
from bokeh.models import CustomJS,Slider
|
||||||
from bokeh.charts import Histogram,HeatMap
|
from bokeh.charts import Histogram,HeatMap
|
||||||
@@ -570,7 +572,6 @@ def interactive_cum_flex_chart2(theworkouts,promember=0,
|
|||||||
|
|
||||||
datadf = dataprep.smalldataprep(theworkouts,xparam,yparam1,yparam2)
|
datadf = dataprep.smalldataprep(theworkouts,xparam,yparam1,yparam2)
|
||||||
|
|
||||||
|
|
||||||
axlabels = {
|
axlabels = {
|
||||||
'time': 'Time',
|
'time': 'Time',
|
||||||
'distance': 'Distance (m)',
|
'distance': 'Distance (m)',
|
||||||
@@ -631,11 +632,16 @@ def interactive_cum_flex_chart2(theworkouts,promember=0,
|
|||||||
return ['','<p>No non-zero data in selection</p>','','']
|
return ['','<p>No non-zero data in selection</p>','','']
|
||||||
|
|
||||||
|
|
||||||
datadf['x1'] = datadf.ix[:,xparam]
|
# datadf['x1'] = datadf.ix[:,xparam]
|
||||||
|
datadf = datadf.rename(columns={
|
||||||
|
xparam:'x1',
|
||||||
|
yparam1:'y1',
|
||||||
|
})
|
||||||
|
|
||||||
datadf['y1'] = datadf.ix[:,yparam1]
|
# datadf['y1'] = datadf.ix[:,yparam1]
|
||||||
if yparam2 != 'None':
|
if yparam2 != 'None':
|
||||||
datadf['y2'] = datadf.ix[:,yparam2]
|
# datadf['y2'] = datadf.ix[:,yparam2]
|
||||||
|
datadf = datadf.rename(columns={yparam2:'y2'})
|
||||||
else:
|
else:
|
||||||
datadf['y2'] = datadf['y1']
|
datadf['y2'] = datadf['y1']
|
||||||
|
|
||||||
@@ -674,6 +680,8 @@ def interactive_cum_flex_chart2(theworkouts,promember=0,
|
|||||||
datadf.copy()
|
datadf.copy()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
print "jet",timezone.now()
|
||||||
|
|
||||||
# Add hover to this comma-separated string and see what changes
|
# Add hover to this comma-separated string and see what changes
|
||||||
if (promember==1):
|
if (promember==1):
|
||||||
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,resize,crosshair'
|
TOOLS = 'save,pan,box_zoom,wheel_zoom,reset,tap,resize,crosshair'
|
||||||
|
|||||||
@@ -30,6 +30,14 @@
|
|||||||
<th>Weight Category:</th><td>{{ workout.weightcategory }}</td>
|
<th>Weight Category:</th><td>{{ workout.weightcategory }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
<form id="searchform" action="."
|
||||||
|
method="get" accept-charset="utf-8">
|
||||||
|
<button class="button blue small" type="submit">
|
||||||
|
Search
|
||||||
|
</button>
|
||||||
|
<input class="searchfield" id="searchbox" name="q" type="text" placeholder="Search">
|
||||||
|
</form>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="comparison" class="grid_8 omega">
|
<div id="comparison" class="grid_8 omega">
|
||||||
@@ -73,5 +81,21 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<p> No workouts found </p>
|
<p> No workouts found </p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
<div class="grid_2 prefix_5 suffix_1 omega">
|
||||||
|
<span class="button gray small">
|
||||||
|
{% if workouts.has_previous %}
|
||||||
|
<a class="wh" href="?page={{ workouts.previous_page_number }}"><</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<span>
|
||||||
|
Page {{ workouts.number }} of {{ workouts.paginator.num_pages }}.
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{% if workouts.has_next %}
|
||||||
|
<a class="wh" href="?page={{ workouts.next_page_number }}">></a>
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -6,6 +6,14 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1>Recent Graphs</h1>
|
<h1>Recent Graphs</h1>
|
||||||
|
|
||||||
|
<form id="searchform" action="."
|
||||||
|
method="get" accept-charset="utf-8">
|
||||||
|
<button class="button blue small" type="submit">
|
||||||
|
Search
|
||||||
|
</button>
|
||||||
|
<input class="searchfield" id="searchbox" name="q" type="text" placeholder="Search">
|
||||||
|
</form>
|
||||||
{% if graphs1 %}
|
{% if graphs1 %}
|
||||||
<div class="grid_1 alpha">
|
<div class="grid_1 alpha">
|
||||||
<p> </p>
|
<p> </p>
|
||||||
|
|||||||
@@ -5,7 +5,9 @@
|
|||||||
{% block title %}Workouts{% endblock %}
|
{% block title %}Workouts{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
<div class="grid_12">
|
||||||
<h1>My Workouts</h1>
|
<h1>My Workouts</h1>
|
||||||
|
|
||||||
{% if workouts %}
|
{% if workouts %}
|
||||||
<table width="70%" class="listtable">
|
<table width="70%" class="listtable">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -49,4 +51,35 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<p> No workouts found </p>
|
<p> No workouts found </p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="grid_6 alpha">
|
||||||
|
<form id="searchform" action="."
|
||||||
|
method="get" accept-charset="utf-8">
|
||||||
|
<div class="grid_3 alpha">
|
||||||
|
<input class="searchfield" id="searchbox" name="q" type="text" placeholder="Search">
|
||||||
|
</div>
|
||||||
|
<div class="grid_1 suffix_2 omega">
|
||||||
|
<button class="button blue small" type="submit">
|
||||||
|
Search
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div class="grid_2 prefix_4 omega">
|
||||||
|
<span class="button gray small">
|
||||||
|
{% if workouts.has_previous %}
|
||||||
|
<a class="wh" href="?page={{ workouts.previous_page_number }}"><</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<span>
|
||||||
|
Page {{ workouts.number }} of {{ workouts.paginator.num_pages }}.
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{% if workouts.has_next %}
|
||||||
|
<a class="wh" href="?page={{ workouts.next_page_number }}">></a>
|
||||||
|
{% endif %}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
import time
|
import time
|
||||||
|
import operator
|
||||||
from django.views.generic.base import TemplateView
|
from django.views.generic.base import TemplateView
|
||||||
|
from django.db.models import Q
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.http import HttpResponse, HttpResponseRedirect
|
from django.http import HttpResponse, HttpResponseRedirect
|
||||||
from django.contrib.auth import authenticate, login, logout
|
from django.contrib.auth import authenticate, login, logout
|
||||||
from rowers.forms import LoginForm,DocumentsForm,UploadOptionsForm
|
from rowers.forms import LoginForm,DocumentsForm,UploadOptionsForm
|
||||||
from django.core.urlresolvers import reverse
|
from django.core.urlresolvers import reverse
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
|
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.utils.datastructures import MultiValueDictKeyError
|
from django.utils.datastructures import MultiValueDictKeyError
|
||||||
from django.utils import timezone,translation
|
from django.utils import timezone,translation
|
||||||
@@ -1772,6 +1775,25 @@ def workouts_view(request,message='',successmessage=''):
|
|||||||
# successmessage = 'New Workouts have been created from email'
|
# successmessage = 'New Workouts have been created from email'
|
||||||
|
|
||||||
workouts = Workout.objects.filter(user=r).order_by("-date", "-starttime")
|
workouts = Workout.objects.filter(user=r).order_by("-date", "-starttime")
|
||||||
|
query = request.GET.get('q')
|
||||||
|
if query:
|
||||||
|
query_list = query.split()
|
||||||
|
workouts = workouts.filter(
|
||||||
|
reduce(operator.and_,
|
||||||
|
(Q(name__icontains=q) for q in query_list)) |
|
||||||
|
reduce(operator.and_,
|
||||||
|
(Q(notes__icontains=q) for q in query_list))
|
||||||
|
)
|
||||||
|
|
||||||
|
paginator = Paginator(workouts,25) # show 25 workouts per page
|
||||||
|
page = request.GET.get('page')
|
||||||
|
|
||||||
|
try:
|
||||||
|
workouts = paginator.page(page)
|
||||||
|
except PageNotAnInteger:
|
||||||
|
workouts = paginator.page(1)
|
||||||
|
except EmptyPage:
|
||||||
|
workouts = paginator.page(paginator.num_pages)
|
||||||
|
|
||||||
return render(request, 'list_workouts.html',
|
return render(request, 'list_workouts.html',
|
||||||
{'workouts': workouts,
|
{'workouts': workouts,
|
||||||
@@ -1787,6 +1809,27 @@ def workout_comparison_list(request,id=0,message='',successmessage=''):
|
|||||||
r = Rower.objects.get(user=request.user)
|
r = Rower.objects.get(user=request.user)
|
||||||
u = User.objects.get(id=r.user.id)
|
u = User.objects.get(id=r.user.id)
|
||||||
workouts = Workout.objects.filter(user=r).order_by("-date", "-starttime").exclude(id=id)
|
workouts = Workout.objects.filter(user=r).order_by("-date", "-starttime").exclude(id=id)
|
||||||
|
|
||||||
|
query = request.GET.get('q')
|
||||||
|
if query:
|
||||||
|
query_list = query.split()
|
||||||
|
workouts = workouts.filter(
|
||||||
|
reduce(operator.and_,
|
||||||
|
(Q(name__icontains=q) for q in query_list)) |
|
||||||
|
reduce(operator.and_,
|
||||||
|
(Q(notes__icontains=q) for q in query_list))
|
||||||
|
)
|
||||||
|
|
||||||
|
paginator = Paginator(workouts,15) # show 25 workouts per page
|
||||||
|
page = request.GET.get('page')
|
||||||
|
|
||||||
|
try:
|
||||||
|
workouts = paginator.page(page)
|
||||||
|
except PageNotAnInteger:
|
||||||
|
workouts = paginator.page(1)
|
||||||
|
except EmptyPage:
|
||||||
|
workouts = paginator.page(paginator.num_pages)
|
||||||
|
|
||||||
row = Workout.objects.get(id=id)
|
row = Workout.objects.get(id=id)
|
||||||
|
|
||||||
return render(request, 'comparison_list.html',
|
return render(request, 'comparison_list.html',
|
||||||
@@ -3942,6 +3985,16 @@ def graphs_view(request):
|
|||||||
try:
|
try:
|
||||||
r = Rower.objects.get(user=request.user)
|
r = Rower.objects.get(user=request.user)
|
||||||
workouts = Workout.objects.filter(user=r).order_by("-date", "-starttime")
|
workouts = Workout.objects.filter(user=r).order_by("-date", "-starttime")
|
||||||
|
query = request.GET.get('q')
|
||||||
|
if query:
|
||||||
|
query_list = query.split()
|
||||||
|
workouts = workouts.filter(
|
||||||
|
reduce(operator.and_,
|
||||||
|
(Q(name__icontains=q) for q in query_list)) |
|
||||||
|
reduce(operator.and_,
|
||||||
|
(Q(notes__icontains=q) for q in query_list))
|
||||||
|
)
|
||||||
|
|
||||||
g = GraphImage.objects.filter(workout__in=workouts).order_by("-creationdatetime")
|
g = GraphImage.objects.filter(workout__in=workouts).order_by("-creationdatetime")
|
||||||
if (len(g)<=5):
|
if (len(g)<=5):
|
||||||
return render(request, 'list_graphs.html',
|
return render(request, 'list_graphs.html',
|
||||||
|
|||||||
@@ -17,14 +17,19 @@ a {
|
|||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
a:visited { color:#000; }
|
a:visited { color:#000; }
|
||||||
|
|
||||||
a:link { color: #000; }
|
a:link { color: #000; }
|
||||||
|
|
||||||
|
|
||||||
a:hover {
|
a:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
h1 {
|
h1 {
|
||||||
/* font-family: Georgia, serif; */
|
/* font-family: Georgia, serif; */
|
||||||
font-weight: normal;
|
font-weight: normal;
|
||||||
@@ -472,3 +477,15 @@ a.button {
|
|||||||
position: relative;
|
position: relative;
|
||||||
z-index: 10;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
a.wh:link {
|
||||||
|
color: #e9e9e9;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.wh:visited {
|
||||||
|
color: #e9e9e9;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.wh:hover {
|
||||||
|
color: #e9e9e9;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user