Private
Public Access
1
0

fixed RQ issue - bg tasks now working on linux notebook

This commit is contained in:
Sander Roosendaal
2019-02-17 14:30:29 +01:00
parent 158a1e7956
commit f70b1a7ce5
6 changed files with 124 additions and 6 deletions

View File

@@ -171,9 +171,17 @@ def update_subscription(rower,data,method='up'):
)
if rower.paidplan != 'coach':
coachees = Rower.objects.filter(coach__in=[rower]).distinct()
for coachee in coachees:
coachee.coaches.remove(rower)
try:
coachgroup = coach.mycoachgroup
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':
transactions = result.subscription.transactions

View File

@@ -1705,7 +1705,7 @@ def handle_sendemail_coachrequest(email,name,code,coachname,
fullemail = email
subject = 'Invitation to add {n} to your athletes'.format(n=name)
from_email = 'Rowsandall <info@rowsandall.com>'
siteurl = SITE_URL
if debug:
siteurl = SITE_URL_DEV
@@ -1731,7 +1731,7 @@ def handle_sendemail_coacheerequest(email,name,code,coachname,
fullemail = email
subject = '{n} asks coach access to your data on rowsandall.com'.format(n=coachname)
from_email = 'Rowsandall <info@rowsandall.com>'
siteurl = SITE_URL
if debug:
siteurl = SITE_URL_DEV

View File

@@ -999,6 +999,107 @@ class PermissionsViewTests(TestCase):
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 disappears from list when downgrading

Binary file not shown.

View File

@@ -298,11 +298,14 @@ def myqueue(queue,function,*args,**kwargs):
if settings.TESTING:
return MockJob()
if settings.DEBUG:
if settings.CELERY:
kwargs['debug'] = True
job = function.delay(*args,**kwargs)
else:
if settings.DEBUG:
kwargs['debug'] = True
job_id = str(uuid.uuid4())
kwargs['job_id'] = job_id
kwargs['jobkey'] = job_id

View File

@@ -467,3 +467,9 @@ try:
OPAQUE_SECRET_KEY = CFG['opaque_secret_key']
except KeyError:
OPAQUE_SECRET_KEY = 0xa193443a
# Celery or RQ
try:
CELERY = CFG['use_celery']
except KeyError:
CELERY = False