From 0c5d6a56eaa449a0c8bd03fd0425ff04736c4fe3 Mon Sep 17 00:00:00 2001 From: Tony Date: Thu, 9 Jun 2022 18:05:00 -0500 Subject: [PATCH] broke out lineup into its own app --- benchcoach/templates/base.html | 2 - config/settings/base.py | 2 +- teamsnap/lineup/__init__.py | 0 teamsnap/lineup/apps.py | 6 + teamsnap/lineup/forms.py | 48 +++ teamsnap/lineup/migrations/__init__.py | 0 .../lineup/static/lineup/js/lineup.js | 4 - teamsnap/lineup/static/lineup/teamsnap.svg | 1 + .../templates/lineup/multiple_choose.html | 0 .../templates/lineup/multiple_edit.html | 3 +- .../templates/lineup/widgets/lineup.html | 0 .../lineup/widgets/lineup_table.html | 0 teamsnap/lineup/tests.py | 3 + teamsnap/lineup/urls.py | 26 ++ teamsnap/lineup/views.py | 288 ++++++++++++++++++ teamsnap/templates/event/instagen.html | 76 ----- teamsnap/templates/lineup/edit.html | 10 - .../templates/lineup/multiple_choose_2.html | 45 --- teamsnap/urls.py | 3 +- 19 files changed, 376 insertions(+), 141 deletions(-) create mode 100644 teamsnap/lineup/__init__.py create mode 100644 teamsnap/lineup/apps.py create mode 100644 teamsnap/lineup/forms.py create mode 100644 teamsnap/lineup/migrations/__init__.py rename benchcoach/static/js/project.js => teamsnap/lineup/static/lineup/js/lineup.js (97%) create mode 100644 teamsnap/lineup/static/lineup/teamsnap.svg rename teamsnap/{ => lineup}/templates/lineup/multiple_choose.html (100%) rename teamsnap/{ => lineup}/templates/lineup/multiple_edit.html (98%) rename teamsnap/{ => lineup}/templates/lineup/widgets/lineup.html (100%) rename teamsnap/{ => lineup}/templates/lineup/widgets/lineup_table.html (100%) create mode 100644 teamsnap/lineup/tests.py create mode 100644 teamsnap/lineup/urls.py create mode 100644 teamsnap/lineup/views.py delete mode 100644 teamsnap/templates/event/instagen.html delete mode 100644 teamsnap/templates/lineup/edit.html delete mode 100644 teamsnap/templates/lineup/multiple_choose_2.html diff --git a/benchcoach/templates/base.html b/benchcoach/templates/base.html index 74d6118..e7acc17 100644 --- a/benchcoach/templates/base.html +++ b/benchcoach/templates/base.html @@ -28,8 +28,6 @@ - - {% endblock javascript %} diff --git a/config/settings/base.py b/config/settings/base.py index c1b3d3e..fbd12aa 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -272,5 +272,5 @@ SOCIALACCOUNT_FORMS = {"signup": "benchcoach.users.forms.UserSocialSignupForm"} # Your stuff... # ------------------------------------------------------------------------------ -INSTALLED_APPS += ["teamsnap", "instagen"] +INSTALLED_APPS += ["teamsnap", "instagen", "teamsnap.lineup"] SOCIALACCOUNT_PROVIDERS = {"teamsnap": {"SCOPE": ["read", "write"]}} diff --git a/teamsnap/lineup/__init__.py b/teamsnap/lineup/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/teamsnap/lineup/apps.py b/teamsnap/lineup/apps.py new file mode 100644 index 0000000..01c53a2 --- /dev/null +++ b/teamsnap/lineup/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class LineupConfig(AppConfig): + default_auto_field = "django.db.models.BigAutoField" + name = "teamsnap.lineup" diff --git a/teamsnap/lineup/forms.py b/teamsnap/lineup/forms.py new file mode 100644 index 0000000..efe9623 --- /dev/null +++ b/teamsnap/lineup/forms.py @@ -0,0 +1,48 @@ +from django import forms +from django.forms import formset_factory + + +class LineupEntryForm(forms.Form): + member = None + availability = None + lineup_entry = None + + event_lineup_entry_id = forms.Field(required=False) + event_lineup_id = forms.Field(required=False) + event_id = forms.Field() + member_id = forms.Field() + position_only = forms.BooleanField(initial=False, required=False) + sequence = forms.IntegerField(required=False) + label = forms.ChoiceField( + required=False, + choices=[ + ("", "--"), + ("P", "P"), + ("C", "C"), + ("1B", "1B"), + ("2B", "2B"), + ("3B", "3B"), + ("SS", "SS"), + ("LF", "LF"), + ("CF", "CF"), + ("RF", "RF"), + ("DH", "DH"), + ("DR", "DR"), + ("EH", "EH"), + ], + widget=forms.Select(attrs={"onchange": "positionSelectChanged(this);"}), + ) + + +LineupEntryFormset = formset_factory( + LineupEntryForm, can_delete=True, can_order=True, extra=0 +) + + +class EventChooseForm(forms.Form): + event_id = forms.ChoiceField() + + +LineupEntryFormset = formset_factory( + LineupEntryForm, can_delete=True, can_order=True, extra=0 +) diff --git a/teamsnap/lineup/migrations/__init__.py b/teamsnap/lineup/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/benchcoach/static/js/project.js b/teamsnap/lineup/static/lineup/js/lineup.js similarity index 97% rename from benchcoach/static/js/project.js rename to teamsnap/lineup/static/lineup/js/lineup.js index 5d43766..9687854 100644 --- a/benchcoach/static/js/project.js +++ b/teamsnap/lineup/static/lineup/js/lineup.js @@ -8,8 +8,6 @@ function positionSelectChanged(elem) { function colorPositions() { for (bcLineup of document.getElementsByClassName("benchcoach-lineup")) { var player_rows = bcLineup.querySelectorAll('tr'); - // player_rows.push.apply(player_rows, document.getElementsByClassName('benchcoach-lineup').querySelectorAll('tr')); - // player_rows.push.apply(player_rows, document.getElementsByClassName('benchcoach-bench').querySelectorAll('tr')); var label_value_array = [] player_rows.forEach(function (player_row, index) { if (player_row.querySelector('[name$="label"]')) { @@ -30,9 +28,7 @@ function colorPositions() { } position_status.classList.add('text-danger') } - // console.dir(position_status) }) - // console.dir(label_value_array) } } diff --git a/teamsnap/lineup/static/lineup/teamsnap.svg b/teamsnap/lineup/static/lineup/teamsnap.svg new file mode 100644 index 0000000..1565893 --- /dev/null +++ b/teamsnap/lineup/static/lineup/teamsnap.svg @@ -0,0 +1 @@ +TeamSnap Logo diff --git a/teamsnap/templates/lineup/multiple_choose.html b/teamsnap/lineup/templates/lineup/multiple_choose.html similarity index 100% rename from teamsnap/templates/lineup/multiple_choose.html rename to teamsnap/lineup/templates/lineup/multiple_choose.html diff --git a/teamsnap/templates/lineup/multiple_edit.html b/teamsnap/lineup/templates/lineup/multiple_edit.html similarity index 98% rename from teamsnap/templates/lineup/multiple_edit.html rename to teamsnap/lineup/templates/lineup/multiple_edit.html index 006fd4d..02fdf06 100644 --- a/teamsnap/templates/lineup/multiple_edit.html +++ b/teamsnap/lineup/templates/lineup/multiple_edit.html @@ -35,13 +35,12 @@ - {% endblock %} {% block inline_javascript %} {{ block.super }} - + - -{% endblock %} diff --git a/teamsnap/templates/lineup/multiple_choose_2.html b/teamsnap/templates/lineup/multiple_choose_2.html deleted file mode 100644 index a21bccf..0000000 --- a/teamsnap/templates/lineup/multiple_choose_2.html +++ /dev/null @@ -1,45 +0,0 @@ -{% extends "base.html" %}{% load static %} -{% block title %} {{ title }}{% endblock %} - -{% csrf_token %} - -{% block page_heading %} -
-
- Schedule -
-
- -{% endblock %} -{% block content %} -
- {{ formset.management_form }} - - {% load tz %} -
- - {# #} - {# #} - - {% for form in formset %} - {{ form.event_id.as_hidden }} - - - - - - - {% endfor %} - -
- {{ form.checked }} - - {{ form.event.data.formatted_title }} - - {{ form.event.data.start_date | localtime}} - - {{ form.event.data.location_name }} -
-
-
-{% endblock %} diff --git a/teamsnap/urls.py b/teamsnap/urls.py index 0e12217..971a548 100644 --- a/teamsnap/urls.py +++ b/teamsnap/urls.py @@ -1,5 +1,5 @@ from allauth.socialaccount.providers.oauth2.urls import default_urlpatterns -from django.urls import path +from django.urls import include, path from .provider import TeamsnapProvider from .views import ( @@ -45,4 +45,5 @@ urlpatterns += [ multi_lineup_choose, name="teamsnap_choose_multiple_lineups", ), + path("", include("teamsnap.lineup.urls")), ]