add dashboard page and chart.js
This commit is contained in:
10627
benchcoachproject/static/teamsnap/js/chart.esm.js
Normal file
10627
benchcoachproject/static/teamsnap/js/chart.esm.js
Normal file
File diff suppressed because it is too large
Load Diff
13269
benchcoachproject/static/teamsnap/js/chart.js
Normal file
13269
benchcoachproject/static/teamsnap/js/chart.js
Normal file
File diff suppressed because it is too large
Load Diff
13
benchcoachproject/static/teamsnap/js/chart.min.js
vendored
Normal file
13
benchcoachproject/static/teamsnap/js/chart.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
7
benchcoachproject/static/teamsnap/js/helpers.esm.js
Normal file
7
benchcoachproject/static/teamsnap/js/helpers.esm.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
/*!
|
||||||
|
* Chart.js v3.7.1
|
||||||
|
* https://www.chartjs.org
|
||||||
|
* (c) 2022 Chart.js Contributors
|
||||||
|
* Released under the MIT License
|
||||||
|
*/
|
||||||
|
export { H as HALF_PI, aX as INFINITY, P as PI, aW as PITAU, aZ as QUARTER_PI, aY as RAD_PER_DEG, T as TAU, a_ as TWO_THIRDS_PI, Q as _addGrace, V as _alignPixel, a0 as _alignStartEnd, p as _angleBetween, a$ as _angleDiff, _ as _arrayUnique, a6 as _attachContext, aq as _bezierCurveTo, an as _bezierInterpolation, av as _boundSegment, al as _boundSegments, a3 as _capitalize, ak as _computeSegments, a7 as _createResolver, aH as _decimalPlaces, aP as _deprecated, a8 as _descriptors, af as _elementsEqual, M as _factorize, aJ as _filterBetween, F as _getParentNode, U as _int16Range, ah as _isBetween, ag as _isClickEvent, K as _isDomSupported, z as _isPointInArea, w as _limitValue, aI as _longestText, aK as _lookup, x as _lookupByKey, S as _measureText, aN as _merger, aO as _mergerIf, aw as _normalizeAngle, ao as _pointInLine, ai as _readValueToProps, A as _rlookupByKey, aD as _setMinAndMaxByKey, am as _steppedInterpolation, ap as _steppedLineTo, az as _textX, $ as _toLeftRightCenter, aj as _updateBezierControlPoints, as as addRoundedRectPath, aG as almostEquals, aF as almostWhole, O as callback, ad as clearCanvas, W as clipArea, aM as clone, c as color, h as createContext, ab as debounce, j as defined, aC as distanceBetweenPoints, ar as drawPoint, D as each, e as easingEffects, N as finiteOrDefault, aU as fontString, o as formatNumber, B as getAngleFromPoint, aL as getHoverColor, E as getMaximumSize, y as getRelativePosition, ax as getRtlAdapter, aT as getStyle, b as isArray, g as isFinite, a5 as isFunction, k as isNullOrUndef, q as isNumber, i as isObject, l as listenArrayEvents, L as log10, a2 as merge, a9 as mergeIf, aE as niceNum, aB as noop, ay as overrideTextDirection, G as readUsedSize, X as renderText, r as requestAnimFrame, a as resolve, f as resolveObjectKey, aA as restoreTextDirection, ac as retinaScale, ae as setsEqual, s as sign, aR as splineCurve, aS as splineCurveMonotone, J as supportsEventListenerOptions, I as throttled, R as toDegrees, n as toDimension, Z as toFont, aQ as toFontString, aV as toLineHeight, C as toPadding, m as toPercentage, t as toRadians, at as toTRBL, au as toTRBLCorners, aa as uid, Y as unclipArea, u as unlistenArrayEvents, v as valueOrDefault } from './chunks/helpers.segment.js';
|
||||||
@@ -7,6 +7,7 @@ from . import views
|
|||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.home, name='teamsnap_home'),
|
path('', views.home, name='teamsnap_home'),
|
||||||
|
path('<int:team_id>/dashboard/', views.dashboard, name='teamsnap_dashboard'),
|
||||||
path('edit/event/<int:id>', views.edit_event, name='teamsnap edit event'),
|
path('edit/event/<int:id>', views.edit_event, name='teamsnap edit event'),
|
||||||
path('sync/download', views.sync_from_teamsnap, name="sync from teamsnap"),
|
path('sync/download', views.sync_from_teamsnap, name="sync from teamsnap"),
|
||||||
path('import/', views.import_teamsnap, name="import"),
|
path('import/', views.import_teamsnap, name="import"),
|
||||||
|
|||||||
@@ -54,6 +54,31 @@ def home(request):
|
|||||||
}
|
}
|
||||||
return render(request, 'teamsnap/home.html', context)
|
return render(request, 'teamsnap/home.html', context)
|
||||||
|
|
||||||
|
@login_required()
|
||||||
|
def dashboard(request, team_id):
|
||||||
|
current_benchcoach_user = request.user
|
||||||
|
current_teamsnap_user = request.user.profile.teamsnap_user
|
||||||
|
current_teamsnap_team = request.user.profile.teamsnapsettings.managed_team
|
||||||
|
teamsnap_objects = {}
|
||||||
|
|
||||||
|
TEAM_ID = team_id
|
||||||
|
TOKEN = request.user.profile.teamsnap_access_token
|
||||||
|
no_past = bool(request.GET.get('no_past', 0))
|
||||||
|
games_only = bool(request.GET.get('games_only', 0))
|
||||||
|
from pyteamsnap.api import TeamSnap, Event, AvailabilitySummary
|
||||||
|
client = TeamSnap(token=TOKEN)
|
||||||
|
time.sleep(.5)
|
||||||
|
ts_events = Event.search(client, team_id=TEAM_ID)
|
||||||
|
ts_availability_summaries_d = {a.data['id']:a for a in AvailabilitySummary.search(client, team_id=team_id)}
|
||||||
|
ts_events_future = [e for e in ts_events if e.data['start_date'] > datetime.datetime.now(datetime.timezone.utc)]
|
||||||
|
ts_events_past = [e for e in reversed(ts_events) if e.data['start_date'] < datetime.datetime.now(datetime.timezone.utc)]
|
||||||
|
|
||||||
|
return render(request, 'teamsnap/teamsnap.html', {
|
||||||
|
'ts_events_future':ts_events_future,
|
||||||
|
'ts_events_past': ts_events_past,
|
||||||
|
'events_availabilities' : [(e, ts_availability_summaries_d[e.data['id']]) for e in ts_events_future]
|
||||||
|
})
|
||||||
|
|
||||||
@login_required()
|
@login_required()
|
||||||
def sync_from_teamsnap(request, object_name=None, object_id=None):
|
def sync_from_teamsnap(request, object_name=None, object_id=None):
|
||||||
if request.POST:
|
if request.POST:
|
||||||
@@ -179,7 +204,7 @@ def event(request, event_id, team_id):
|
|||||||
|
|
||||||
members = []
|
members = []
|
||||||
|
|
||||||
return render(request, "teamsnap/view_event.html", context={
|
return render(request, "teamsnap/event/view_event.html", context={
|
||||||
"availability_summary":ts_availability_summary,
|
"availability_summary":ts_availability_summary,
|
||||||
"event":ts_event,
|
"event":ts_event,
|
||||||
"availablities":[],
|
"availablities":[],
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<script src="{% static 'js/bootstrap.bundle.js' %}" crossorigin="anonymous"></script>
|
<script src="{% static 'js/bootstrap.bundle.js' %}" crossorigin="anonymous"></script>
|
||||||
|
<script src="{% static 'teamsnap/js/chart.js' %}" crossorigin="anonymous"></script>
|
||||||
<link rel="stylesheet" href="{% static 'css/bootstrap.css' %}">
|
<link rel="stylesheet" href="{% static 'css/bootstrap.css' %}">
|
||||||
<link rel='stylesheet' href="{% static 'css/base.css' %}">
|
<link rel='stylesheet' href="{% static 'css/base.css' %}">
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.2/font/bootstrap-icons.css">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.8.2/font/bootstrap-icons.css">
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{% load static %}
|
{% load static %}
|
||||||
<nav class="navbar navbar-dark navbar-expand-lg mb-2" style="background: #323669">
|
<nav class="navbar navbar-dark navbar-expand-lg mb-2" style="background: #323669">
|
||||||
<a class="navbar-brand text-uppercase fw-bold mx-2 text-dark">
|
<a class="navbar-brand text-uppercase fw-bold mx-2 text-dark" href="{% url 'home'%}">
|
||||||
<img class="d-inline-block" width="32" height="32" src="{% static 'benchcoach.svg' %}" />
|
<img class="d-inline-block" width="32" height="32" src="{% static 'benchcoach.svg' %}" />
|
||||||
<span class="text-white">bench coach</span>
|
<span class="text-white">bench coach</span>
|
||||||
</a>
|
</a>
|
||||||
@@ -11,10 +11,10 @@
|
|||||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||||
<ul class="navbar-nav mx-2">
|
<ul class="navbar-nav mx-2">
|
||||||
<li class="nav-item ">
|
<li class="nav-item ">
|
||||||
<a class="nav-link{% if request.resolver_match.url_name == 'home' %} active{% endif %} text-decoration-none" href="{% url 'home'%}">
|
<a class="nav-link{% if request.resolver_match.url_name == 'teamsnap_dashboard' %} active{% endif %} text-decoration-none" href="{% url 'teamsnap_dashboard' team_id=request.user.profile.teamsnapsettings.managed_team.id %}">
|
||||||
<i class="bi bi-house-fill"></i>
|
<i class="bi bi-speedometer2"></i>
|
||||||
<span class="">
|
<span class="">
|
||||||
Home
|
Dashboard
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
Reference in New Issue
Block a user