updates to use pyteamsnap module
This commit is contained in:
@@ -78,17 +78,18 @@ class PreferencesFormView(FormView):
|
||||
"""
|
||||
Returns the initial data to use for forms on this view.
|
||||
"""
|
||||
import pyteamsnap
|
||||
import pyteamsnap.client
|
||||
import pyteamsnap.objects
|
||||
|
||||
ts_account = self.request.user.socialaccount_set.first()
|
||||
ts_token = ts_account.socialtoken_set.first()
|
||||
# ts_token =
|
||||
ts = pyteamsnap.TeamSnap(token=ts_token)
|
||||
ts = pyteamsnap.client.TeamSnap(token=ts_token)
|
||||
|
||||
me = pyteamsnap.api.Me(ts)
|
||||
me = pyteamsnap.objects.Me(ts)
|
||||
|
||||
teams = [
|
||||
(id, pyteamsnap.api.Team.get(ts, id=id))
|
||||
(id, pyteamsnap.objects.Team.get(ts, id=id))
|
||||
for id in me.data["managed_team_ids"]
|
||||
]
|
||||
|
||||
@@ -183,7 +184,6 @@ 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 .forms import EventChooseForm
|
||||
@@ -248,13 +248,13 @@ class OpponentFormView(FormView):
|
||||
def form_valid(self, form):
|
||||
# This method is called when valid form data has been POSTed.
|
||||
# It should return an HttpResponse.
|
||||
import pyteamsnap
|
||||
import pyteamsnap.objects
|
||||
|
||||
ts_client = get_teamsnap_client(self.request)
|
||||
user = pyteamsnap.api.Me(ts_client)
|
||||
user = pyteamsnap.objects.Me(ts_client)
|
||||
team_id = int(self.kwargs.get("team_id"))
|
||||
opponent_id = int(self.kwargs.get("opponent_id"))
|
||||
opponent = pyteamsnap.api.Opponent.get(ts_client, opponent_id)
|
||||
opponent = pyteamsnap.objects.Opponent.get(ts_client, opponent_id)
|
||||
if (
|
||||
team_id in user.data["managed_team_ids"]
|
||||
and opponent.data["team_id"] == team_id
|
||||
|
||||
Reference in New Issue
Block a user