Revert "incorporate new pyteamsnap, incorporate loading from sessions before creating new client."

This reverts commit cf28a5f133.
This commit is contained in:
2022-06-23 07:44:26 -05:00
parent fe8a6ccad4
commit a0c6582d52
5 changed files with 19 additions and 32 deletions

View File

@@ -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)