Private
Public Access
1
0

Merge branch 'release/v6.34'

This commit is contained in:
Sander Roosendaal
2018-03-25 20:51:20 +02:00
6 changed files with 96 additions and 15 deletions

View File

@@ -72,6 +72,7 @@ def processattachment(rower, fileobj, title, uploadoptions,testing=False):
workout = Workout.objects.get(id=workoutid[0])
uploads.do_sync(workout, uploadoptions)
uploads.make_private(workout, uploadoptions)
uploads.set_workouttype(workout, uploadoptions)
if 'make_plot' in uploadoptions:
plottype = uploadoptions['plottype']
workoutcsvfilename = workout.csvfilename[6:-4]

View File

@@ -369,13 +369,13 @@ def get_sessions_manager(m,teamid=0,startdate=date.today(),
manager=m,
startdate__lte=enddate,
enddate__gte=startdate,
).order_by("startdate","preferreddate","enddate")
).order_by("preferreddate","startdate","enddate")
else:
sps = PlannedSession.objects.filter(
manager=m,
startdate__lte=enddate,
enddate__gte=startdate,
).order_by("startdate","preferreddate","enddate")
).order_by("preferreddate","startdate","enddate")
return sps
@@ -386,7 +386,7 @@ def get_sessions(r,startdate=date.today(),
rower__in=[r],
startdate__lte=enddate,
enddate__gte=startdate,
).order_by("startdate","preferreddate","enddate")
).order_by("preferreddate","startdate","enddate")
return sps

View File

@@ -35,15 +35,15 @@
Last Week
</a>
<a class="button gray small alpha"
href="/rowers/sessions/coach/lastmonth/">
href="/rowers/sessions/coach/lastmonth">
Last Month
</a>
<a class="button gray small alpha"
href="/rowers/sessions/coach/nextweek/">
href="/rowers/sessions/coach/nextweek">
Next Week
</a>
<a class="button gray small alpha"
href="/rowers/sessions/coach/nextmonth/">
href="/rowers/sessions/coach/nextmonth">
Next Month
</a>
</div>
@@ -81,6 +81,7 @@
<tr>
<th>On or after</th>
<th>On or before</th>
<th>Preferred date</th>
<th>Name</th>
{% for r in rowers %}
<th class="rotate"><div><span>
@@ -90,7 +91,7 @@
</tr>
</thead>
<tbody>
{% for key, thedict in statusdict.items %}
{% for thedict in statusdict %}
<tr>
<td>
{{ thedict|lookup:'startdate'|date:"Y-m-d" }}
@@ -99,7 +100,10 @@
{{ thedict|lookup:'enddate'|date:"Y-m-d" }}
</td>
<td>
<a href="/rowers/sessions/{{ key }}">
{{ thedict|lookup:'preferreddate'|date:"Y-m-d" }}
</td>
<td>
<a href="/rowers/sessions/{{ thedict|lookup:"id" }}">
{% if thedict|lookup:'name' %}
{{ thedict|lookup:'name' }}
{% else %}
@@ -111,18 +115,18 @@
<td>
{% if thedict|lookup:'results'|lookup:r.id == 'completed' %}
<a class="green dot"
href="{% url 'plannedsession_view' id=key rowerid=r.id %}">&nbsp;</a>
href="{% url 'plannedsession_view' id=thedict|lookup:"id" rowerid=r.id %}">&nbsp;</a>
{% elif thedict|lookup:'results'|lookup:r.id == 'partial' %}
<a class="orange dot"
href="{% url 'plannedsession_view' id=key rowerid=r.id %}">&nbsp;</a>
href="{% url 'plannedsession_view' id=thedict|lookup:"id" rowerid=r.id %}">&nbsp;</a>
{% elif thedict|lookup:'results'|lookup:r.id == 'not done' %}
<a class="white dot"
href="/rowers/sessions/manage/{{ timeperiod }}/rower/{{ r.id }}/session/{{ key }}">&nbsp;</a>
href="/rowers/sessions/manage/{{ timeperiod }}/rower/{{ r.id }}/session/{{ thedict|lookup:"id" }}">&nbsp;</a>
{% elif thedict|lookup:'results'|lookup:r.id == 'not assigned' %}
&nbsp;
{% else %}
<a class="red dot"
href="/rowers/sessions/manage/{{ timeperiod }}/rower/{{ r.id }}/session/{{ key }}">&nbsp;</a>
href="/rowers/sessions/manage/{{ timeperiod }}/rower/{{ r.id }}/session/{{ thedict|lookup:"id" }}">&nbsp;</a>
{% endif %}
</td>
{% endfor %}

View File

@@ -362,7 +362,11 @@ class EmailTests(TestCase):
from_header = u.email,
subject = filename,
body="""
chart time
---
chart: time
workouttype: water
boattype: 4x
...
""")
m.save()
a2 = 'media/mailbox_attachments/'+filename

View File

@@ -27,6 +27,8 @@ queue = django_rq.get_queue('default')
queuelow = django_rq.get_queue('low')
queuehigh = django_rq.get_queue('low')
from types import workouttypes,boattypes
try:
from cStringIO import StringIO
except:
@@ -96,6 +98,29 @@ def matchsync(line):
return results
def gettypeoptions_body2(uploadoptions,body):
tester = re.compile('^(workout)')
testerb = re.compile('^(boat)')
for line in body.splitlines():
if tester.match(line.lower()):
for typ,verb in workouttypes:
str1 = '^(workout)(.*)({a})'.format(
a = typ
)
testert = re.compile(str1)
if testert.match(line.lower()):
uploadoptions['workouttype'] = typ
if testerb.match(line.lower()):
for typ,verb in boattypes:
str1 = '^(boat)(.*)({a})'.format(
a = typ
)
testert = re.compile(str1)
if testert.match(line.lower()):
uploadoptions['boattype'] = typ
return uploadoptions
def getprivateoptions_body2(uploadoptions,body):
tester = re.compile('^(priva)')
for line in body.splitlines():
@@ -181,6 +206,32 @@ def getplotoptions(uploadoptions,value):
return uploadoptions
def gettype(uploadoptions,value,key):
workouttype = 'rower'
for type,verb in workouttypes:
if value == type:
workouttype = type
if value == verb:
workouttype = type
uploadoptions[key] = workouttype
return uploadoptions
def getboattype(uploadoptions,value,key):
boattype = '1x'
for type,verb in boattypes:
if value == type:
boattype = type
if value == verb:
boattype = type
uploadoptions[key] = boattype
return uploadoptions
def getboolean(uploadoptions,value,key):
b = True
if not value:
@@ -208,6 +259,10 @@ def upload_options(body):
uploadoptions = getplotoptions(uploadoptions,value)
if 'priva' in lowkey:
uploadoptions = getboolean(uploadoptions,value,'makeprivate')
if 'workout' in lowkey:
uploadoptions = gettype(uploadoptions,value,'workouttype')
if 'boat' in lowkey:
uploadoptions = getboattype(uploadoptions,value,'boattype')
except AttributeError:
#pass
raise yaml.YAMLError
@@ -216,6 +271,7 @@ def upload_options(body):
uploadoptions = getplotoptions_body2(uploadoptions,body)
uploadoptions = getsyncoptions_body2(uploadoptions,body)
uploadoptions = getprivateoptions_body2(uploadoptions,body)
typeoptions = gettypeoptions_body2(uploadoptions,body)
except IOError:
pm = exc.problem_mark
strpm = str(pm)
@@ -296,6 +352,20 @@ def make_plot(r,w,f1,f2,plottype,title,imagename='',plotnr=0):
import c2stuff,stravastuff,sporttracksstuff,runkeeperstuff
import underarmourstuff,tpstuff
def set_workouttype(w,options):
try:
w.workouttype = options['workouttype']
w.save()
except KeyError:
pass
try:
w.boattype = options['boattype']
w.save()
except KeyError:
pass
return 1
def make_private(w,options):
if 'makeprivate' in options and options['makeprivate']:
w.privacy = 'hidden'

View File

@@ -12554,7 +12554,7 @@ def plannedsessions_coach_view(request,timeperiod='thisweek',
rowers = list(set(rowers))
statusdict = {}
statusdict = []
for ps in sps:
rowerstatus = {}
@@ -12562,12 +12562,14 @@ def plannedsessions_coach_view(request,timeperiod='thisweek',
ratio, status,completiondate = is_session_complete(r,ps)
rowerstatus[r.id] = status
sessiondict = {
'id': ps.id,
'results':rowerstatus,
'name': ps.name,
'startdate': ps.startdate,
'preferreddate': ps.preferreddate,
'enddate': ps.enddate,
}
statusdict[ps.id] = sessiondict
statusdict.append(sessiondict)
unmatchedworkouts = []
for r in rowers: