Private
Public Access
1
0

fixing bug creating teams for trial users

This commit is contained in:
Sander Roosendaal
2020-04-06 09:46:59 +02:00
parent 47effe503e
commit 1b8185b2c7
6 changed files with 20 additions and 18 deletions

View File

@@ -750,7 +750,7 @@ def update_workout_field_sql(workoutid,fieldname,value,debug=False):
table = 'rowers_workout' table = 'rowers_workout'
query = "UPDATE %s SET %s = %s WHERE `id` = %s;" % (table,fieldname,value,workoutid) query = "UPDATE %s SET %s = %s WHERE `id` = %s;" % (table,fieldname,value,workoutid)
with engine.connect() as conn, conn.begin(): with engine.connect() as conn, conn.begin():
result = conn.execute(query) result = conn.execute(query)

View File

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

View File

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

View File

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

View File

@@ -106,8 +106,8 @@
<tr> <tr>
<td>Create and manage groups.</td> <td>Create and manage groups.</td>
<td>&nbsp;</td> <td>&nbsp;</td>
<td>&#10004;</td> <td>&#10004; (max 1)</td>
<td>&#10004;</td> <td>&#10004; (max 1)</td>
<td>&#10004;</td> <td>&#10004;</td>
<td>&#10004;</td> <td>&#10004;</td>
</tr> </tr>
@@ -311,17 +311,17 @@
<h2>Coach and Self-Coach Membership</h2> <h2>Coach and Self-Coach Membership</h2>
<p>Rowsandall.com's Training Planning functionality <p>Rowsandall.com's Training Planning functionality
is part of the paid "Self-Coach" and "Coach" plans.</p> is part of the paid "Self-Coach" and "Coach" plans.</p>
<p>On the "Self-Coach" plan, you can plan your own sessions.</p> <p>On the "Self-Coach" plan, you can plan your own sessions.</p>
<p>On the "Coach" plan, you can establish teams, see workouts done by <p>On the "Coach" plan, you can establish teams, see workouts done by
athletes on your team, and plan individual and group sessions for your athletes on your team, and plan individual and group sessions for your
athletes. athletes.
</p> </p>
<p>The Coach plan functionality listed is available to the coach only. <p>The Coach plan functionality listed is available to the coach only.
Individual athletes Individual athletes
can purchase upgrades to "Pro" and "Self-Coach" plans. can purchase upgrades to "Pro" and "Self-Coach" plans.
@@ -331,7 +331,7 @@
The Coach plans come in two versions: free and paid. On the free coach plan, The Coach plans come in two versions: free and paid. On the free coach plan,
you can only have athletes who are on the PRO paid plans or higher, and you you can only have athletes who are on the PRO paid plans or higher, and you
cannot upload any workouts to your own account. Some of the advanced Analysis functionality cannot upload any workouts to your own account. Some of the advanced Analysis functionality
becomes available when the athlete group is larger than 4. becomes available when the athlete group is larger than 4.
On the paid On the paid
plans, your athletes can be on the free plan, and you have full access to the plans, your athletes can be on the free plan, and you have full access to the
site functionality for your own workouts and those of your athletes. site functionality for your own workouts and those of your athletes.
@@ -363,7 +363,7 @@
<p>Do not hesitate to contact us at <a href="mailto:info@rowsandall.com">info@rowsandall.com</a> <p>Do not hesitate to contact us at <a href="mailto:info@rowsandall.com">info@rowsandall.com</a>
with any payment related question you have.</p> with any payment related question you have.</p>
</li> </li>
</ul> </ul>
@@ -372,4 +372,3 @@
{% block sidebar %} {% block sidebar %}
{% include 'menu_help.html' %} {% include 'menu_help.html' %}
{% endblock %} {% endblock %}

View File

@@ -651,7 +651,8 @@ def team_edit_view(request, team_id=0):
}) })
@login_required() @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): def team_create_view(request):
r = getrequestrower(request) r = getrequestrower(request)