making pass tests
This commit is contained in:
@@ -949,7 +949,7 @@ def check_teams_on_change(sender, **kwargs):
|
||||
#if instance.protrialexpires < datetime.date.today() and instance.plantrialexpires < datetime.date.today():
|
||||
for id in pk_set:
|
||||
team = Team.objects.get(id=id)
|
||||
if not can_join_team(instance,team):
|
||||
if not can_join_team(instance.user,team):
|
||||
raise ValidationError(
|
||||
"You cannot join a team led by a Pro, Free Coach Plan or Self-Coach user"
|
||||
)
|
||||
|
||||
@@ -124,7 +124,7 @@ def is_protrial(user):
|
||||
|
||||
ispromember = is_promember | is_protrial
|
||||
|
||||
can_have_teams = ispromember
|
||||
can_have_teams = ispromember | is_coach
|
||||
|
||||
@rules.predicate
|
||||
def can_add_team(user):
|
||||
|
||||
@@ -1112,21 +1112,22 @@ class PermissionsViewTests(TestCase):
|
||||
## Pro cannot run analytics on behalf of athlete
|
||||
@patch('rowers.dataprep.read_cols_df_sql', side_effect = mocked_read_df_cols_sql_multistats)
|
||||
def test_pro_edit_athlete_analysis(self,mocked_df):
|
||||
self.rpro.team.add(self.teampro)
|
||||
with transaction.atomic():
|
||||
self.rpro.team.add(self.teampro)
|
||||
|
||||
login = self.c.login(username=self.upro2.username, password=self.upro2password)
|
||||
self.assertTrue(login)
|
||||
login = self.c.login(username=self.upro2.username, password=self.upro2password)
|
||||
self.assertTrue(login)
|
||||
|
||||
|
||||
url = reverse('cumstats',
|
||||
kwargs={
|
||||
'theuser':self.ubasic.id,
|
||||
}
|
||||
)
|
||||
url = reverse('cumstats',
|
||||
kwargs={
|
||||
'theuser':self.ubasic.id,
|
||||
}
|
||||
)
|
||||
|
||||
response = self.c.get(url)
|
||||
response = self.c.get(url)
|
||||
|
||||
self.assertEqual(response.status_code,403)
|
||||
self.assertEqual(response.status_code,403)
|
||||
|
||||
## Self Coach cannot upload on behalf of athlete
|
||||
@patch('rowers.dataprep.create_engine')
|
||||
|
||||
@@ -4877,7 +4877,7 @@ def team_workout_upload_view(request,message="",
|
||||
workouttype = form.cleaned_data['workouttype']
|
||||
if rowerform.is_valid():
|
||||
u = rowerform.cleaned_data['user']
|
||||
if can_add_workout_member(user,u.rower):
|
||||
if can_add_workout_member(request.user,u.rower):
|
||||
r = getrower(u)
|
||||
else:
|
||||
message = 'Please select a rower'
|
||||
|
||||
Reference in New Issue
Block a user