fixed RQ issue - bg tasks now working on linux notebook
This commit is contained in:
@@ -171,9 +171,17 @@ def update_subscription(rower,data,method='up'):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if rower.paidplan != 'coach':
|
if rower.paidplan != 'coach':
|
||||||
coachees = Rower.objects.filter(coach__in=[rower]).distinct()
|
try:
|
||||||
for coachee in coachees:
|
coachgroup = coach.mycoachgroup
|
||||||
coachee.coaches.remove(rower)
|
except CoachingGroup.DoesNotExist:
|
||||||
|
coachgroup = CoachingGroup()
|
||||||
|
coachgroup.save()
|
||||||
|
rower.mycoachgroup = coachgroup
|
||||||
|
rower.save()
|
||||||
|
|
||||||
|
athletes = Rower.objects.filter(coachinggroups__in=[rower.mycoachgroup]).distinct()
|
||||||
|
for athlete in athletes:
|
||||||
|
athlete.coachinggroups.remove(rower.mycoachgroup)
|
||||||
|
|
||||||
if method == 'up':
|
if method == 'up':
|
||||||
transactions = result.subscription.transactions
|
transactions = result.subscription.transactions
|
||||||
|
|||||||
@@ -1705,7 +1705,7 @@ def handle_sendemail_coachrequest(email,name,code,coachname,
|
|||||||
|
|
||||||
fullemail = email
|
fullemail = email
|
||||||
subject = 'Invitation to add {n} to your athletes'.format(n=name)
|
subject = 'Invitation to add {n} to your athletes'.format(n=name)
|
||||||
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||||
siteurl = SITE_URL
|
siteurl = SITE_URL
|
||||||
if debug:
|
if debug:
|
||||||
siteurl = SITE_URL_DEV
|
siteurl = SITE_URL_DEV
|
||||||
@@ -1731,7 +1731,7 @@ def handle_sendemail_coacheerequest(email,name,code,coachname,
|
|||||||
|
|
||||||
fullemail = email
|
fullemail = email
|
||||||
subject = '{n} asks coach access to your data on rowsandall.com'.format(n=coachname)
|
subject = '{n} asks coach access to your data on rowsandall.com'.format(n=coachname)
|
||||||
|
from_email = 'Rowsandall <info@rowsandall.com>'
|
||||||
siteurl = SITE_URL
|
siteurl = SITE_URL
|
||||||
if debug:
|
if debug:
|
||||||
siteurl = SITE_URL_DEV
|
siteurl = SITE_URL_DEV
|
||||||
|
|||||||
@@ -999,6 +999,107 @@ class PermissionsViewTests(TestCase):
|
|||||||
status_code=302,target_status_code=200)
|
status_code=302,target_status_code=200)
|
||||||
|
|
||||||
|
|
||||||
|
@override_settings(TESTING=True)
|
||||||
|
class PermissionsCoachingTests(TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
self.c = Client()
|
||||||
|
## Users - Pro, Basic, Coach & Self Coach
|
||||||
|
|
||||||
|
self.ucoach = UserFactory(username='coachuser')
|
||||||
|
self.rcoach = Rower.objects.create(user=self.ucoach,
|
||||||
|
birthdate=faker.profile()['birthdate'],
|
||||||
|
gdproptin=True,gdproptindate=timezone.now(),
|
||||||
|
rowerplan='coach')
|
||||||
|
|
||||||
|
self.ucoach_workouts = WorkoutFactory.create_batch(5, user=self.rcoach)
|
||||||
|
self.coachinggroup = CoachingGroup.objects.create()
|
||||||
|
self.rcoach.mycoachgroup = self.coachinggroup
|
||||||
|
self.rcoach.save()
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
self.password = faker.word()
|
||||||
|
self.ucoach.set_password(self.password)
|
||||||
|
self.ucoach.save()
|
||||||
|
|
||||||
|
self.uplan = UserFactory(username='planuser')
|
||||||
|
self.rplan = Rower.objects.create(user=self.uplan,
|
||||||
|
birthdate=faker.profile()['birthdate'],
|
||||||
|
gdproptin=True,gdproptindate=timezone.now(),
|
||||||
|
rowerplan='plan')
|
||||||
|
|
||||||
|
self.uplan_workouts = WorkoutFactory.create_batch(5, user=self.rplan)
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
self.password = faker.word()
|
||||||
|
self.uplan.set_password(self.password)
|
||||||
|
self.uplan.save()
|
||||||
|
|
||||||
|
self.upro = UserFactory(username='prouser')
|
||||||
|
self.rpro = Rower.objects.create(user=self.upro,
|
||||||
|
birthdate=faker.profile()['birthdate'],
|
||||||
|
gdproptin=True,gdproptindate=timezone.now(),
|
||||||
|
rowerplan='pro')
|
||||||
|
|
||||||
|
self.upro_workouts = WorkoutFactory.create_batch(5, user=self.rpro)
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
self.password = faker.word()
|
||||||
|
self.upro.set_password(self.password)
|
||||||
|
self.upro.save()
|
||||||
|
|
||||||
|
self.uplan2 = UserFactory(username='planuser2')
|
||||||
|
self.rplan2 = Rower.objects.create(user=self.uplan2,
|
||||||
|
birthdate=faker.profile()['birthdate'],
|
||||||
|
gdproptin=True,gdproptindate=timezone.now(),
|
||||||
|
rowerplan='plan')
|
||||||
|
|
||||||
|
self.uplan2_workouts = WorkoutFactory.create_batch(5, user=self.rplan2)
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
self.password = faker.word()
|
||||||
|
self.uplan2.set_password(self.password)
|
||||||
|
self.uplan2.save()
|
||||||
|
|
||||||
|
self.upro2 = UserFactory(username='prouser2')
|
||||||
|
self.rpro2 = Rower.objects.create(user=self.upro2,
|
||||||
|
birthdate=faker.profile()['birthdate'],
|
||||||
|
gdproptin=True,gdproptindate=timezone.now(),
|
||||||
|
rowerplan='pro')
|
||||||
|
|
||||||
|
self.upro2_workouts = WorkoutFactory.create_batch(5, user=self.rpro2)
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
self.password = faker.word()
|
||||||
|
self.upro2.set_password(self.password)
|
||||||
|
self.upro2.save()
|
||||||
|
|
||||||
|
self.ubasic = UserFactory(username='basicuser')
|
||||||
|
self.rbasic = Rower.objects.create(user=self.ubasic,
|
||||||
|
birthdate=faker.profile()['birthdate'],
|
||||||
|
gdproptin=True,gdproptindate=timezone.now(),
|
||||||
|
rowerplan='basic')
|
||||||
|
|
||||||
|
self.ubasic_workouts = WorkoutFactory.create_batch(5, user=self.rbasic)
|
||||||
|
self.factory = RequestFactory()
|
||||||
|
self.password = faker.word()
|
||||||
|
self.ubasic.set_password(self.password)
|
||||||
|
self.ubasic.save()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## TeamPro, TeamCoach, TeamSelfCoach
|
||||||
|
|
||||||
|
self.teampro = Team.objects.create(
|
||||||
|
name=faker.word()+'1',
|
||||||
|
notes=faker.text(),
|
||||||
|
manager=self.upro2)
|
||||||
|
|
||||||
|
self.teamplan = Team.objects.create(
|
||||||
|
name=faker.word()+'2',
|
||||||
|
notes=faker.text(),
|
||||||
|
manager=self.uplan2)
|
||||||
|
|
||||||
|
self.teamcoach = Team.objects.create(
|
||||||
|
name=faker.word()+'3',
|
||||||
|
notes=faker.text(),
|
||||||
|
manager=self.ucoach)
|
||||||
|
|
||||||
|
|
||||||
# coach related
|
# coach related
|
||||||
|
|
||||||
## coach disappears from list when downgrading
|
## coach disappears from list when downgrading
|
||||||
|
|||||||
BIN
rowers/tests/testdata/testdata.csv.gz
vendored
BIN
rowers/tests/testdata/testdata.csv.gz
vendored
Binary file not shown.
@@ -298,11 +298,14 @@ def myqueue(queue,function,*args,**kwargs):
|
|||||||
if settings.TESTING:
|
if settings.TESTING:
|
||||||
return MockJob()
|
return MockJob()
|
||||||
|
|
||||||
if settings.DEBUG:
|
if settings.CELERY:
|
||||||
kwargs['debug'] = True
|
kwargs['debug'] = True
|
||||||
|
|
||||||
job = function.delay(*args,**kwargs)
|
job = function.delay(*args,**kwargs)
|
||||||
else:
|
else:
|
||||||
|
if settings.DEBUG:
|
||||||
|
kwargs['debug'] = True
|
||||||
|
|
||||||
job_id = str(uuid.uuid4())
|
job_id = str(uuid.uuid4())
|
||||||
kwargs['job_id'] = job_id
|
kwargs['job_id'] = job_id
|
||||||
kwargs['jobkey'] = job_id
|
kwargs['jobkey'] = job_id
|
||||||
|
|||||||
@@ -467,3 +467,9 @@ try:
|
|||||||
OPAQUE_SECRET_KEY = CFG['opaque_secret_key']
|
OPAQUE_SECRET_KEY = CFG['opaque_secret_key']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
OPAQUE_SECRET_KEY = 0xa193443a
|
OPAQUE_SECRET_KEY = 0xa193443a
|
||||||
|
|
||||||
|
# Celery or RQ
|
||||||
|
try:
|
||||||
|
CELERY = CFG['use_celery']
|
||||||
|
except KeyError:
|
||||||
|
CELERY = False
|
||||||
|
|||||||
Reference in New Issue
Block a user