all the plumbing to let people select, drop, offer, coaching
This commit is contained in:
@@ -635,6 +635,12 @@ class PaidPlan(models.Model):
|
|||||||
class CoachingGroup(models.Model):
|
class CoachingGroup(models.Model):
|
||||||
name = models.CharField(default='group',max_length=30,null=True,blank=True)
|
name = models.CharField(default='group',max_length=30,null=True,blank=True)
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return 'Coaching Group {id}: {name}'.format(
|
||||||
|
id = self.pk,
|
||||||
|
name = self.name
|
||||||
|
)
|
||||||
|
|
||||||
# Extension of User with rowing specific data
|
# Extension of User with rowing specific data
|
||||||
class Rower(models.Model):
|
class Rower(models.Model):
|
||||||
adaptivetypes = mytypes.adaptivetypes
|
adaptivetypes = mytypes.adaptivetypes
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ def coach_remove_athlete(coach,rower):
|
|||||||
coach.mycoachgroup = coachgroup
|
coach.mycoachgroup = coachgroup
|
||||||
coach.save()
|
coach.save()
|
||||||
|
|
||||||
rower.coachingrgroups.remove(coachgroup)
|
rower.coachinggroups.remove(coachgroup)
|
||||||
|
|
||||||
return (1,'Coach removed')
|
return (1,'Coach removed')
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<p>Dear <strong>{{ name }}</strong>,</p>
|
<p>Dear <strong>{{ name }}</strong>,</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
{{ coachname }} is inviting you to become your coach on rowsandall.com.
|
{{ coachname }} is offering to become your coach on rowsandall.com.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
By accepting the invite, {{ coachname }} will have access to your
|
By accepting the invite, {{ coachname }} will have access to your
|
||||||
@@ -22,8 +22,8 @@
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
You can also click the direct link:
|
You can also click the direct link:
|
||||||
<a href="{{ siteurl }}/rowers/me/coacheeinvitation/{{ code }}">
|
<a href="{{ siteurl }}/rowers/me/coachoffer/{{ code }}/accept/">
|
||||||
{{ siteurl }}/rowers/me/coacheeinvitation/{{ code }}</a>
|
{{ siteurl }}/rowers/me/coachoffer/{{ code }}/accept</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
You can also click the direct link:
|
You can also click the direct link:
|
||||||
<a href="{{ siteurl }}/rowers/me/coachinvitation/{{ code }}">
|
<a href="{{ siteurl }}/rowers/me/coachrequest/{{ code }}/accept/">
|
||||||
{{ siteurl }}/rowers/me/coachinvitation/{{ code }}</a>
|
{{ siteurl }}/rowers/me/coachrequest/{{ code }}/accept/</a>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
33
rowers/templates/dropathleteconfirm.html
Normal file
33
rowers/templates/dropathleteconfirm.html
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
{% extends "newbase.html" %}
|
||||||
|
{% load staticfiles %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
|
||||||
|
{% block title %}Remove Athlete {% endblock %}
|
||||||
|
|
||||||
|
{% block main %}
|
||||||
|
<h1>Confirm removing {{ athlete.user.first_name }} {{ athlete.user.last_name }}</h1>
|
||||||
|
|
||||||
|
<ul class="main-content">
|
||||||
|
<li class="grid_2">
|
||||||
|
<p>This will remove this rower from your list of athlete. The athlete can still
|
||||||
|
be in one of your training groups, but you cannot upload workouts, run analysis
|
||||||
|
or edit settings on their behalf.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a class="button green small" href="/rowers/me/teams">Cancel</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a class="button red small" href="/rowers/coaches/{{ athlete.id }}/drop">Drop Athlete</a>
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block sidebar %}
|
||||||
|
{% include 'menu_teams.html' %}
|
||||||
|
{% endblock %}
|
||||||
35
rowers/templates/dropcoachconfirm.html
Normal file
35
rowers/templates/dropcoachconfirm.html
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
{% extends "newbase.html" %}
|
||||||
|
{% load staticfiles %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
|
||||||
|
{% block title %}Remove Coach {% endblock %}
|
||||||
|
|
||||||
|
{% block main %}
|
||||||
|
<h1>Confirm removing {{ coach.user.first_name }} {{ coach.user.last_name }}</h1>
|
||||||
|
|
||||||
|
<ul class="main-content">
|
||||||
|
<li class="grid_2">
|
||||||
|
<p>This will remove this coach from your list of coaches.
|
||||||
|
You can still be in this coach's training groups, but she/he is losing the ability to
|
||||||
|
upload workouts for you, run analysis
|
||||||
|
or edit your settings on your behalf.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a class="button green small" href="/rowers/me/teams">Cancel</a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<a class="button red small" href="/rowers/coaches/{{ coach.id }}/dropcoach">Drop Coach
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block sidebar %}
|
||||||
|
{% include 'menu_teams.html' %}
|
||||||
|
{% endblock %}
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
{% block main %}
|
{% block main %}
|
||||||
<ul class="main-content">
|
<ul class="main-content">
|
||||||
{% if teams %}
|
{% if teams %}
|
||||||
<li >
|
<li class="grid_2">
|
||||||
<h2>My Groups</h2>
|
<h2>My Groups</h2>
|
||||||
<table width="100%" class="listtable">
|
<table width="100%" class="listtable">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if otherteams %}
|
{% if otherteams %}
|
||||||
<li >
|
<li class="grid_2">
|
||||||
<h2>Open Groups</h2>
|
<h2>Open Groups</h2>
|
||||||
<table width="100%" class="listtable">
|
<table width="100%" class="listtable">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -56,7 +56,7 @@
|
|||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<li >
|
<li class="grid_2">
|
||||||
<h2>Groups I manage</h2>
|
<h2>Groups I manage</h2>
|
||||||
{% if myteams %}
|
{% if myteams %}
|
||||||
<table width="100%" class="listtable">
|
<table width="100%" class="listtable">
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
<a class="button green" href="/rowers/team/create/">New Training Group</a>
|
<a class="button green" href="/rowers/team/create/">New Training Group</a>
|
||||||
</li>
|
</li>
|
||||||
{% if coaches %}
|
{% if coaches %}
|
||||||
<li>
|
<li class="grid_2">
|
||||||
<h2>My Coaches</h2>
|
<h2>My Coaches</h2>
|
||||||
<table width="100%" class="listtable">
|
<table width="100%" class="listtable">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a class="button small red"
|
<a class="button small red"
|
||||||
href="/rowers/coaches/{{ coach.id }}/dropconfirm/">Remove
|
href="/rowers/coaches/{{ coach.id }}/dropcoachconfirm/">Remove
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -109,7 +109,7 @@
|
|||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if coachees %}
|
{% if coachees %}
|
||||||
<li>
|
<li class="grid_2">
|
||||||
<h2>My Rowers</h2>
|
<h2>My Rowers</h2>
|
||||||
<table width="100%" class="listtable">
|
<table width="100%" class="listtable">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -125,7 +125,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<a class="button small red"
|
<a class="button small red"
|
||||||
href="/rowers/coaches/{{ coach.id }}/dropconfirm/">Remove
|
href="/rowers/coaches/{{ coachee.id }}/dropconfirm/">Remove
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -297,7 +297,7 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
{% if potentialathletes %}
|
{% if potentialathletes %}
|
||||||
<li>
|
<li class="grid_2">
|
||||||
<h2>Rowers you could coach</h2>
|
<h2>Rowers you could coach</h2>
|
||||||
<table width="90%" class="listtable">
|
<table width="90%" class="listtable">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -322,7 +322,7 @@
|
|||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if potentialcoaches %}
|
{% if potentialcoaches %}
|
||||||
<li>
|
<li class="grid_2">
|
||||||
<h2>Coaches who could coach you</h2>
|
<h2>Coaches who could coach you</h2>
|
||||||
<table width="90%" class="listtable">
|
<table width="90%" class="listtable">
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
BIN
rowers/tests/testdata/testdata.csv.gz
vendored
BIN
rowers/tests/testdata/testdata.csv.gz
vendored
Binary file not shown.
@@ -412,6 +412,14 @@ urlpatterns = [
|
|||||||
url(r'^team/(?P<teamid>\d+)/requestmembership/(?P<userid>\d+)/$',views.team_requestmembership_view,name='team_requestmembership_view'),
|
url(r'^team/(?P<teamid>\d+)/requestmembership/(?P<userid>\d+)/$',views.team_requestmembership_view,name='team_requestmembership_view'),
|
||||||
url(r'^me/coachrequest/(?P<id>\d+)/reject/$',views.reject_revoke_coach_request,
|
url(r'^me/coachrequest/(?P<id>\d+)/reject/$',views.reject_revoke_coach_request,
|
||||||
name='reject_revoke_coach_request'),
|
name='reject_revoke_coach_request'),
|
||||||
|
url(r'^coaches/(?P<id>\d+)/dropconfirm/$',views.coach_drop_athlete_confirm_view,
|
||||||
|
name='coach_drop_athlete_confirm_view'),
|
||||||
|
url(r'^coaches/(?P<id>\d+)/drop/$',views.coach_drop_athlete_view,
|
||||||
|
name='coach_drop_athlete_view'),
|
||||||
|
url(r'^coaches/(?P<id>\d+)/dropcoachconfirm/$',views.athlete_drop_coach_confirm_view,
|
||||||
|
name='athlete_drop_coach_confirm_view'),
|
||||||
|
url(r'^coaches/(?P<id>\d+)/dropcoach/$',views.athlete_drop_coach_view,
|
||||||
|
name='athlete_drop_coach_view'),
|
||||||
url(r'^me/coachrequest/(?P<id>\d+)/revoke/$',views.reject_revoke_coach_request,
|
url(r'^me/coachrequest/(?P<id>\d+)/revoke/$',views.reject_revoke_coach_request,
|
||||||
name='reject_revoke_coach_request'),
|
name='reject_revoke_coach_request'),
|
||||||
url(r'^me/coachoffer/(?P<id>\d+)/reject/$',views.reject_revoke_coach_offer,
|
url(r'^me/coachoffer/(?P<id>\d+)/reject/$',views.reject_revoke_coach_offer,
|
||||||
|
|||||||
@@ -279,6 +279,101 @@ def manager_requests_view(request,code=None,message='',successmessage=''):
|
|||||||
})
|
})
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
@login_required()
|
||||||
|
def athlete_drop_coach_confirm_view(request,id):
|
||||||
|
r = getrower(request.user)
|
||||||
|
try:
|
||||||
|
coach = Rower.objects.get(id=id)
|
||||||
|
except Rower.DoesNotExist:
|
||||||
|
raise Http404("This rower doesn't exist")
|
||||||
|
if coach not in teams.rower_get_coaches(r):
|
||||||
|
raise PermissionDenied("You are not allowed to do this")
|
||||||
|
|
||||||
|
breadcrumbs = [
|
||||||
|
{
|
||||||
|
'url':reverse('rower_teams_view'),
|
||||||
|
'name': 'Teams'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'url':reverse('athlete_drop_coach_confirm_view',kwargs={'id':id}),
|
||||||
|
'name': 'Confirm drop athlete'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
return render(request,'dropcoachconfirm.html',
|
||||||
|
{
|
||||||
|
'rower':r,
|
||||||
|
'coach':coach
|
||||||
|
})
|
||||||
|
|
||||||
|
@login_required()
|
||||||
|
def coach_drop_athlete_confirm_view(request,id):
|
||||||
|
r = getrower(request.user)
|
||||||
|
try:
|
||||||
|
rower = Rower.objects.get(id=id)
|
||||||
|
except Rower.DoesNotExist:
|
||||||
|
raise Http404("This rower doesn't exist")
|
||||||
|
if rower not in teams.coach_getcoachees(r):
|
||||||
|
raise PermissionDenied("You are not allowed to do this")
|
||||||
|
|
||||||
|
breadcrumbs = [
|
||||||
|
{
|
||||||
|
'url':reverse('rower_teams_view'),
|
||||||
|
'name': 'Teams'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'url':reverse('coach_drop_athlete_confirm_view',kwargs={'id':id}),
|
||||||
|
'name': 'Confirm drop athlete'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
return render(request,'dropathleteconfirm.html',
|
||||||
|
{
|
||||||
|
'rower':r,
|
||||||
|
'athlete':rower
|
||||||
|
})
|
||||||
|
|
||||||
|
@login_required()
|
||||||
|
def coach_drop_athlete_view(request,id):
|
||||||
|
r = getrower(request.user)
|
||||||
|
try:
|
||||||
|
rower = Rower.objects.get(id=id)
|
||||||
|
except Rower.DoesNotExist:
|
||||||
|
raise Http404("This rower doesn't exist")
|
||||||
|
if rower not in teams.coach_getcoachees(r):
|
||||||
|
raise PermissionDenied("You are not allowed to do this")
|
||||||
|
|
||||||
|
res,text = teams.coach_remove_athlete(r,rower)
|
||||||
|
|
||||||
|
if res:
|
||||||
|
messages.info(request,'You are not coaching this athlete any more')
|
||||||
|
else:
|
||||||
|
messages.error(request,'There was an error dropping the athlete from your list')
|
||||||
|
|
||||||
|
url = reverse('rower_teams_view')
|
||||||
|
|
||||||
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
@login_required()
|
||||||
|
def athlete_drop_coach_view(request,id):
|
||||||
|
r = getrower(request.user)
|
||||||
|
try:
|
||||||
|
coach = Rower.objects.get(id=id)
|
||||||
|
except Rower.DoesNotExist:
|
||||||
|
raise Http404("This coach doesn't exist")
|
||||||
|
if coach not in teams.rower_get_coaches(r):
|
||||||
|
raise PermissionDenied("You are not allowed to do this")
|
||||||
|
|
||||||
|
res,text = teams.coach_remove_athlete(coach,r)
|
||||||
|
|
||||||
|
if res:
|
||||||
|
messages.info(request,'Removal successful')
|
||||||
|
else:
|
||||||
|
messages.error(request,'There was an error dropping the coach from your list')
|
||||||
|
|
||||||
|
url = reverse('rower_teams_view')
|
||||||
|
|
||||||
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
@login_required()
|
@login_required()
|
||||||
def team_requestmembership_view(request,teamid,userid):
|
def team_requestmembership_view(request,teamid,userid):
|
||||||
|
|||||||
@@ -227,7 +227,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<li id="nav-teams">
|
<li id="nav-teams">
|
||||||
<a href="/rowers/me/teams/">
|
<a href="/rowers/me/teams/">
|
||||||
<i class="fas fa-bullhorn"></i> Teams
|
<i class="fas fa-bullhorn"></i> Groups
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
Reference in New Issue
Block a user