broke out dashboard into its own app
This commit is contained in:
@@ -272,5 +272,5 @@ SOCIALACCOUNT_FORMS = {"signup": "benchcoach.users.forms.UserSocialSignupForm"}
|
|||||||
|
|
||||||
# Your stuff...
|
# Your stuff...
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
INSTALLED_APPS += ["teamsnap", "instagen", "teamsnap.lineup"]
|
INSTALLED_APPS += ["teamsnap", "instagen", "teamsnap.lineup", "teamsnap.dashboard"]
|
||||||
SOCIALACCOUNT_PROVIDERS = {"teamsnap": {"SCOPE": ["read", "write"]}}
|
SOCIALACCOUNT_PROVIDERS = {"teamsnap": {"SCOPE": ["read", "write"]}}
|
||||||
|
|||||||
0
teamsnap/dashboard/__init__.py
Normal file
0
teamsnap/dashboard/__init__.py
Normal file
6
teamsnap/dashboard/apps.py
Normal file
6
teamsnap/dashboard/apps.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class DashboardConfig(AppConfig):
|
||||||
|
default_auto_field = "django.db.models.BigAutoField"
|
||||||
|
name = "teamsnap.dashboard"
|
||||||
0
teamsnap/dashboard/migrations/__init__.py
Normal file
0
teamsnap/dashboard/migrations/__init__.py
Normal file
3
teamsnap/dashboard/tests.py
Normal file
3
teamsnap/dashboard/tests.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
7
teamsnap/dashboard/urls.py
Normal file
7
teamsnap/dashboard/urls.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
from django.urls import path
|
||||||
|
from views import dashboard
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path("<int:team_id>/dashboard/", dashboard, name="teamsnap_dashboard"),
|
||||||
|
path("dashboard/", dashboard, name="teamsnap_dashboard"),
|
||||||
|
]
|
||||||
42
teamsnap/dashboard/views.py
Normal file
42
teamsnap/dashboard/views.py
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
import datetime
|
||||||
|
|
||||||
|
from django.shortcuts import redirect, render
|
||||||
|
|
||||||
|
from teamsnap.views import get_teamsnap_client
|
||||||
|
|
||||||
|
|
||||||
|
def dashboard(request, team_id=None):
|
||||||
|
if not team_id:
|
||||||
|
return redirect(
|
||||||
|
"teamsnap_dashboard", team_id=request.user.preferences.managed_team_id
|
||||||
|
)
|
||||||
|
|
||||||
|
from pyteamsnap.api import AvailabilitySummary, Event
|
||||||
|
|
||||||
|
client = get_teamsnap_client(request)
|
||||||
|
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,
|
||||||
|
"dashboard.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
|
||||||
|
],
|
||||||
|
},
|
||||||
|
)
|
||||||
@@ -18,4 +18,5 @@ urlpatterns += [
|
|||||||
name="teamsnap_view_event",
|
name="teamsnap_view_event",
|
||||||
),
|
),
|
||||||
path("", include("teamsnap.lineup.urls")),
|
path("", include("teamsnap.lineup.urls")),
|
||||||
|
path("", include("teamsnap.dashboard.urls")),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -362,43 +362,6 @@ def edit_lineup(request, event_ids, team_id):
|
|||||||
return render(request, "lineup/edit.html", context={"contexts": contexts})
|
return render(request, "lineup/edit.html", context={"contexts": contexts})
|
||||||
|
|
||||||
|
|
||||||
def dashboard(request, team_id=None):
|
|
||||||
if not team_id:
|
|
||||||
return redirect(
|
|
||||||
"teamsnap_dashboard", team_id=request.user.preferences.managed_team_id
|
|
||||||
)
|
|
||||||
|
|
||||||
from pyteamsnap.api import AvailabilitySummary, Event
|
|
||||||
|
|
||||||
client = get_teamsnap_client(request)
|
|
||||||
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,
|
|
||||||
"dashboard.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
|
|
||||||
],
|
|
||||||
},
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def submit_lineup(request, team_id, event_id):
|
def submit_lineup(request, team_id, event_id):
|
||||||
from pyteamsnap.api import Event, EventLineup, EventLineupEntry
|
from pyteamsnap.api import Event, EventLineup, EventLineupEntry
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user