bug fix
This commit is contained in:
@@ -49,6 +49,18 @@ def cleanbody(body):
|
||||
|
||||
return body
|
||||
|
||||
|
||||
sources = [s for s,name in workoutsources]
|
||||
|
||||
def matchsource(line):
|
||||
results = []
|
||||
for s in sources:
|
||||
testert = '^source.*(%s)' % s
|
||||
tester = re.compile(testert)
|
||||
|
||||
if tester.match(line.lower()):
|
||||
return group(1)
|
||||
|
||||
# currently only matches one chart
|
||||
def matchchart(line):
|
||||
results = []
|
||||
@@ -147,6 +159,14 @@ def getprivateoptions_body2(uploadoptions,body):
|
||||
|
||||
return uploadoptions
|
||||
|
||||
def getworkoutsources(uploadoptions,body):
|
||||
for line in body.splitlines():
|
||||
workoutsource = matchsource(line)
|
||||
if workoutsource:
|
||||
uploadoptions['workoutsource'] = workoutsource
|
||||
|
||||
return uploadoptions
|
||||
|
||||
def getplotoptions_body2(uploadoptions,body):
|
||||
for line in body.splitlines():
|
||||
chart = matchchart(line)
|
||||
@@ -241,6 +261,17 @@ def getboattype(uploadoptions,value,key):
|
||||
|
||||
return uploadoptions
|
||||
|
||||
def getsource(uploadoptions,value,key):
|
||||
workoutsource = 'unknown'
|
||||
for type,verb in workoutsources:
|
||||
if value == type:
|
||||
workoutsource = type
|
||||
if value == verb:
|
||||
workoutsource = type
|
||||
|
||||
uploadoptions[key] = workoutsource
|
||||
|
||||
return uploadoptions
|
||||
|
||||
def getboolean(uploadoptions,value,key):
|
||||
b = True
|
||||
@@ -273,6 +304,8 @@ def upload_options(body):
|
||||
uploadoptions = gettype(uploadoptions,value,'workouttype')
|
||||
if 'boat' in lowkey:
|
||||
uploadoptions = getboattype(uploadoptions,value,'boattype')
|
||||
if 'source' in lowkey:
|
||||
uploadoptions = getsource(uploadoptions,value,'workoutsource')
|
||||
except AttributeError:
|
||||
#pass
|
||||
raise yaml.YAMLError
|
||||
@@ -283,6 +316,7 @@ def upload_options(body):
|
||||
uploadoptions = getprivateoptions_body2(uploadoptions,body)
|
||||
typeoptions = gettypeoptions_body2(uploadoptions,body)
|
||||
uploadoptions = getstravaid(uploadoptions,body)
|
||||
uploadoptions = getworkoutsources(uploadoptions,body)
|
||||
except IOError:
|
||||
pm = exc.problem_mark
|
||||
strpm = str(pm)
|
||||
@@ -377,6 +411,13 @@ def set_workouttype(w,options):
|
||||
|
||||
return 1
|
||||
|
||||
def set_workoutsource(w,options):
|
||||
try:
|
||||
w.workoutsource = options['workoutsource']
|
||||
w.save()
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
def make_private(w,options):
|
||||
if 'makeprivate' in options and options['makeprivate']:
|
||||
w.privacy = 'hidden'
|
||||
|
||||
Reference in New Issue
Block a user