resolve merge conflicts

This commit is contained in:
2022-06-10 08:59:22 -05:00
126 changed files with 1459 additions and 299 deletions

View File

@@ -1,6 +1,5 @@
import datetime
import pyteamsnap.api
import requests
from allauth.socialaccount.providers.oauth2.views import (
OAuth2Adapter,
@@ -16,6 +15,7 @@ from gamechanger.models import Player as GamechangerPlayer
from .forms import PreferencesForm
from .models import Preferences
from .provider import TeamsnapProvider
from .utils import get_teamsnap_client
class TeamsnapAdapter(OAuth2Adapter):
@@ -50,19 +50,6 @@ oauth2_login = OAuth2LoginView.adapter_view(TeamsnapAdapter)
oauth2_callback = OAuth2CallbackView.adapter_view(TeamsnapAdapter)
def get_teamsnap_client(request):
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
)
return pyteamsnap.api.TeamSnap(token=ts_token)
class PreferencesFormView(FormView):
template_name = "preferences.html"
form_class = PreferencesForm
@@ -370,45 +357,7 @@ def edit_lineup(request, event_ids, team_id):
}
)
return render(request, "lineup/multiple_edit.html", context={"contexts": contexts})
def dashboard(request, team_id=None):
if not team_id:
return redirect(
"teamsnap_dashboard",
team_id=request.user.teamsnap_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
],
},
)
return render(request, "lineup/edit.html", context={"contexts": contexts})
def submit_lineup(request, team_id, event_id):
@@ -443,8 +392,7 @@ def submit_lineup(request, team_id, event_id):
try:
r.append(event_lineup_entry.put())
except Exception as e:
e
pass
raise e
pass
elif data.get("sequence") is not None and data.get("label"):
event_lineup_entry = EventLineupEntry.new(client)
@@ -489,7 +437,7 @@ def multi_lineup_choose(request, team_id):
formset = EventChooseFormset(request.POST)
return redirect(
"teamsnap_edit_multiple_lineups",
"teamsnap_edit_lineup",
team_id=team_id,
event_ids=",".join(event_ids),
)