Private
Public Access
1
0

all the plumbing to let people select, drop, offer, coaching

This commit is contained in:
Sander Roosendaal
2019-02-17 10:36:59 +01:00
parent 5f8fd9315a
commit c4523ea03e
11 changed files with 193 additions and 16 deletions

View File

@@ -634,6 +634,12 @@ class PaidPlan(models.Model):
class CoachingGroup(models.Model):
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
class Rower(models.Model):

View File

@@ -178,7 +178,7 @@ def coach_remove_athlete(coach,rower):
coach.mycoachgroup = coachgroup
coach.save()
rower.coachingrgroups.remove(coachgroup)
rower.coachinggroups.remove(coachgroup)
return (1,'Coach removed')

View File

@@ -4,7 +4,7 @@
<p>Dear <strong>{{ name }}</strong>,</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>
By accepting the invite, {{ coachname }} will have access to your
@@ -22,8 +22,8 @@
</p>
<p>
You can also click the direct link:
<a href="{{ siteurl }}/rowers/me/coacheeinvitation/{{ code }}">
{{ siteurl }}/rowers/me/coacheeinvitation/{{ code }}</a>
<a href="{{ siteurl }}/rowers/me/coachoffer/{{ code }}/accept/">
{{ siteurl }}/rowers/me/coachoffer/{{ code }}/accept</a>
</p>
<p>

View File

@@ -23,8 +23,8 @@
</p>
<p>
You can also click the direct link:
<a href="{{ siteurl }}/rowers/me/coachinvitation/{{ code }}">
{{ siteurl }}/rowers/me/coachinvitation/{{ code }}</a>
<a href="{{ siteurl }}/rowers/me/coachrequest/{{ code }}/accept/">
{{ siteurl }}/rowers/me/coachrequest/{{ code }}/accept/</a>
</p>
<p>

View 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 %}

View 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 %}

View File

@@ -5,7 +5,7 @@
{% block main %}
<ul class="main-content">
{% if teams %}
<li >
<li class="grid_2">
<h2>My Groups</h2>
<table width="100%" class="listtable">
<thead>
@@ -31,7 +31,7 @@
{% endif %}
{% if otherteams %}
<li >
<li class="grid_2">
<h2>Open Groups</h2>
<table width="100%" class="listtable">
<thead>
@@ -56,7 +56,7 @@
</li>
{% endif %}
<li >
<li class="grid_2">
<h2>Groups I manage</h2>
{% if myteams %}
<table width="100%" class="listtable">
@@ -83,7 +83,7 @@
<a class="button green" href="/rowers/team/create/">New Training Group</a>
</li>
{% if coaches %}
<li>
<li class="grid_2">
<h2>My Coaches</h2>
<table width="100%" class="listtable">
<thead>
@@ -99,7 +99,7 @@
</td>
<td>
<a class="button small red"
href="/rowers/coaches/{{ coach.id }}/dropconfirm/">Remove
href="/rowers/coaches/{{ coach.id }}/dropcoachconfirm/">Remove
</a>
</td>
</tr>
@@ -109,7 +109,7 @@
</li>
{% endif %}
{% if coachees %}
<li>
<li class="grid_2">
<h2>My Rowers</h2>
<table width="100%" class="listtable">
<thead>
@@ -125,7 +125,7 @@
</td>
<td>
<a class="button small red"
href="/rowers/coaches/{{ coach.id }}/dropconfirm/">Remove
href="/rowers/coaches/{{ coachee.id }}/dropconfirm/">Remove
</a>
</td>
</tr>
@@ -297,7 +297,7 @@
{% endif %}
</li>
{% if potentialathletes %}
<li>
<li class="grid_2">
<h2>Rowers you could coach</h2>
<table width="90%" class="listtable">
<thead>
@@ -322,7 +322,7 @@
</li>
{% endif %}
{% if potentialcoaches %}
<li>
<li class="grid_2">
<h2>Coaches who could coach you</h2>
<table width="90%" class="listtable">
<thead>

Binary file not shown.

View File

@@ -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'^me/coachrequest/(?P<id>\d+)/reject/$',views.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,
name='reject_revoke_coach_request'),
url(r'^me/coachoffer/(?P<id>\d+)/reject/$',views.reject_revoke_coach_offer,

View File

@@ -279,6 +279,101 @@ def manager_requests_view(request,code=None,message='',successmessage=''):
})
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()
def team_requestmembership_view(request,teamid,userid):

View File

@@ -227,7 +227,7 @@
</li>
<li id="nav-teams">
<a href="/rowers/me/teams/">
<i class="fas fa-bullhorn"></i>&nbsp;Teams
<i class="fas fa-bullhorn"></i>&nbsp;Groups
</a>
</li>
</ul>