Private
Public Access
1
0

Merge branch 'release/v9.94'

This commit is contained in:
Sander Roosendaal
2019-05-22 15:15:17 +02:00
4 changed files with 109 additions and 14 deletions
+1 -1
View File
@@ -629,7 +629,7 @@ def process_invite_code(user,code):
send_invite_accept_email(invitation) send_invite_accept_email(invitation)
invitation.delete() invitation.delete()
return result return (result,'You were added to the team')
def remove_expired_invites(): def remove_expired_invites():
issuedate = timezone.now()-timedelta(days=inviteduration) issuedate = timezone.now()-timedelta(days=inviteduration)
+3 -2
View File
@@ -39,8 +39,9 @@
// Check to see if the checkbox is checked. // Check to see if the checkbox is checked.
// If it is, show the fields and populate the input. // If it is, show the fields and populate the input.
// If not, hide the fields. // If not, hide the fields.
var Value = modality.val(); var Value = modality.val();
if (Value=='water') { var otwtypes = ['water','coastal','c-boat','churchboat']
if (otwtypes.includes(Value)) {
// Show the hidden fields. // Show the hidden fields.
hidden.show(); hidden.show();
} else { } else {
+93
View File
@@ -637,3 +637,96 @@ class HistoTest(TestCase):
response = self.c.get('/rowers/histodata/') response = self.c.get('/rowers/histodata/')
self.assertEqual(response.status_code,200) self.assertEqual(response.status_code,200)
#--------------------------------------------------
class WorkoutCompareTestNew(TestCase):
def setUp(self):
self.u = UserFactory()
self.r = Rower.objects.create(user=self.u,
birthdate=faker.profile()['birthdate'],
gdproptin=True,
gdproptindate=timezone.now(),
rowerplan='coach')
self.c = Client()
self.user_workouts = WorkoutFactory.create_batch(5, user=self.r)
self.factory = RequestFactory()
self.password = faker.word()
self.u.set_password(self.password)
self.u.save()
def tearDown(self):
for workout in self.user_workouts:
try:
os.remove(workout.csvfilename)
except (IOError, FileNotFoundError, OSError):
pass
@patch('rowers.dataprep.create_engine')
@patch('rowers.dataprep.getsmallrowdata_db')
def test_workouts_compare(self, mocked_sqlalchemy,
mocked_getsmallrowdata_db):
login = self.c.login(username=self.u.username, password=self.password)
self.assertTrue(login)
url = '/rowers/user-analysis-select/compare/'
response = self.c.get(url)
self.assertEqual(response.status_code,200)
@patch('rowers.dataprep.create_engine')
@patch('rowers.dataprep.getsmallrowdata_db', side_effect=mocked_getsmallrowdata_db)
def test_workouts_compare_submit(self, mocked_sqlalchemy,
mocked_getsmallrowdata_db):
login = self.c.login(username=self.u.username,password=self.password)
self.assertTrue(login)
startdate = (self.user_workouts[0].startdatetime-datetime.timedelta(days=3)).date()
enddate = (self.user_workouts[0].startdatetime+datetime.timedelta(days=3)).date()
form_data = {
'function':'compare',
'xparam':'hr',
'plotfield':'spm',
'yparam':'pace',
'groupby':'spm',
'palette':'monochrome_blue'
'xaxis':'time',
'yaxis1':'power',
'startdate':startdate,
'enddate':enddate,
'plottype':'scatter',
'spmmin':15,
'spmmax':55,
'workmin':0,
'workmax':1500,
'includereststrokes':False,
'modality':'all',
'waterboattype':['1x','2x','4x'],
'rankingonly':False,
'workouts':[1,2,3]
}
form = AnalysisChoiceForm(form_data)
optionsform = AnalysisOptionsForm(form_data)
dateform = DateRangeForm(form_data)
result = form.is_valid()
if not result:
print(form.errors)
self.assertTrue(form.is_valid())
self.assertTrue(optionsform.is_valid())
self.assertTrue(dateform.is_valid())
response = self.c.post('/rowers/user-analysis-select/',form_data)
self.assertEqual(response.status_code,200)
+12 -11
View File
@@ -54,6 +54,15 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0):
except KeyError: except KeyError:
workouttypes = ['rower','dynamic','slides'] workouttypes = ['rower','dynamic','slides']
try:
modalities = options['modalities']
modality = modalities[0]
except KeyError:
modalities = [m[0] for m in mytypes.workouttypes]
modality = 'all'
try: try:
rankingonly = options['rankingonly'] rankingonly = options['rankingonly']
except KeyError: except KeyError:
@@ -136,17 +145,6 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0):
'enddate':enddate, 'enddate':enddate,
}) })
if 'modalities' in request.session:
modalities = request.session['modalities']
if len(modalities) > 1:
modality = 'all'
else:
modality = modalities[0]
else:
modalities = [m[0] for m in mytypes.workouttypes]
modality = 'all'
negtypes = [] negtypes = []
@@ -168,6 +166,8 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0):
if b[0] not in waterboattype: if b[0] not in waterboattype:
negtypes.append(b[0]) negtypes.append(b[0])
if theteam is not None and (theteam.viewing == 'allmembers' or theteam.manager == request.user): if theteam is not None and (theteam.viewing == 'allmembers' or theteam.manager == request.user):
workouts = Workout.objects.filter(team=theteam, workouts = Workout.objects.filter(team=theteam,
startdatetime__gte=startdate, startdatetime__gte=startdate,
@@ -191,6 +191,7 @@ def analysis_new(request,userid=0,function='boxplot',teamid=0):
"-date", "-starttime" "-date", "-starttime"
).exclude(boattype__in=negtypes) ).exclude(boattype__in=negtypes)
if rankingonly: if rankingonly:
workouts = workouts.exclude(rankingpiece=False) workouts = workouts.exclude(rankingpiece=False)