gamecard v0.1
This commit is contained in:
191
teamsnap/templates/lineup/gamecard.html
Normal file
191
teamsnap/templates/lineup/gamecard.html
Normal file
@@ -0,0 +1,191 @@
|
||||
{% load static %}
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" href="{% static 'css/gamecard.css' %}">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body class="b5">
|
||||
<section class="sheet">
|
||||
<div class="whole-card">
|
||||
<div class="half-card">
|
||||
<div class="content card-left">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th colspan="8" class="gametitle">
|
||||
{{ event.data.formatted_title }} {{ event.data.start_date|date:'m/d/Y g:i A' }}
|
||||
{# G#01 at Browns 05/01/2021 12:30 PM#}
|
||||
</th>
|
||||
<th class="homeaway" colspan="4">{{ event.data.game_type }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="numbercell">
|
||||
</th>
|
||||
<th class="customcol">
|
||||
</th>
|
||||
<th class="numbercell">
|
||||
</th>
|
||||
<th class="numbercell">
|
||||
</th>
|
||||
<th class="numbercell">1
|
||||
</th>
|
||||
<th class="numbercell">2
|
||||
</th>
|
||||
<th class="numbercell">3
|
||||
</th>
|
||||
<th class="numbercell">4
|
||||
</th>
|
||||
<th class="numbercell">5
|
||||
</th>
|
||||
<th class="numbercell">6
|
||||
</th>
|
||||
<th class="numbercell">7
|
||||
</th>
|
||||
<th class="numbercell">X
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for member in members_startinglineup %}
|
||||
<tr>
|
||||
<td class="numbercell">{{ member.lineup_entry.sequence | add:"1" }}</td>
|
||||
<td class="customcol">{{ member.member.last_name }}</td>
|
||||
<td class="numbercell">{{ member.member.jersey_number }}</td>
|
||||
<td class="numbercell">{{ member.lineup_entry.label }}</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<table>
|
||||
<tbody>
|
||||
{% for member in members_startingpositiononly %}
|
||||
<tr>
|
||||
<td class="numbercell"></td>
|
||||
<td class="customcol">{{ member.member.last_name }}</td>
|
||||
<td class="numbercell">{{ member.member.jersey_number }}</td>
|
||||
<td class="numbercell">{{ member.lineup_entry.label }}</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="half-card">
|
||||
<div class="content card-right">
|
||||
<table class="tg">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="numbercell"></th>
|
||||
<th class="numbercell"></th>
|
||||
<th class="condensedNameCell">Available</th>
|
||||
<th class="statscell">AVG/OBP/SLG:PA</th>
|
||||
<th class="numbercell"></th>
|
||||
<th class="numbercell"></th>
|
||||
<th class="numbercell"></th>
|
||||
<th class="numbercell"></th>
|
||||
<th class="numbercell"></th>
|
||||
<th class="numbercell"></th>
|
||||
<th class="numbercell"></th>
|
||||
<th class="numbercell"></th>
|
||||
<th class="numbercell"></th>
|
||||
<th class="numbercell"></th>
|
||||
<th class="numbercell"></th>
|
||||
<th class="numbercell"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for member in members %}
|
||||
<tr>
|
||||
<td class="numbercell"></td>
|
||||
<td class="numbercell available-status-code-{{ member.availability.status_code }}">{{ member.member.jersey_number }}</td>
|
||||
<td class="condensedNameCell available-status-code-{{ member.availability.status_code }}">{{ member.member.last_name }}</td>
|
||||
<td class="statscell"></td>
|
||||
<td class="numbercell"></td>
|
||||
<td class="numbercell"></td>
|
||||
<td class="numbercell"></td>
|
||||
<td class="numbercell"></td>
|
||||
<td class="numbercell"></td>
|
||||
<td class="numbercell"></td>
|
||||
<td class="numbercell"></td>
|
||||
<td class="numbercell"></td>
|
||||
<td class="numbercell"></td>
|
||||
<td class="numbercell"></td>
|
||||
<td class="numbercell"></td>
|
||||
<td class="numbercell"></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="whole-card">
|
||||
<div class="half-card">
|
||||
<div class="content card-left"></div>
|
||||
</div>
|
||||
<div class="half-card">
|
||||
<div class="content card-right">
|
||||
<div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="numbercell" style="background-color: #323669">
|
||||
{{ event.data.start_date|date:"D, F j, Y g:i A" }}
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="numbercell" style="background-color: #323669">
|
||||
{{ event.data.location_name }}
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="numbercell" style="background-color: lightgray">
|
||||
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
<div>
|
||||
<div class="" width="100%">
|
||||
<img src="{% static 'teamsnap/ig/logos/hounds.png' %}"
|
||||
height="120px"
|
||||
>
|
||||
</div>
|
||||
<div class="" width="100%" style="text-align: center;font-size: xxx-large; font-family: Pacifico">
|
||||
VS.
|
||||
</div>
|
||||
<div class="" width="100%" style="text-align: right">
|
||||
<img src="{% static 'teamsnap/ig/logos/hounds.png' %}"
|
||||
width="120px"
|
||||
>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
||||
@@ -8,7 +8,8 @@ from .views import (
|
||||
edit_lineup,
|
||||
schedule_view,
|
||||
view_event,
|
||||
submit_lineup
|
||||
submit_lineup,
|
||||
gamecard
|
||||
)
|
||||
|
||||
urlpatterns = default_urlpatterns(TeamsnapProvider)
|
||||
@@ -38,4 +39,7 @@ urlpatterns += [
|
||||
edit_lineup,
|
||||
name='teamsnap_edit_multiple_lineups'
|
||||
),
|
||||
path('<int:team_id>/schedule/edit_lineup/<int:event_id>/gamecard/',
|
||||
gamecard,
|
||||
name='gamecard'),
|
||||
]
|
||||
|
||||
@@ -441,3 +441,92 @@ def submit_lineup(request, team_id, event_id):
|
||||
return JsonResponse(ts_event.data)
|
||||
pass
|
||||
return HttpResponseServerError
|
||||
def gamecard(request, team_id, event_id):
|
||||
import re
|
||||
from pyteamsnap.api import Event, Availability, Member, EventLineupEntry, EventLineup, \
|
||||
AvailabilitySummary
|
||||
client = get_teamsnap_client(request)
|
||||
ts_bulkload = client.bulk_load(team_id=team_id,
|
||||
types=[Event, EventLineup, EventLineupEntry, AvailabilitySummary, Member],
|
||||
event__id=event_id)
|
||||
formsets_lineup = []
|
||||
formsets_bench = []
|
||||
formsets = []
|
||||
events = []
|
||||
contexts = []
|
||||
ts_event = [i for i in ts_bulkload if isinstance(i, Event) and i.data['id'] == event_id][0]
|
||||
ts_availabilities = Availability.search(client, event_id=ts_event.data['id'])
|
||||
ts_availability_summary = \
|
||||
[i for i in ts_bulkload if isinstance(i, AvailabilitySummary) and i.data['event_id'] == event_id][0]
|
||||
ts_lineup_entries = EventLineupEntry.search(client, event_id=event_id)
|
||||
|
||||
if ts_lineup_entries:
|
||||
ts_lineup = EventLineup.get(client, id=ts_lineup_entries[0].data['event_lineup_id'])
|
||||
else:
|
||||
ts_lineup = EventLineup.search(client, event_id=event_id)
|
||||
|
||||
ts_members = [i for i in ts_bulkload if isinstance(i, Member)]
|
||||
ts_member_lookup = {m.data['id']: m for m in ts_members}
|
||||
ts_availability_lookup = {m.data['member_id']: m for m in ts_availabilities}
|
||||
ts_lineup_entries_lookup = {m.data['member_id']: m for m in ts_lineup_entries}
|
||||
|
||||
members = []
|
||||
|
||||
for member in ts_members:
|
||||
if not member.data['is_non_player']:
|
||||
members.append({
|
||||
"member": getattr(member, 'data'),
|
||||
"availability": getattr(ts_availability_lookup.get(member.data['id'], {}), 'data', {}),
|
||||
"lineup_entry": getattr(ts_lineup_entries_lookup.get(member.data['id'], {}), 'data', {})
|
||||
}
|
||||
)
|
||||
|
||||
members = sorted(members, key=lambda d: (
|
||||
{
|
||||
None: 3, # No Response
|
||||
0: 2, # No
|
||||
2: 1, # Maybe
|
||||
1: 0 # Yes
|
||||
|
||||
}.get(d['availability'].get('status_code')),
|
||||
d['member'].get('last_name'))
|
||||
)
|
||||
|
||||
members_startinglineup = []
|
||||
members_startingpositiononly = []
|
||||
|
||||
for member in members:
|
||||
if re.search(r'([A-Z0-9]+)(?:\s+\[(.*)\])?', member['lineup_entry'].get('label', '')):
|
||||
position, position_note = re.search(r'([A-Z0-9]+)(?:\s+\[(.*)\])?',
|
||||
member['lineup_entry'].get('label', '')).groups()
|
||||
else:
|
||||
position, position_note = ("", "")
|
||||
|
||||
position_only = position_note == "PO"
|
||||
|
||||
if position_only:
|
||||
member['lineup_entry']['label'] = position
|
||||
|
||||
if member['lineup_entry'].get('id') and not position_only:
|
||||
members_startinglineup.append(member)
|
||||
elif member['lineup_entry'].get('id') and position_only:
|
||||
members_startingpositiononly.append(member)
|
||||
|
||||
members_startinglineup = sorted(
|
||||
members_startinglineup,
|
||||
key=lambda d: d.get('lineup_entry',{}).get('sequence', 100)
|
||||
)
|
||||
|
||||
from teamsnap.forms import LineupEntryFormset, LineupEntryForm
|
||||
|
||||
initial = []
|
||||
l=[]
|
||||
# l = [(member,ts_availability_lookup.get(member['member_id'])) for member in members if not member['is_non_player']]
|
||||
|
||||
context={
|
||||
"event": ts_event,
|
||||
"members": members,
|
||||
"members_startinglineup":members_startinglineup,
|
||||
"members_startingpositiononly":members_startingpositiononly
|
||||
}
|
||||
return render(request, "lineup/gamecard.html", context=context)
|
||||
|
||||
Reference in New Issue
Block a user