Private
Public Access
1
0

Merge branch 'release/v12.06'

This commit is contained in:
Sander Roosendaal
2020-04-06 09:47:54 +02:00
6 changed files with 20 additions and 18 deletions

View File

@@ -363,6 +363,8 @@ class Team(models.Model):
"Basic user cannot be team manager"
)
if not self.id:
# new model instance
if not can_add_team(manager):
raise ValidationError(
"Pro and Self-Coach users cannot have more than one team"

View File

@@ -142,6 +142,7 @@ def is_protrial(user):
return False
ispromember = is_promember | is_protrial
can_have_teams = ispromember | is_coach
@@ -151,7 +152,7 @@ def can_add_team(user):
if is_coach(user):
return True
if ispromember(user):
if ispromember(user) or is_planmember(user):
otherteams = user.rower.get_managed_teams()
if otherteams.count() == 0:
return True
@@ -628,7 +629,7 @@ def is_team_member(user,team):
def can_view_team(user,team):
# user based - below untested
if user.rower.rowerplan == 'basic' and team.manager.rower.rowerplan != 'coach':
return False
return is_plantrial(user) or is_protrial(user)
# team is public
if team.private == 'open':
return True

View File

@@ -186,7 +186,6 @@ def handle_strava_sync(stravatoken,workoutid,filename,name,activity_type,descrip
except TypeError:
act = client.update_activity(res.id,activity_type=activity_type,
description=description)
result = update_workout_field_sql(workoutid,'uploadedtostrava',res.id,debug=debug)
try:
os.remove(filename)

View File

@@ -106,8 +106,8 @@
<tr>
<td>Create and manage groups.</td>
<td>&nbsp;</td>
<td>&#10004;</td>
<td>&#10004;</td>
<td>&#10004; (max 1)</td>
<td>&#10004; (max 1)</td>
<td>&#10004;</td>
<td>&#10004;</td>
</tr>
@@ -372,4 +372,3 @@
{% block sidebar %}
{% include 'menu_help.html' %}
{% endblock %}

View File

@@ -651,7 +651,8 @@ def team_edit_view(request, team_id=0):
})
@login_required()
@user_passes_test(can_add_team,login_url="/rowers/paidplans",redirect_field_name=None)
@user_passes_test(can_add_team,login_url="/rowers/paidplans",redirect_field_name=None,
message="You need to upgrade or log in to access this functionality")
def team_create_view(request):
r = getrequestrower(request)