Private
Public Access
1
0

fixed access to teams

This commit is contained in:
Sander Roosendaal
2019-08-29 07:59:13 +02:00
parent 3357a06d4a
commit b6a1a7646b

View File

@@ -15,12 +15,17 @@ def team_view(request,id=0,userid=0):
myteams, memberteams, otherteams = get_teams(request)
teams.remove_expired_invites()
try:
t = Team.objects.get(id=id)
except Team.DoesNotExist:
raise Http404("Team doesn't exist")
if r.rowerplan == 'basic' and t.manager.rower.rowerplan != 'coach':
raise PermissionDenied("You need to be on a Paid Plan to see or join this team")
q = User.objects.filter(rower__isnull=False,rower__team__in=myteams).distinct().exclude(rower__team__name=t.name)
mygroups = [request.user.rower.mycoachgroup]
q2 = User.objects.filter(rower__isnull=False,rower__coachinggroups__in=mygroups).distinct().exclude(rower__team__name=t.name)
@@ -168,8 +173,8 @@ def get_teams(request):
private='open').exclude(
rower=r).exclude(manager=request.user).order_by('name')
if rower.rowerplan == 'basic':
otherteams.exclude(manager__rower__rowerplan='freecoach')
if r.rowerplan == 'basic':
otherteams = otherteams.filter(manager__rower__rowerplan='coach')
return myteams, memberteams, otherteams