Revert "incorporate new pyteamsnap, incorporate loading from sessions before creating new client."
This reverts commit cf28a5f133.
This commit is contained in:
@@ -281,4 +281,3 @@ INSTALLED_APPS += [
|
||||
"teamsnap.dashboard",
|
||||
]
|
||||
SOCIALACCOUNT_PROVIDERS = {"teamsnap": {"SCOPE": ["read", "write"]}}
|
||||
SESSION_SERIALIZER = "django.contrib.sessions.serializers.PickleSerializer"
|
||||
|
||||
@@ -25,7 +25,7 @@ def dashboard(request, team_id=None):
|
||||
team_id=request.user.teamsnap_preferences.managed_team_id,
|
||||
)
|
||||
|
||||
from pyteamsnap.objects import AvailabilitySummary, Event
|
||||
from pyteamsnap.api import AvailabilitySummary, Event
|
||||
|
||||
client = get_teamsnap_client(request)
|
||||
ts_events = Event.search(client, team_id=team_id)
|
||||
|
||||
@@ -17,7 +17,7 @@ def teamsnap_event_redirect(request, event_id, team_id):
|
||||
def edit_lineup(request, event_ids, team_id):
|
||||
import re
|
||||
|
||||
from pyteamsnap.objects import (
|
||||
from pyteamsnap.api import (
|
||||
Availability,
|
||||
AvailabilitySummary,
|
||||
Event,
|
||||
@@ -25,6 +25,7 @@ def edit_lineup(request, event_ids, team_id):
|
||||
EventLineupEntry,
|
||||
Member,
|
||||
)
|
||||
|
||||
from teamsnap.forms import LineupEntryFormset
|
||||
|
||||
client = get_teamsnap_client(request)
|
||||
@@ -199,7 +200,8 @@ def edit_lineup(request, event_ids, team_id):
|
||||
|
||||
|
||||
def submit_lineup(request, team_id, event_id):
|
||||
from pyteamsnap.objects import Event, EventLineup, EventLineupEntry
|
||||
from pyteamsnap.api import Event, EventLineup, EventLineupEntry
|
||||
|
||||
from teamsnap.forms import LineupEntryFormset
|
||||
|
||||
client = get_teamsnap_client(request)
|
||||
@@ -258,8 +260,7 @@ def multi_lineup_choose(request, team_id=None):
|
||||
team_id=request.user.teamsnap_preferences.managed_team_id,
|
||||
)
|
||||
from django.forms import formset_factory
|
||||
|
||||
from pyteamsnap.objects import Event
|
||||
from pyteamsnap.api import Event
|
||||
|
||||
from .forms import EventChooseForm
|
||||
|
||||
|
||||
@@ -1,26 +1,14 @@
|
||||
import logging
|
||||
|
||||
from pyteamsnap.client import TeamSnap
|
||||
|
||||
# This retrieves a Python logging instance (or creates it)
|
||||
logger = logging.getLogger(__name__)
|
||||
import pyteamsnap
|
||||
|
||||
|
||||
def get_teamsnap_client(request):
|
||||
client = request.session.get("teamsnap_client")
|
||||
if client:
|
||||
logger.info("TeamSnap client found saved in session, loading.")
|
||||
return client
|
||||
elif not client:
|
||||
logger.info("No TeamSnap client saved in session, getting one.")
|
||||
request.user.socialaccount_set.filter(provider="teamsnap").first()
|
||||
current_teamsnap_user = request.user.socialaccount_set.filter(
|
||||
provider="teamsnap"
|
||||
).first()
|
||||
request.user.socialaccount_set.filter(provider="teamsnap").first()
|
||||
current_teamsnap_user = request.user.socialaccount_set.filter(
|
||||
provider="teamsnap"
|
||||
).first()
|
||||
|
||||
ts_token = (
|
||||
current_teamsnap_user.socialtoken_set.order_by("-expires_at").first().token
|
||||
)
|
||||
client = TeamSnap(token=ts_token)
|
||||
request.session["teamsnap_client"] = client
|
||||
return client
|
||||
ts_token = (
|
||||
current_teamsnap_user.socialtoken_set.order_by("-expires_at").first().token
|
||||
)
|
||||
|
||||
return pyteamsnap.api.TeamSnap(token=ts_token)
|
||||
|
||||
@@ -116,7 +116,7 @@ def schedule_view(request, team_id=None):
|
||||
client = get_teamsnap_client(request)
|
||||
no_past = bool(request.GET.get("no_past", 0))
|
||||
games_only = bool(request.GET.get("games_only", 0))
|
||||
from pyteamsnap.objects import Event
|
||||
from pyteamsnap.api import Event
|
||||
|
||||
ts_events = Event.search(client, team_id=team_id)
|
||||
if no_past:
|
||||
@@ -143,7 +143,7 @@ def view_event(request, event_id, team_id=None):
|
||||
"teamsnap_event", team_id=request.user.teamsnap_preferences.managed_team_id
|
||||
)
|
||||
|
||||
from pyteamsnap.objects import (
|
||||
from pyteamsnap.api import (
|
||||
AvailabilitySummary,
|
||||
Event,
|
||||
EventLineup,
|
||||
@@ -183,8 +183,7 @@ def view_event(request, event_id, team_id=None):
|
||||
|
||||
def multi_lineup_choose(request, team_id):
|
||||
from django.forms import formset_factory
|
||||
|
||||
from pyteamsnap.objects import Event
|
||||
from pyteamsnap.api import Event
|
||||
|
||||
from .forms import EventChooseForm
|
||||
|
||||
|
||||
Reference in New Issue
Block a user