team permission checks now let staff in
This commit is contained in:
parent
eb2382d3ac
commit
7de1763de0
1 changed files with 8 additions and 4 deletions
|
@ -17,6 +17,8 @@ def can_join(team, user):
|
|||
return True
|
||||
elif team.access == "invitation" and state is "invited":
|
||||
return True
|
||||
elif user.is_staff and state is None:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
@ -33,6 +35,8 @@ def can_apply(team, user):
|
|||
state = team.get_state_for_user(user)
|
||||
if team.access == "application" and state is None:
|
||||
return True
|
||||
elif user.is_staff and state is None:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
|
@ -44,7 +48,7 @@ def can_apply(team, user):
|
|||
def team_detail(request, slug):
|
||||
team = get_object_or_404(Team, slug=slug)
|
||||
state = team.get_state_for_user(request.user)
|
||||
if team.access == "invitation" and state is None:
|
||||
if team.access == "invitation" and state is None and request.user.is_staff:
|
||||
raise Http404()
|
||||
|
||||
return render(request, "teams/team_detail.html", {
|
||||
|
@ -60,7 +64,7 @@ def team_detail(request, slug):
|
|||
def team_join(request, slug):
|
||||
team = get_object_or_404(Team, slug=slug)
|
||||
state = team.get_state_for_user(request.user)
|
||||
if team.access == "invitation" and state is None:
|
||||
if team.access == "invitation" and state is None and request.user.is_staff:
|
||||
raise Http404()
|
||||
|
||||
if can_join(team, request.user) and request.method == "POST":
|
||||
|
@ -77,7 +81,7 @@ def team_join(request, slug):
|
|||
def team_leave(request, slug):
|
||||
team = get_object_or_404(Team, slug=slug)
|
||||
state = team.get_state_for_user(request.user)
|
||||
if team.access == "invitation" and state is None:
|
||||
if team.access == "invitation" and state is None and request.user.is_staff:
|
||||
raise Http404()
|
||||
|
||||
if can_leave(team, request.user) and request.method == "POST":
|
||||
|
@ -93,7 +97,7 @@ def team_leave(request, slug):
|
|||
def team_apply(request, slug):
|
||||
team = get_object_or_404(Team, slug=slug)
|
||||
state = team.get_state_for_user(request.user)
|
||||
if team.access == "invitation" and state is None:
|
||||
if team.access == "invitation" and state is None and request.user.is_staff:
|
||||
raise Http404()
|
||||
|
||||
if can_apply(team, request.user) and request.method == "POST":
|
||||
|
|
Loading…
Reference in a new issue