fixifix
This commit is contained in:
@@ -2301,6 +2301,15 @@ class PlannedSession(models.Model):
|
|||||||
|
|
||||||
return stri
|
return stri
|
||||||
|
|
||||||
|
def update_json(self):
|
||||||
|
# read file
|
||||||
|
if self.fitfile:
|
||||||
|
steps = steps_read_fit(settings.MEDIA_ROOT+'/'+self.fitfile.name)
|
||||||
|
self.steps_json = json.dumps(steps)
|
||||||
|
|
||||||
|
self.save()
|
||||||
|
|
||||||
|
|
||||||
def save(self, *args, **kwargs):
|
def save(self, *args, **kwargs):
|
||||||
if self.sessionvalue <= 0:
|
if self.sessionvalue <= 0:
|
||||||
self.sessionvalue = 1
|
self.sessionvalue = 1
|
||||||
@@ -2359,8 +2368,7 @@ class PlannedSession(models.Model):
|
|||||||
if self.preferreddate < self.startdate:
|
if self.preferreddate < self.startdate:
|
||||||
self.preferreddate = self.startdate
|
self.preferreddate = self.startdate
|
||||||
|
|
||||||
print(self.fitfile)
|
#super(PlannedSession,self).save(*args, **kwargs)
|
||||||
super(PlannedSession,self).save(*args, **kwargs)
|
|
||||||
|
|
||||||
# read file
|
# read file
|
||||||
if self.fitfile:
|
if self.fitfile:
|
||||||
@@ -2370,11 +2378,8 @@ class PlannedSession(models.Model):
|
|||||||
steps = steps_read_fit(settings.MEDIA_ROOT+'/'+self.fitfile.name)
|
steps = steps_read_fit(settings.MEDIA_ROOT+'/'+self.fitfile.name)
|
||||||
self.steps_json = json.dumps(steps)
|
self.steps_json = json.dumps(steps)
|
||||||
|
|
||||||
try:
|
|
||||||
super(PlannedSession,self).save(*args, **kwargs)
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
super(PlannedSession,self).save(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
from django.core.validators import RegexValidator,validate_email
|
from django.core.validators import RegexValidator,validate_email
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ nu = datetime.datetime.now()
|
|||||||
from rowers.utils import allmonths,allsundays
|
from rowers.utils import allmonths,allsundays
|
||||||
|
|
||||||
import rowers.plannedsessions as plannedsessions
|
import rowers.plannedsessions as plannedsessions
|
||||||
|
from django.db import transaction
|
||||||
|
|
||||||
@override_settings(TESTING=True)
|
@override_settings(TESTING=True)
|
||||||
class TrainingPlanTest(TestCase):
|
class TrainingPlanTest(TestCase):
|
||||||
@@ -37,6 +38,7 @@ class TrainingPlanTest(TestCase):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def test_createplan(self):
|
def test_createplan(self):
|
||||||
|
with transaction.atomic():
|
||||||
login = self.c.login(username=self.u.username, password=self.password)
|
login = self.c.login(username=self.u.username, password=self.password)
|
||||||
self.assertTrue(login)
|
self.assertTrue(login)
|
||||||
|
|
||||||
@@ -132,6 +134,7 @@ class TrainingPlanTest(TestCase):
|
|||||||
|
|
||||||
# add test for creating new sessions
|
# add test for creating new sessions
|
||||||
def test_sessions_create(self):
|
def test_sessions_create(self):
|
||||||
|
with transaction.atomic():
|
||||||
|
|
||||||
login = self.c.login(username=self.u.username, password=self.password)
|
login = self.c.login(username=self.u.username, password=self.password)
|
||||||
self.assertTrue(login)
|
self.assertTrue(login)
|
||||||
@@ -220,6 +223,7 @@ class SessionLinkTest(TestCase):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def test_plannedsessions(self):
|
def test_plannedsessions(self):
|
||||||
|
with transaction.atomic():
|
||||||
login = self.c.login(username=self.u.username, password=self.password)
|
login = self.c.login(username=self.u.username, password=self.password)
|
||||||
self.assertTrue(login)
|
self.assertTrue(login)
|
||||||
|
|
||||||
@@ -303,6 +307,7 @@ class SessionLinkTest(TestCase):
|
|||||||
self.assertEqual(response.status_code,200)
|
self.assertEqual(response.status_code,200)
|
||||||
|
|
||||||
def test_multiplesessions(self):
|
def test_multiplesessions(self):
|
||||||
|
with transaction.atomic():
|
||||||
login = self.c.login(username=self.u.username, password=self.password)
|
login = self.c.login(username=self.u.username, password=self.password)
|
||||||
self.assertTrue(login)
|
self.assertTrue(login)
|
||||||
|
|
||||||
@@ -456,7 +461,7 @@ class SessionCompleteTest(TestCase):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def test_session1_complete(self):
|
def test_session1_complete(self):
|
||||||
|
with transaction.atomic():
|
||||||
result = plannedsessions.add_workouts_plannedsession(
|
result = plannedsessions.add_workouts_plannedsession(
|
||||||
[self.w1],self.ps_rscore,self.r
|
[self.w1],self.ps_rscore,self.r
|
||||||
)
|
)
|
||||||
@@ -499,6 +504,7 @@ class SessionCompleteTest(TestCase):
|
|||||||
self.assertEqual(verdict,'on target')
|
self.assertEqual(verdict,'on target')
|
||||||
|
|
||||||
def test_session_comment(self):
|
def test_session_comment(self):
|
||||||
|
with transaction.atomic():
|
||||||
login = self.c.login(username=self.u.username, password=self.password)
|
login = self.c.login(username=self.u.username, password=self.password)
|
||||||
self.assertTrue(login)
|
self.assertTrue(login)
|
||||||
|
|
||||||
@@ -520,6 +526,7 @@ class SessionCompleteTest(TestCase):
|
|||||||
|
|
||||||
|
|
||||||
def test_session1_exact_complete(self):
|
def test_session1_exact_complete(self):
|
||||||
|
with transaction.atomic():
|
||||||
self.ps_rscore.criterium = 'exact'
|
self.ps_rscore.criterium = 'exact'
|
||||||
self.ps_rscore.save()
|
self.ps_rscore.save()
|
||||||
|
|
||||||
@@ -711,7 +718,7 @@ class ChallengeCompleteTest(TestCase):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def test_challenge1_complete(self):
|
def test_challenge1_complete(self):
|
||||||
|
with transaction.atomic():
|
||||||
result = plannedsessions.add_workouts_plannedsession(
|
result = plannedsessions.add_workouts_plannedsession(
|
||||||
[self.w1],self.ps_rscore,self.r
|
[self.w1],self.ps_rscore,self.r
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -468,11 +468,11 @@ def plannedsession_create_view(request,
|
|||||||
|
|
||||||
ps.save()
|
ps.save()
|
||||||
|
|
||||||
#if sessioncreateform.cleaned_data['fitfile']:
|
if sessioncreateform.cleaned_data['fitfile']:
|
||||||
# f = sessioncreateform.cleaned_data['fitfile']
|
f = sessioncreateform.cleaned_data['fitfile']
|
||||||
# filename, path_and_filename = handle_uploaded_file(f)
|
filename, path_and_filename = handle_uploaded_file(f)
|
||||||
# ps.fitfile.name = filename
|
ps.fitfile.name = filename
|
||||||
# ps.save()
|
ps.save()
|
||||||
|
|
||||||
add_rower_session(r,ps)
|
add_rower_session(r,ps)
|
||||||
|
|
||||||
@@ -790,6 +790,11 @@ def plannedsession_teamcreate_view(request,
|
|||||||
manager=request.user)
|
manager=request.user)
|
||||||
|
|
||||||
ps.save()
|
ps.save()
|
||||||
|
if fitfile:
|
||||||
|
f = sessioncreateform.cleaned_data['fitfile']
|
||||||
|
filename, path_and_filename = handle_uploaded_file(f)
|
||||||
|
ps.fitfile.name = filename
|
||||||
|
ps.save()
|
||||||
|
|
||||||
cd = sessionteamselectform.cleaned_data
|
cd = sessionteamselectform.cleaned_data
|
||||||
teams = cd['team']
|
teams = cd['team']
|
||||||
|
|||||||
Reference in New Issue
Block a user