Private
Public Access
1
0

team delete - line 349 urls.py

This commit is contained in:
Sander Roosendaal
2018-10-10 21:12:57 +02:00
parent 58cdc1edc2
commit 77d72ea60d
6 changed files with 278 additions and 196 deletions

View File

@@ -1,37 +1,20 @@
{% extends "base.html" %} {% extends "newbase.html" %}
{% block title %}Team {% endblock %} {% block title %}Team {% endblock %}
{% block content %} {% block main %}
<div class="grid_12 alpha"> <h1>{{ team.name }}</h1>
{% include "teambuttons.html" with teamid=team.id %}
</div>
<div class="grid_12">
<div class="grid_8 alpha">
<h1>{{ team.name }}</h1>
<div class="grid_4 omega"> <ul class="main-content">
<li>
<p>{{ team.notes }}</p> <p>{{ team.notes }}</p>
<p><b>Manager:</b> {{ team.manager.first_name }} {{ team.manager.last_name }}</p> <p><b>Manager:</b> {{ team.manager.first_name }} {{ team.manager.last_name }}</p>
</div> </li>
</div> <li>
<div class="grid_12 alpha">
{% if ismember %} {% if hasrequested %}
<div class="grid_2 alpha">
<a class="button red small" href="/rowers/team/{{ team.id }}/leaveconfirm">Leave this team</a>
</div>
{% if team.manager == user %}
<div class="grid_2 suffix_8 omega">
<a class="button blue small" href="/rowers/team/{{ team.id }}/edit">Edit Team</a>
</div>
{% else %}
<div class="grid_2 suffix_8 omega">
<p>&nbsp;
</div>
{% endif %}
{% elif hasrequested %}
<p>You have requested access to this team</p> <p>You have requested access to this team</p>
{% else %} {% elif team not in myteams %}
<p>You can request access to this team. By requesting access, you <p>You can request access to this team. By requesting access, you
agree to the <a href="/rowers/legal">Privacy Policy</a> regarding agree to the <a href="/rowers/legal">Privacy Policy</a> regarding
team functionality. You agree to share your workout data (except team functionality. You agree to share your workout data (except
@@ -39,19 +22,13 @@
You also grant the team manager access to your heart rate and power You also grant the team manager access to your heart rate and power
zone settings, as well as your functional threshold information. You zone settings, as well as your functional threshold information. You
are granting the team manager permission to edit your workouts.</p> are granting the team manager permission to edit your workouts.</p>
<div class="grid_2 suffix_10 alpha tooltip">
<a class="button green small" href="/rowers/team/{{ team.id }}/requestmembership/{{ user.id }}">Join</a> <a class="button green small" href="/rowers/team/{{ team.id }}/requestmembership/{{ user.id }}">Join</a>
<span class="tooltiptext">A request will be sent to the team manager</span> <span class="tooltiptext">A request will be sent to the team manager</span>
</div>
{% endif %} {% endif %}
</div> </li>
<li class="grid_2">
<div class="grid_12 alpha">
<div class="grid_6 alpha">
<p>
<h2>Members</h2> <h2>Members</h2>
<table width="70%" class="listtable"> <table width="100%" class="listtable">
<thead> <thead>
<tr> <tr>
<th>Name</th> <th>Name</th>
@@ -71,11 +48,9 @@
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</p> </li>
<li class="grid_2">
</div>
<div class="grid_6 omega">
{% if team.manager == user %} {% if team.manager == user %}
<p>Use the form to add a new user. You can either select a user from the list of your existing club members who are not on this team yet, or you can type the user's email address, which also works for users who have not registered to the site yet.</p> <p>Use the form to add a new user. You can either select a user from the list of your existing club members who are not on this team yet, or you can type the user's email address, which also works for users who have not registered to the site yet.</p>
{% if inviteform.errors %} {% if inviteform.errors %}
@@ -88,19 +63,19 @@
{{ inviteform.as_table }} {{ inviteform.as_table }}
</table> </table>
{% csrf_token %} {% csrf_token %}
<div id="formbutton" class="grid_1 prefix_4 suffix_1">
<input class="button green" type="submit" value="Submit"> <input class="button green" type="submit" value="Submit">
</div>
</form> </form>
{% else %} {% else %}
<p> <p>
&nbsp; &nbsp;
</p> </p>
{% endif %} {% endif %}
</div> </li>
</div> </ul>
</div>
{% endblock %} {% endblock %}
{% block sidebar %}
{% include 'menu_teams.html' %}
{% endblock %}

View File

@@ -1,43 +1,38 @@
{% extends "base.html" %} {% extends "newbase.html" %}
{% load staticfiles %} {% load staticfiles %}
{% load rowerfilters %} {% load rowerfilters %}
{% block title %}Leave Team {% endblock %} {% block title %}Delete Team {% endblock %}
{% block content %} {% block main %}
<div id="workouts" class="grid_6 alpha"> <h1>Confirm Deleting the team {{ team.name }}</h1>
<ul class="main-content">
<li class="grid_2">
{% if form.errors %} {% if form.errors %}
<p style="color: red;"> <p style="color: red;">
Please correct the error{{ form.errors|pluralize }} below. Please correct the error{{ form.errors|pluralize }} below.
</p> </p>
{% endif %} {% endif %}
<h1>Confirm Deleting the team {{ team.name }}</h1>
<p>This will remove the team. Your team members and their workouts <p>This will remove the team. Your team members and their workouts
will not be deleted. will not be deleted.
</p> </p>
<div class="grid_2 alpha">
<p> <p>
<a class="button green small" href="/rowers/team/{{ team.id }}">Cancel</a> <a class="button green small" href="/rowers/team/{{ team.id }}">Cancel</a>
</div> </p>
<div class="grid_2">
<p> <p>
<a class="button red small" href="/rowers/team/{{ team.id }}/delete">Delete</a> <a class="button red small" href="/rowers/team/{{ team.id }}/delete">Delete</a>
</p> </p>
</div> </li>
</ul>
</div>
<div id="images" class="grid_6 omega">
<p>
&nbsp;
</p>
</div>
{% endblock %} {% endblock %}
{% block sidebar %}
{% include 'menu_teams.html' %}
{% endblock %}

View File

@@ -1,13 +1,14 @@
{% extends "base.html" %} {% extends "newbase.html" %}
{% load staticfiles %} {% load staticfiles %}
{% block title %}New Team{% endblock %} {% block title %}Edit Team{% endblock %}
{% block content %} {% block main %}
<div class="grid_12 alpha">
<h1>Edit Team {{ team.name }}</h1> <h1>Edit Team {{ team.name }}</h1>
</div>
<div id="left" class="grid_6 alpha"> <ul class="main-content">
<li class="grid_2">
<form enctype="multipart/form-data" action="{{ formloc }}" method="post"> <form enctype="multipart/form-data" action="{{ formloc }}" method="post">
{% if form.errors %} {% if form.errors %}
<p style="color: red;"> <p style="color: red;">
@@ -19,19 +20,23 @@
{{ form.as_table }} {{ form.as_table }}
</table> </table>
{% csrf_token %} {% csrf_token %}
<div id="formbutton" class="grid_1 prefix_4 suffix_1">
<input class="button green" type="submit" value="Submit"> <input class="button green" type="submit" value="Submit">
</div> </form>
</div> </li>
<div id="right" class="grid_6 omega"> <li class="grid_2">
<ul> <ul>
<li>Team Type: A private team is invisible on the Teams Management page, except for its members. The only way to add members is for the manager to send an invitation. An open team is visible for all rowsandall.com users. In addition to the invitation mechanism, any user can request to be added to this team. The team manager will always have to approve membership.</li> <li>Team Type: A private team is invisible on the Teams Management page, except for its members. The only way to add members is for the manager to send an invitation. An open team is visible for all rowsandall.com users. In addition to the invitation mechanism, any user can request to be added to this team. The team manager will always have to approve membership.</li>
<li>Sharing Behavior: When set to "All Members", all members of a team will see each other's workouts. This is the recommended setting. If te sharing bhavior is set to "Coach Only", team members only see their own workouts. The coach sees all team members' workouts.</li> <li>Sharing Behavior: When set to "All Members", all members of a team will see each other's workouts. This is the recommended setting. If te sharing bhavior is set to "Coach Only", team members only see their own workouts. The coach sees all team members' workouts.</li>
<li>These settings can be changed at any point in time through the Team Edit page</li> <li>These settings can be changed at any point in time through the Team Edit page
</li>
</ul> </ul>
</div> </li>
</ul>
</form> {% endblock %}
{% block sidebar %}
{% include 'menu_teams.html' %}
{% endblock %} {% endblock %}

View File

@@ -1,19 +1,20 @@
{% extends "base.html" %} {% extends "newbase.html" %}
{% load staticfiles %} {% load staticfiles %}
{% load rowerfilters %} {% load rowerfilters %}
{% block title %}Leave Team {% endblock %} {% block title %}Leave Team {% endblock %}
{% block content %} {% block main %}
<div id="workouts" class="grid_6 alpha"> <h1>Confirm Leaving the team {{ team.name }}</h1>
<ul class="main-content">
<li class="grid_2">
{% if form.errors %} {% if form.errors %}
<p style="color: red;"> <p style="color: red;">
Please correct the error{{ form.errors|pluralize }} below. Please correct the error{{ form.errors|pluralize }} below.
</p> </p>
{% endif %} {% endif %}
<h1>Confirm Leaving the team {{ team.name }}</h1>
<p>This will remove you and all your workouts from the team. If this <p>This will remove you and all your workouts from the team. If this
is a closed team, you can only return when the team manager is a closed team, you can only return when the team manager
reinvites you. reinvites you.
@@ -21,25 +22,20 @@
</p> </p>
<div class="grid_2 alpha">
<p> <p>
<a class="button green small" href="/rowers/team/{{ team.id }}">Cancel</a> <a class="button green small" href="/rowers/team/{{ team.id }}">Cancel</a>
</div> </p>
<div class="grid_2">
<p> <p>
<a class="button red small" href="/rowers/team/{{ team.id }}/leave">Leave</a> <a class="button red small" href="/rowers/team/{{ team.id }}/leave">Leave</a>
</p> </p>
</div> </li>
</ul>
</div>
<div id="images" class="grid_6 omega">
<p>
&nbsp;
</p>
</div>
{% endblock %}
{% block sidebar %}
{% include 'menu_teams.html' %}
{% endblock %} {% endblock %}

View File

@@ -1,17 +1,13 @@
{% extends "base.html" %} {% extends "newbase.html" %}
{% block title %}Team {% endblock %} {% block title %}Team {% endblock %}
{% block content %} {% block main %}
<div class="grid_12 alpha"> <h1>{{ team.name }} Stats</h1>
{% include "teambuttons.html" with teamid=team.id team=team %} <p>
</div>
<div class="grid_12 alpha">
<h1>{{ team.name }} Stats</h1>
<p>
Links to the cumulative statistics pages for your team's members Links to the cumulative statistics pages for your team's members
</p> </p>
<table width="90%" class="listtable shortpadded"> <table width="90%" class="listtable shortpadded">
<tbody> <tbody>
{% for u in theusers %} {% for u in theusers %}
<tr> <tr>
@@ -26,10 +22,11 @@
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
</div>
{% endblock %} {% endblock %}
{% block sidebar %}
{% include 'menu_teams.html' %}
{% endblock %}

View File

@@ -12423,11 +12423,14 @@ def strokedatajson(request,id):
import teams import teams
@login_required() @login_required()
def team_view(request,id=0): def team_view(request,id=0,userid=0):
ismember = 0 ismember = 0
hasrequested = 0 hasrequested = 0
r = getrower(request.user) r = getrequestrower(request,userid=userid)
myteams = Team.objects.filter(manager=request.user)
myteams, memberteams, otherteams = get_teams(request)
teams.remove_expired_invites()
try: try:
t = Team.objects.get(id=id) t = Team.objects.get(id=id)
@@ -12467,13 +12470,27 @@ def team_view(request,id=0):
if r in members: if r in members:
ismember = 1 ismember = 1
breadcrumbs = [
{
'url':reverse(rower_teams_view),
'name': 'Teams'
},
{
'url':reverse(team_view,kwargs={'id':id}),
'name': t.name
}
]
return render(request, 'team.html', return render(request, 'team.html',
{ {
'team':t, 'team':t,
'teams':get_my_teams(request.user), 'teams':get_my_teams(request.user),
'myteams':myteams,
'memberteams':memberteams,
'members':members, 'members':members,
'breadcrumbs':breadcrumbs,
'active':'nav-teams',
'inviteform':inviteform, 'inviteform':inviteform,
'ismember':ismember, 'ismember':ismember,
'hasrequested':hasrequested, 'hasrequested':hasrequested,
@@ -12486,10 +12503,31 @@ def team_leaveconfirm_view(request,id=0):
except Team.DoesNotExist: except Team.DoesNotExist:
raise Http404("Team doesn't exist") raise Http404("Team doesn't exist")
myteams, memberteams, otherteams = get_teams(request)
breadcrumbs = [
{
'url':reverse(rower_teams_view),
'name': 'Teams'
},
{
'url':reverse(team_view,kwargs={'id':id}),
'name': t.name
},
{
'url':reverse(team_leaveconfirm_view,kwargs={'id':id}),
'name': 'Leave'
}
]
return render(request,'teamleaveconfirm.html', return render(request,'teamleaveconfirm.html',
{ {
'team':t, 'team':t,
'teams':get_my_teams(request.user), 'teams':get_my_teams(request.user),
'myteams':myteams,
'memberteams':memberteams,
'otherteams':otherteams,
'active':'nav-teams',
'breadcrumbs':breadcrumbs,
}) })
@login_required() @login_required()
@@ -12624,6 +12662,19 @@ def team_leave_view(request,id=0):
from rowers.forms import TeamInviteCodeForm from rowers.forms import TeamInviteCodeForm
def get_teams(request):
r = Rower.objects.get(user=request.user)
myteams = Team.objects.filter(
manager=request.user).order_by('name')
memberteams = Team.objects.filter(
rower=r).exclude(manager=request.user).order_by('name')
otherteams = Team.objects.filter(
private='open').exclude(
rower=r).exclude(manager=request.user).order_by('name')
return myteams, memberteams, otherteams
@login_required() @login_required()
def rower_teams_view(request,message='',successmessage=''): def rower_teams_view(request,message='',successmessage=''):
if request.method == 'POST': if request.method == 'POST':
@@ -12640,11 +12691,12 @@ def rower_teams_view(request,message='',successmessage=''):
r = getrower(request.user) r = getrower(request.user)
ts = Team.objects.filter(rower=r) ts = Team.objects.filter(rower=r)
myteams = Team.objects.filter(manager=request.user)
memberteams = Team.objects.filter(rower=r).exclude(manager=request.user).order_by('name')
otherteams = Team.objects.filter(private='open').exclude(rower=r).exclude(manager=request.user).order_by('name') myteams, memberteams, otherteams = get_teams(request)
teams.remove_expired_invites() teams.remove_expired_invites()
invites = TeamInvite.objects.filter(user=request.user) invites = TeamInvite.objects.filter(user=request.user)
requests = TeamRequest.objects.filter(user=request.user) requests = TeamRequest.objects.filter(user=request.user)
myrequests = TeamRequest.objects.filter(team__in=myteams) myrequests = TeamRequest.objects.filter(team__in=myteams)
@@ -12843,10 +12895,32 @@ def team_edit_view(request,id=0):
else: else:
teamcreateform = TeamForm(instance=t) teamcreateform = TeamForm(instance=t)
myteams, memberteams, otherteams = get_teams(request)
breadcrumbs = [
{
'url':reverse(rower_teams_view),
'name': 'Teams'
},
{
'url':reverse(team_view,kwargs={'id':id}),
'name': t.name
},
{
'url':reverse(team_edit_view,kwargs={'id':id}),
'name': 'Edit'
}
]
return render(request,'teamedit.html', return render(request,'teamedit.html',
{ {
'form':teamcreateform, 'form':teamcreateform,
'teams':get_my_teams(request.user), 'teams':get_my_teams(request.user),
'myteams':myteams,
'memberteams':memberteams,
'otherteams':otherteams,
'active':'nav-teams',
'breadcrumbs':breadcrumbs,
'team':t, 'team':t,
}) })
@@ -12886,10 +12960,30 @@ def team_deleteconfirm_view(request,id):
if t.manager != request.user: if t.manager != request.user:
raise PermissionDenied("You are not allowed to delete this team") raise PermissionDenied("You are not allowed to delete this team")
myteams, memberteams, otherteams = get_teams(request)
breadcrumbs = [
{
'url':reverse(rower_teams_view),
'name': 'Teams'
},
{
'url':reverse(team_view,kwargs={'id':id}),
'name': t.name
},
{
'url':reverse(team_deleteconfirm_view,kwargs={'id':id}),
'name': 'Leave'
}
]
return render(request,'teamdeleteconfirm.html', return render(request,'teamdeleteconfirm.html',
{ {
'teams':get_my_teams(request.user), 'teams':get_my_teams(request.user),
'team':t 'team':t,
'myteams':myteams,
'memberteams':memberteams,
'otherteams':otherteams,
'active':'nav-teams',
}) })
@user_passes_test(iscoachmember,login_url="/",redirect_field_name=None) @user_passes_test(iscoachmember,login_url="/",redirect_field_name=None)
@@ -12922,11 +13016,31 @@ def team_members_stats_view(request,id):
theusers = [member.user for member in members] theusers = [member.user for member in members]
myteams, memberteams, otherteams = get_teams(request)
breadcrumbs = [
{
'url':reverse(rower_teams_view),
'name': 'Teams'
},
{
'url':reverse(team_view,kwargs={'id':id}),
'name': t.name
},
{
'url':reverse(team_members_stats_view,kwargs={'id':id}),
'name': 'Members Stats'
}
]
response = render(request,'teamstats.html', response = render(request,'teamstats.html',
{ {
'teams':get_my_teams(request.user), 'teams':get_my_teams(request.user),
'myteams':myteams,
'memberteams':memberteams,
'otherteams':otherteams,
'active':'nav-teams',
'breadcrumbs':breadcrumbs,
'team':t, 'team':t,
'theusers':theusers, 'theusers':theusers,
}) })