From 2feccf758f3c9a819cbdb7ab12f78fd8e991e207 Mon Sep 17 00:00:00 2001 From: Daniel Engelhardt Date: Sun, 13 Aug 2023 12:34:55 +0200 Subject: [PATCH] Added Kreisliga base setup --- .DS_Store | Bin 6148 -> 6148 bytes .flake8 | 5 + DSTBundesliga/apps/dstffbl/admin.py | 136 +++-- DSTBundesliga/apps/dstffbl/forms.py | 14 +- .../create_leagues_from_invitations.py | 6 +- .../management/commands/import_invitations.py | 14 +- .../management/commands/send_open_emails.py | 2 +- .../commands/update_last_years_leagues.py | 2 +- .../apps/dstffbl/migrations/0001_initial.py | 49 +- .../migrations/0002_auto_20210501_1937.py | 68 ++- .../migrations/0003_auto_20210501_1939.py | 12 +- .../0004_seasonuser_possible_commish.py | 7 +- .../0005_seasonuser_registration_ts.py | 7 +- .../0006_seasonuser_last_years_league.py | 15 +- .../migrations/0007_seasonuser_dst_player.py | 15 +- .../migrations/0008_auto_20210725_0938.py | 7 +- .../migrations/0009_auto_20210725_1424.py | 7 +- .../migrations/0010_seasoninvitation.py | 38 +- .../migrations/0011_auto_20220720_1852.py | 100 +++- .../0012_seasonregistration_send_ts.py | 7 +- .../migrations/0013_auto_20220724_1311.py | 23 +- .../apps/dstffbl/migrations/0014_dstemail.py | 29 +- .../dstffbl/migrations/0015_dstemail_type.py | 16 +- .../migrations/0016_auto_20220724_1336.py | 11 +- .../migrations/0017_auto_20220727_2036.py | 47 +- .../migrations/0018_auto_20230730_1959.py | 11 +- DSTBundesliga/apps/dstffbl/models.py | 170 ++++-- .../apps/dstffbl/services/season_service.py | 115 ++-- .../apps/dstffbl/templatetags/dstffbl_tags.py | 6 +- DSTBundesliga/apps/dstffbl/urls.py | 18 +- DSTBundesliga/apps/dstffbl/views.py | 199 ++++--- DSTBundesliga/apps/leagues/admin.py | 25 +- DSTBundesliga/apps/leagues/cms_menus.py | 88 ++- DSTBundesliga/apps/leagues/config.py | 37 +- .../commands/calc_final_standings.py | 9 +- .../management/commands/delete_old_leagues.py | 13 +- .../commands/set_champions_league.py | 21 +- .../commands/set_listener_league.py | 21 +- .../commands/update_draft_for_league.py | 16 +- .../commands/update_draft_stats_for_season.py | 12 +- .../management/commands/update_drafts.py | 2 +- .../management/commands/update_everything.py | 2 +- .../management/commands/update_leagues.py | 2 +- .../commands/update_listener_draft.py | 2 +- .../commands/update_listener_league.py | 2 +- .../management/commands/update_matchups.py | 2 +- .../management/commands/update_players.py | 2 +- .../management/commands/update_playoffs.py | 2 +- .../leagues/management/commands/update_rss.py | 2 +- .../management/commands/update_stats.py | 2 +- .../commands/update_stats_for_weeks.py | 9 +- .../management/commands/update_trades.py | 4 +- .../apps/leagues/migrations/0001_initial.py | 274 ++++++--- .../migrations/0002_auto_20200711_1232.py | 43 +- .../leagues/migrations/0003_league_region.py | 7 +- .../migrations/0004_auto_20200806_1650.py | 7 +- .../migrations/0005_auto_20200806_1651.py | 7 +- .../migrations/0006_auto_20200806_1711.py | 11 +- .../migrations/0007_auto_20200806_1857.py | 59 +- .../migrations/0008_auto_20200806_1910.py | 15 +- .../migrations/0009_auto_20200806_2116.py | 11 +- .../migrations/0010_auto_20200807_1910.py | 7 +- .../apps/leagues/migrations/0011_news.py | 21 +- .../migrations/0012_auto_20200809_1102.py | 11 +- .../migrations/0013_auto_20200809_1141.py | 7 +- .../migrations/0014_auto_20200816_1703.py | 18 +- .../migrations/0015_league_conference.py | 7 +- .../migrations/0016_auto_20200818_2031.py | 11 +- .../migrations/0017_auto_20200903_2012.py | 23 +- .../apps/leagues/migrations/0018_matchup.py | 37 +- .../migrations/0019_auto_20200915_1913.py | 36 +- .../migrations/0020_auto_20200915_2009.py | 11 +- .../migrations/0021_auto_20201028_1933.py | 21 +- .../migrations/0022_auto_20201028_1936.py | 13 +- .../migrations/0023_auto_20201107_1629.py | 13 +- .../leagues/migrations/0024_news_image.py | 9 +- .../leagues/migrations/0025_playoffmatchup.py | 31 +- .../migrations/0026_playoffmatchup_rank.py | 7 +- .../apps/leagues/migrations/0027_season.py | 21 +- .../leagues/migrations/0028_delete_news.py | 7 +- .../leagues/migrations/0029_league_type.py | 12 +- .../migrations/0030_auto_20210725_1424.py | 7 +- .../migrations/0031_auto_20210808_1100.py | 11 +- .../migrations/0032_auto_20210808_1101.py | 43 +- .../migrations/0033_auto_20210808_1101.py | 43 +- .../migrations/0034_playerdraftstats.py | 40 +- .../leagues/migrations/0035_waiverpickup.py | 46 +- .../migrations/0036_auto_20211016_1344.py | 7 +- .../migrations/0037_auto_20220720_1847.py | 7 +- .../migrations/0038_auto_20220727_2036.py | 55 +- .../migrations/0039_auto_20220727_2121.py | 19 +- .../migrations/0040_auto_20220728_2020.py | 41 +- .../migrations/0041_auto_20220728_2034.py | 17 +- .../migrations/0042_auto_20230730_1959.py | 7 +- DSTBundesliga/apps/leagues/models.py | 114 ++-- DSTBundesliga/apps/leagues/tables.py | 380 +++++++++--- .../apps/leagues/templatetags/league_tags.py | 1 + DSTBundesliga/apps/leagues/urls.py | 54 +- DSTBundesliga/apps/leagues/views.py | 562 ++++++++++++------ DSTBundesliga/apps/services/awards_service.py | 296 +++++---- DSTBundesliga/apps/services/data_services.py | 430 +++++++++----- .../apps/services/patreon_service.py | 21 +- DSTBundesliga/apps/services/rss_service.py | 12 +- DSTBundesliga/apps/services/season_service.py | 98 +-- DSTBundesliga/apps/services/state_service.py | 2 +- DSTBundesliga/asgi.py | 2 +- DSTBundesliga/settings.py | 241 ++++---- DSTBundesliga/urls.py | 20 +- DSTBundesliga/wsgi.py | 2 +- local_settings_example.py | 8 +- manage.py | 4 +- poetry.lock | 139 ++++- pyproject.toml | 4 + 113 files changed, 3198 insertions(+), 1723 deletions(-) create mode 100644 .flake8 diff --git a/.DS_Store b/.DS_Store index 7b3ae374f50f1ae266f096d4aa1ecc90b1faacaa..c5dca30b461a3a456ddd8e27ca0809597d78b5a9 100644 GIT binary patch delta 32 ocmZoMXfc@J&nUPtU^g?P;AS3{XvWPeS>u={HaKl&=lIJH0Hy5;EC2ui delta 79 zcmZoMXfc@J&nUDpU^g?P&}JT%XhuUHhD?TZhD3%x3`q>B3`GpZKz=eq215yh9*{0( fDD%w8Pfp6oPhwzT5CG!!o5NW1nKrX?{N)D#B!Uz6 diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..040b027 --- /dev/null +++ b/.flake8 @@ -0,0 +1,5 @@ +[flake8] +exclude = .git,__pycache__,venv,*/migrations +max-line-length = 120 +per-file-ignores = + */__init__.py: F401 diff --git a/DSTBundesliga/apps/dstffbl/admin.py b/DSTBundesliga/apps/dstffbl/admin.py index 9119664..1196e19 100644 --- a/DSTBundesliga/apps/dstffbl/admin.py +++ b/DSTBundesliga/apps/dstffbl/admin.py @@ -3,62 +3,106 @@ import pytz from django.contrib import admin from django.http import HttpResponse -from django.urls import reverse from django.utils.html import format_html -from DSTBundesliga.apps.dstffbl.models import News, Announcement, SeasonUser, SeasonInvitation, SeasonRegistration, \ - DSTEmail +from DSTBundesliga.apps.dstffbl.models import ( + News, + Announcement, + SeasonUser, + SeasonInvitation, + SeasonRegistration, + DSTEmail, +) def download_season_users_csv(modeladmin, request, queryset): REGION = { - 1: 'Nord', - 2: 'Ost', - 3: 'Süd', - 4: 'West', - 5: 'Ausland', + 1: "Nord", + 2: "Ost", + 3: "Süd", + 4: "West", + 5: "Ausland", } - response = HttpResponse(content_type='text/csv') - response['Content-Disposition'] = 'attachment;filename=season_users.csv' + response = HttpResponse(content_type="text/csv") + response["Content-Disposition"] = "attachment;filename=season_users.csv" writer = csv.writer(response) - writer.writerow(["Email", "Sleeper Username", "Sleeper ID", "Region", "Neuer Spieler", "Liga letzte Saison", - "Liga letzte Saison ID", "Potentieller Komissioner", "Anmeldezeitpunkt"]) + writer.writerow( + [ + "Email", + "Sleeper Username", + "Sleeper ID", + "Region", + "Neuer Spieler", + "Liga letzte Saison", + "Liga letzte Saison ID", + "Potentieller Komissioner", + "Anmeldezeitpunkt", + ] + ) for su in queryset: new_player = "Ja" if su.new_player else "Nein" league, league_id = ( - su.last_years_league.sleeper_name, su.last_years_league.sleeper_id) if su.last_years_league else ("", "") + (su.last_years_league.sleeper_name, su.last_years_league.sleeper_id) + if su.last_years_league + else ("", "") + ) commish = "Ja" if su.possible_commish else "Nein" region = REGION.get(su.region) writer.writerow( - [su.user.email, su.dst_player.display_name, su.sleeper_id, region, new_player, league, league_id, commish, - su.registration.registration_ts.astimezone(pytz.timezone('Europe/Berlin')).strftime("%d.%m.%Y, %H:%M:%S")]) + [ + su.user.email, + su.dst_player.display_name, + su.sleeper_id, + region, + new_player, + league, + league_id, + commish, + su.registration.registration_ts.astimezone( + pytz.timezone("Europe/Berlin") + ).strftime("%d.%m.%Y, %H:%M:%S"), + ] + ) return response class NewsAdmin(admin.ModelAdmin): - list_display = ['date', 'title', 'content'] - ordering = ['-date'] + list_display = ["date", "title", "content"] + ordering = ["-date"] class AnnouncementAdmin(admin.ModelAdmin): - list_display = ['valid_from', 'valid_to', 'content'] - ordering = ['-valid_from', '-valid_to'] + list_display = ["valid_from", "valid_to", "content"] + ordering = ["-valid_from", "-valid_to"] class SeasonUserAdmin(admin.ModelAdmin): def get_sleeper_username(self, obj): return obj.dst_player.display_name - get_sleeper_username.short_description = 'Sleeper Username' - - list_display = ['email', 'get_sleeper_username', 'sleeper_id', 'region', 'new_player', 'last_years_league', - 'possible_commish', 'confirm_ts'] - search_fields = ['user__email', 'dst_player__display_name', 'sleeper_id', 'last_years_league__sleeper_name'] - list_filter = ('season', 'region', 'new_player', 'possible_commish') + get_sleeper_username.short_description = "Sleeper Username" + + list_display = [ + "email", + "get_sleeper_username", + "sleeper_id", + "region", + "new_player", + "last_years_league", + "possible_commish", + "confirm_ts", + ] + search_fields = [ + "user__email", + "dst_player__display_name", + "sleeper_id", + "last_years_league__sleeper_name", + ] + list_filter = ("season", "region", "new_player", "possible_commish") actions = [download_season_users_csv] @@ -66,12 +110,26 @@ class SeasonRegistrationAdmin(admin.ModelAdmin): def get_sleeper_username(self, obj): return obj.dst_player.display_name - get_sleeper_username.short_description = 'Sleeper Username' - - list_display = ['email', 'get_sleeper_username', 'sleeper_id', 'region', 'new_player', 'last_years_league', - 'possible_commish', 'registration_ts', "confirm_registration"] - search_fields = ['user__email', 'dst_player__display_name', 'sleeper_id', 'last_years_league__sleeper_name'] - list_filter = ('season', 'region', 'new_player', 'possible_commish') + get_sleeper_username.short_description = "Sleeper Username" + + list_display = [ + "email", + "get_sleeper_username", + "sleeper_id", + "region", + "new_player", + "last_years_league", + "possible_commish", + "registration_ts", + "confirm_registration", + ] + search_fields = [ + "user__email", + "dst_player__display_name", + "sleeper_id", + "last_years_league__sleeper_name", + ] + list_filter = ("season", "region", "new_player", "possible_commish") def confirm_registration(self, obj): return format_html("Registrierung bestätigen", url=obj.url) @@ -81,15 +139,21 @@ class SeasonInvitationAdmin(admin.ModelAdmin): def get_sleeper_username(self, obj): return obj.season_user.dst_player.display_name - list_display = ['get_sleeper_username', 'sleeper_league_name', 'sleeper_league_id', 'sleeper_league_link', 'created'] - ordering = ['-created', 'sleeper_league_id'] + list_display = [ + "get_sleeper_username", + "sleeper_league_name", + "sleeper_league_id", + "sleeper_league_link", + "created", + ] + ordering = ["-created", "sleeper_league_id"] class DSTEmailAdmin(admin.ModelAdmin): - list_display = ['type', 'recipient', 'subject', 'send_ts', 'has_erros'] - list_filter = ('type', 'has_erros') + list_display = ["type", "recipient", "subject", "send_ts", "has_erros"] + list_filter = ("type", "has_erros") search_fields = ["recipient"] - ordering = ['-send_ts'] + ordering = ["-send_ts"] admin.site.register(News, NewsAdmin) diff --git a/DSTBundesliga/apps/dstffbl/forms.py b/DSTBundesliga/apps/dstffbl/forms.py index 40db07c..5e5f85d 100644 --- a/DSTBundesliga/apps/dstffbl/forms.py +++ b/DSTBundesliga/apps/dstffbl/forms.py @@ -12,14 +12,17 @@ class RegisterForm(forms.Form): def clean_sleeper_username(self): data = self.cleaned_data - sleeper_username = data.get('sleeper_username') + sleeper_username = data.get("sleeper_username") try: sleeper_user = sleeper_wrapper.User(sleeper_username) sleeper_id = sleeper_user.get_user_id() except TypeError: raise forms.ValidationError( - message=_('Dein Sleeper Benutzername scheint falsch zu sein - bitte gib deinen aktuellen Benutzernamen an!')) + message=_( + "Dein Sleeper Benutzername scheint falsch zu sein - bitte gib deinen aktuellen Benutzernamen an!" + ) + ) return sleeper_id @@ -32,13 +35,16 @@ class ProfileForm(forms.Form): def clean_sleeper_username(self): data = self.cleaned_data - sleeper_username = data.get('sleeper_username') + sleeper_username = data.get("sleeper_username") try: sleeper_user = sleeper_wrapper.User(sleeper_username) sleeper_id = sleeper_user.get_user_id() except TypeError: raise forms.ValidationError( - message=_('Dein Sleeper Benutzername scheint falsch zu sein - bitte gib deinen aktuellen Benutzernamen an!')) + message=_( + "Dein Sleeper Benutzername scheint falsch zu sein - bitte gib deinen aktuellen Benutzernamen an!" + ) + ) return sleeper_id diff --git a/DSTBundesliga/apps/dstffbl/management/commands/create_leagues_from_invitations.py b/DSTBundesliga/apps/dstffbl/management/commands/create_leagues_from_invitations.py index 1e85336..d9d7321 100644 --- a/DSTBundesliga/apps/dstffbl/management/commands/create_leagues_from_invitations.py +++ b/DSTBundesliga/apps/dstffbl/management/commands/create_leagues_from_invitations.py @@ -1,10 +1,12 @@ from django.core.management import BaseCommand -from DSTBundesliga.apps.dstffbl.services.season_service import create_leagues_from_invitations +from DSTBundesliga.apps.dstffbl.services.season_service import ( + create_leagues_from_invitations, +) class Command(BaseCommand): - help = 'Create Leagues from the given Invitations' + help = "Create Leagues from the given Invitations" def handle(self, *args, **options): create_leagues_from_invitations() diff --git a/DSTBundesliga/apps/dstffbl/management/commands/import_invitations.py b/DSTBundesliga/apps/dstffbl/management/commands/import_invitations.py index 877a762..a18422b 100644 --- a/DSTBundesliga/apps/dstffbl/management/commands/import_invitations.py +++ b/DSTBundesliga/apps/dstffbl/management/commands/import_invitations.py @@ -1,18 +1,16 @@ from django.core.management import BaseCommand -from DSTBundesliga.apps.dstffbl.services.season_service import update_last_years_leagues, import_invitations +from DSTBundesliga.apps.dstffbl.services.season_service import ( + import_invitations, +) class Command(BaseCommand): - help = 'Import Invitations from CSV File' + help = "Import Invitations from CSV File" def add_arguments(self, parser): - parser.add_argument( - 'filepath', - type=str, - help='Path to CSV File' - ) + parser.add_argument("filepath", type=str, help="Path to CSV File") def handle(self, *args, **options): - filepath = options['filepath'] + filepath = options["filepath"] import_invitations(filepath) diff --git a/DSTBundesliga/apps/dstffbl/management/commands/send_open_emails.py b/DSTBundesliga/apps/dstffbl/management/commands/send_open_emails.py index 793cd6d..7bb6cad 100644 --- a/DSTBundesliga/apps/dstffbl/management/commands/send_open_emails.py +++ b/DSTBundesliga/apps/dstffbl/management/commands/send_open_emails.py @@ -4,7 +4,7 @@ class Command(BaseCommand): - help = 'Send Open Invitations for the current Season.' + help = "Send Open Invitations for the current Season." def handle(self, *args, **options): send_email_chunk() diff --git a/DSTBundesliga/apps/dstffbl/management/commands/update_last_years_leagues.py b/DSTBundesliga/apps/dstffbl/management/commands/update_last_years_leagues.py index 6a19b98..765d1d3 100644 --- a/DSTBundesliga/apps/dstffbl/management/commands/update_last_years_leagues.py +++ b/DSTBundesliga/apps/dstffbl/management/commands/update_last_years_leagues.py @@ -4,7 +4,7 @@ class Command(BaseCommand): - help = 'Updates Season Users last years leagues' + help = "Updates Season Users last years leagues" def handle(self, *args, **options): update_last_years_leagues() diff --git a/DSTBundesliga/apps/dstffbl/migrations/0001_initial.py b/DSTBundesliga/apps/dstffbl/migrations/0001_initial.py index 07a7624..ea52426 100644 --- a/DSTBundesliga/apps/dstffbl/migrations/0001_initial.py +++ b/DSTBundesliga/apps/dstffbl/migrations/0001_initial.py @@ -7,24 +7,55 @@ class Migration(migrations.Migration): - initial = True dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('leagues', '0027_season'), + ("leagues", "0027_season"), ] operations = [ migrations.CreateModel( - name='SeasonUser', + name="SeasonUser", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('sleeper_id', models.CharField(max_length=50)), - ('region', models.IntegerField(choices=[(1, 'Nord'), (2, 'Ost'), (3, 'Süd'), (4, 'West'), (5, 'Ausland')])), - ('new_player', models.BooleanField(default=False)), - ('season', models.ForeignKey(default=DSTBundesliga.apps.leagues.models.Season.get_active, on_delete=django.db.models.deletion.DO_NOTHING, to='leagues.Season')), - ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("sleeper_id", models.CharField(max_length=50)), + ( + "region", + models.IntegerField( + choices=[ + (1, "Nord"), + (2, "Ost"), + (3, "Süd"), + (4, "West"), + (5, "Ausland"), + ] + ), + ), + ("new_player", models.BooleanField(default=False)), + ( + "season", + models.ForeignKey( + default=DSTBundesliga.apps.leagues.models.Season.get_active, + on_delete=django.db.models.deletion.DO_NOTHING, + to="leagues.Season", + ), + ), + ( + "user", + models.OneToOneField( + on_delete=django.db.models.deletion.CASCADE, + to=settings.AUTH_USER_MODEL, + ), + ), ], ), ] diff --git a/DSTBundesliga/apps/dstffbl/migrations/0002_auto_20210501_1937.py b/DSTBundesliga/apps/dstffbl/migrations/0002_auto_20210501_1937.py index 096afeb..01a5cec 100644 --- a/DSTBundesliga/apps/dstffbl/migrations/0002_auto_20210501_1937.py +++ b/DSTBundesliga/apps/dstffbl/migrations/0002_auto_20210501_1937.py @@ -5,40 +5,72 @@ class Migration(migrations.Migration): - dependencies = [ - ('dstffbl', '0001_initial'), + ("dstffbl", "0001_initial"), ] operations = [ migrations.CreateModel( - name='Announcement', + name="Announcement", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('valid_from', models.DateField()), - ('valid_to', models.DateField()), - ('content', tinymce.models.HTMLField()), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("valid_from", models.DateField()), + ("valid_to", models.DateField()), + ("content", tinymce.models.HTMLField()), ], options={ - 'verbose_name_plural': 'Announcements', + "verbose_name_plural": "Announcements", }, ), migrations.CreateModel( - name='News', + name="News", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('title', models.TextField()), - ('content', tinymce.models.HTMLField()), - ('image', models.CharField(default='dst_logo_96.png', max_length=255)), - ('date', models.DateTimeField(auto_now=True)), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("title", models.TextField()), + ("content", tinymce.models.HTMLField()), + ("image", models.CharField(default="dst_logo_96.png", max_length=255)), + ("date", models.DateTimeField(auto_now=True)), ], options={ - 'verbose_name_plural': 'News', + "verbose_name_plural": "News", }, ), migrations.AlterField( - model_name='seasonuser', - name='region', - field=models.IntegerField(choices=[(1, 'Nord (Niedersachsen, Bremen, Hamburg, Mecklenburg-Vorpommern , Schleswig-Holstein)'), (2, 'Ost (Thüringen, Berlin, Sachsen, Sachsen-Anhalt, Brandenburg)'), (3, 'Süd (Bayern, Baden-Württemberg)'), (4, 'West (Nordrhein-Westfalen, Hessen, Saarland, Rheinland-Pfalz)'), (5, 'Ausland')]), + model_name="seasonuser", + name="region", + field=models.IntegerField( + choices=[ + ( + 1, + "Nord (Niedersachsen, Bremen, Hamburg, Mecklenburg-Vorpommern , Schleswig-Holstein)", + ), + ( + 2, + "Ost (Thüringen, Berlin, Sachsen, Sachsen-Anhalt, Brandenburg)", + ), + (3, "Süd (Bayern, Baden-Württemberg)"), + ( + 4, + "West (Nordrhein-Westfalen, Hessen, Saarland, Rheinland-Pfalz)", + ), + (5, "Ausland"), + ] + ), ), ] diff --git a/DSTBundesliga/apps/dstffbl/migrations/0003_auto_20210501_1939.py b/DSTBundesliga/apps/dstffbl/migrations/0003_auto_20210501_1939.py index 4d4757f..11c1680 100644 --- a/DSTBundesliga/apps/dstffbl/migrations/0003_auto_20210501_1939.py +++ b/DSTBundesliga/apps/dstffbl/migrations/0003_auto_20210501_1939.py @@ -4,21 +4,17 @@ def load_news(apps, schema_editor): - OldNews = apps.get_model('leagues', 'News') - News = apps.get_model('dstffbl', 'News') + OldNews = apps.get_model("leagues", "News") + News = apps.get_model("dstffbl", "News") for news in OldNews.objects.all(): News.objects.create( - title=news.title, - content=news.content, - image=news.image, - date=news.date + title=news.title, content=news.content, image=news.image, date=news.date ) class Migration(migrations.Migration): - dependencies = [ - ('dstffbl', '0002_auto_20210501_1937'), + ("dstffbl", "0002_auto_20210501_1937"), ] operations = [ diff --git a/DSTBundesliga/apps/dstffbl/migrations/0004_seasonuser_possible_commish.py b/DSTBundesliga/apps/dstffbl/migrations/0004_seasonuser_possible_commish.py index ea1d9e3..2afb931 100644 --- a/DSTBundesliga/apps/dstffbl/migrations/0004_seasonuser_possible_commish.py +++ b/DSTBundesliga/apps/dstffbl/migrations/0004_seasonuser_possible_commish.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('dstffbl', '0003_auto_20210501_1939'), + ("dstffbl", "0003_auto_20210501_1939"), ] operations = [ migrations.AddField( - model_name='seasonuser', - name='possible_commish', + model_name="seasonuser", + name="possible_commish", field=models.BooleanField(default=False), ), ] diff --git a/DSTBundesliga/apps/dstffbl/migrations/0005_seasonuser_registration_ts.py b/DSTBundesliga/apps/dstffbl/migrations/0005_seasonuser_registration_ts.py index c98c7e0..9376e24 100644 --- a/DSTBundesliga/apps/dstffbl/migrations/0005_seasonuser_registration_ts.py +++ b/DSTBundesliga/apps/dstffbl/migrations/0005_seasonuser_registration_ts.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('dstffbl', '0004_seasonuser_possible_commish'), + ("dstffbl", "0004_seasonuser_possible_commish"), ] operations = [ migrations.AddField( - model_name='seasonuser', - name='registration_ts', + model_name="seasonuser", + name="registration_ts", field=models.DateTimeField(auto_now=True), ), ] diff --git a/DSTBundesliga/apps/dstffbl/migrations/0006_seasonuser_last_years_league.py b/DSTBundesliga/apps/dstffbl/migrations/0006_seasonuser_last_years_league.py index e93ea6c..a0b4be3 100644 --- a/DSTBundesliga/apps/dstffbl/migrations/0006_seasonuser_last_years_league.py +++ b/DSTBundesliga/apps/dstffbl/migrations/0006_seasonuser_last_years_league.py @@ -5,16 +5,19 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0029_league_type'), - ('dstffbl', '0005_seasonuser_registration_ts'), + ("leagues", "0029_league_type"), + ("dstffbl", "0005_seasonuser_registration_ts"), ] operations = [ migrations.AddField( - model_name='seasonuser', - name='last_years_league', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='leagues.league'), + model_name="seasonuser", + name="last_years_league", + field=models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.SET_NULL, + to="leagues.league", + ), ), ] diff --git a/DSTBundesliga/apps/dstffbl/migrations/0007_seasonuser_dst_player.py b/DSTBundesliga/apps/dstffbl/migrations/0007_seasonuser_dst_player.py index 8d8d4e2..539b88f 100644 --- a/DSTBundesliga/apps/dstffbl/migrations/0007_seasonuser_dst_player.py +++ b/DSTBundesliga/apps/dstffbl/migrations/0007_seasonuser_dst_player.py @@ -5,16 +5,19 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0029_league_type'), - ('dstffbl', '0006_seasonuser_last_years_league'), + ("leagues", "0029_league_type"), + ("dstffbl", "0006_seasonuser_last_years_league"), ] operations = [ migrations.AddField( - model_name='seasonuser', - name='dst_player', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='leagues.dstplayer'), + model_name="seasonuser", + name="dst_player", + field=models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.CASCADE, + to="leagues.dstplayer", + ), ), ] diff --git a/DSTBundesliga/apps/dstffbl/migrations/0008_auto_20210725_0938.py b/DSTBundesliga/apps/dstffbl/migrations/0008_auto_20210725_0938.py index e843bc4..a337b7b 100644 --- a/DSTBundesliga/apps/dstffbl/migrations/0008_auto_20210725_0938.py +++ b/DSTBundesliga/apps/dstffbl/migrations/0008_auto_20210725_0938.py @@ -4,8 +4,8 @@ def assign_dst_players_to_season_users(apps, schema_editor): - SeasonUser = apps.get_model('dstffbl', 'SeasonUser') - DSTPlayer = apps.get_model('leagues', 'DSTPlayer') + SeasonUser = apps.get_model("dstffbl", "SeasonUser") + DSTPlayer = apps.get_model("leagues", "DSTPlayer") for su in SeasonUser.objects.all(): try: @@ -17,9 +17,8 @@ def assign_dst_players_to_season_users(apps, schema_editor): class Migration(migrations.Migration): - dependencies = [ - ('dstffbl', '0007_seasonuser_dst_player'), + ("dstffbl", "0007_seasonuser_dst_player"), ] operations = [ diff --git a/DSTBundesliga/apps/dstffbl/migrations/0009_auto_20210725_1424.py b/DSTBundesliga/apps/dstffbl/migrations/0009_auto_20210725_1424.py index f7da42d..304de0e 100644 --- a/DSTBundesliga/apps/dstffbl/migrations/0009_auto_20210725_1424.py +++ b/DSTBundesliga/apps/dstffbl/migrations/0009_auto_20210725_1424.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('dstffbl', '0008_auto_20210725_0938'), + ("dstffbl", "0008_auto_20210725_0938"), ] operations = [ migrations.AlterField( - model_name='seasonuser', - name='registration_ts', + model_name="seasonuser", + name="registration_ts", field=models.DateTimeField(auto_now_add=True), ), ] diff --git a/DSTBundesliga/apps/dstffbl/migrations/0010_seasoninvitation.py b/DSTBundesliga/apps/dstffbl/migrations/0010_seasoninvitation.py index 51798c6..ceb5137 100644 --- a/DSTBundesliga/apps/dstffbl/migrations/0010_seasoninvitation.py +++ b/DSTBundesliga/apps/dstffbl/migrations/0010_seasoninvitation.py @@ -5,24 +5,38 @@ class Migration(migrations.Migration): - dependencies = [ - ('dstffbl', '0009_auto_20210725_1424'), + ("dstffbl", "0009_auto_20210725_1424"), ] operations = [ migrations.CreateModel( - name='SeasonInvitation', + name="SeasonInvitation", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('sleeper_username', models.CharField(max_length=50)), - ('sleeper_league_name', models.CharField(max_length=100)), - ('sleeper_league_id', models.CharField(max_length=50)), - ('sleeper_league_link', models.CharField(max_length=500)), - ('send_ts', models.DateTimeField(null=True)), - ('has_erros', models.BooleanField(default=False)), - ('error_message', models.CharField(max_length=500)), - ('season_user', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='dstffbl.seasonuser')), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("sleeper_username", models.CharField(max_length=50)), + ("sleeper_league_name", models.CharField(max_length=100)), + ("sleeper_league_id", models.CharField(max_length=50)), + ("sleeper_league_link", models.CharField(max_length=500)), + ("send_ts", models.DateTimeField(null=True)), + ("has_erros", models.BooleanField(default=False)), + ("error_message", models.CharField(max_length=500)), + ( + "season_user", + models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.SET_NULL, + to="dstffbl.seasonuser", + ), + ), ], ), ] diff --git a/DSTBundesliga/apps/dstffbl/migrations/0011_auto_20220720_1852.py b/DSTBundesliga/apps/dstffbl/migrations/0011_auto_20220720_1852.py index 640499d..2db2503 100644 --- a/DSTBundesliga/apps/dstffbl/migrations/0011_auto_20220720_1852.py +++ b/DSTBundesliga/apps/dstffbl/migrations/0011_auto_20220720_1852.py @@ -8,41 +8,99 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0037_auto_20220720_1847'), + ("leagues", "0037_auto_20220720_1847"), migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('dstffbl', '0010_seasoninvitation'), + ("dstffbl", "0010_seasoninvitation"), ] operations = [ migrations.RemoveField( - model_name='seasonuser', - name='registration_ts', + model_name="seasonuser", + name="registration_ts", ), migrations.AddField( - model_name='seasonuser', - name='confirm_ts', + model_name="seasonuser", + name="confirm_ts", field=models.DateTimeField(auto_now_add=True, null=True), ), migrations.CreateModel( - name='SeasonRegistration', + name="SeasonRegistration", fields=[ - ('id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), - ('sleeper_id', models.CharField(max_length=50)), - ('region', models.IntegerField(choices=[(1, 'Nord (Niedersachsen, Bremen, Hamburg, Mecklenburg-Vorpommern , Schleswig-Holstein)'), (2, 'Ost (Thüringen, Berlin, Sachsen, Sachsen-Anhalt, Brandenburg)'), (3, 'Süd (Bayern, Baden-Württemberg)'), (4, 'West (Nordrhein-Westfalen, Hessen, Saarland, Rheinland-Pfalz)'), (5, 'Ausland')])), - ('new_player', models.BooleanField(default=False)), - ('possible_commish', models.BooleanField(default=False)), - ('registration_ts', models.DateTimeField(auto_now_add=True)), - ('dst_player', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='leagues.dstplayer')), - ('last_years_league', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='leagues.league')), - ('season', models.ForeignKey(default=DSTBundesliga.apps.leagues.models.Season.get_active, on_delete=django.db.models.deletion.DO_NOTHING, to='leagues.season')), - ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ( + "id", + models.UUIDField( + default=uuid.uuid4, + editable=False, + primary_key=True, + serialize=False, + ), + ), + ("sleeper_id", models.CharField(max_length=50)), + ( + "region", + models.IntegerField( + choices=[ + ( + 1, + "Nord (Niedersachsen, Bremen, Hamburg, Mecklenburg-Vorpommern , Schleswig-Holstein)", + ), + ( + 2, + "Ost (Thüringen, Berlin, Sachsen, Sachsen-Anhalt, Brandenburg)", + ), + (3, "Süd (Bayern, Baden-Württemberg)"), + ( + 4, + "West (Nordrhein-Westfalen, Hessen, Saarland, Rheinland-Pfalz)", + ), + (5, "Ausland"), + ] + ), + ), + ("new_player", models.BooleanField(default=False)), + ("possible_commish", models.BooleanField(default=False)), + ("registration_ts", models.DateTimeField(auto_now_add=True)), + ( + "dst_player", + models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.CASCADE, + to="leagues.dstplayer", + ), + ), + ( + "last_years_league", + models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.SET_NULL, + to="leagues.league", + ), + ), + ( + "season", + models.ForeignKey( + default=DSTBundesliga.apps.leagues.models.Season.get_active, + on_delete=django.db.models.deletion.DO_NOTHING, + to="leagues.season", + ), + ), + ( + "user", + models.OneToOneField( + on_delete=django.db.models.deletion.CASCADE, + to=settings.AUTH_USER_MODEL, + ), + ), ], ), migrations.AddField( - model_name='seasonuser', - name='registration', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='dstffbl.seasonregistration'), + model_name="seasonuser", + name="registration", + field=models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.CASCADE, + to="dstffbl.seasonregistration", + ), ), ] diff --git a/DSTBundesliga/apps/dstffbl/migrations/0012_seasonregistration_send_ts.py b/DSTBundesliga/apps/dstffbl/migrations/0012_seasonregistration_send_ts.py index 21d752d..34f3195 100644 --- a/DSTBundesliga/apps/dstffbl/migrations/0012_seasonregistration_send_ts.py +++ b/DSTBundesliga/apps/dstffbl/migrations/0012_seasonregistration_send_ts.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('dstffbl', '0011_auto_20220720_1852'), + ("dstffbl", "0011_auto_20220720_1852"), ] operations = [ migrations.AddField( - model_name='seasonregistration', - name='send_ts', + model_name="seasonregistration", + name="send_ts", field=models.DateTimeField(null=True), ), ] diff --git a/DSTBundesliga/apps/dstffbl/migrations/0013_auto_20220724_1311.py b/DSTBundesliga/apps/dstffbl/migrations/0013_auto_20220724_1311.py index 40995ca..f281183 100644 --- a/DSTBundesliga/apps/dstffbl/migrations/0013_auto_20220724_1311.py +++ b/DSTBundesliga/apps/dstffbl/migrations/0013_auto_20220724_1311.py @@ -4,31 +4,30 @@ class Migration(migrations.Migration): - dependencies = [ - ('dstffbl', '0012_seasonregistration_send_ts'), + ("dstffbl", "0012_seasonregistration_send_ts"), ] operations = [ migrations.RemoveField( - model_name='seasoninvitation', - name='error_message', + model_name="seasoninvitation", + name="error_message", ), migrations.RemoveField( - model_name='seasoninvitation', - name='has_erros', + model_name="seasoninvitation", + name="has_erros", ), migrations.RemoveField( - model_name='seasoninvitation', - name='send_ts', + model_name="seasoninvitation", + name="send_ts", ), migrations.RemoveField( - model_name='seasonregistration', - name='send_ts', + model_name="seasonregistration", + name="send_ts", ), migrations.AddField( - model_name='seasoninvitation', - name='created', + model_name="seasoninvitation", + name="created", field=models.DateTimeField(auto_now=True), ), ] diff --git a/DSTBundesliga/apps/dstffbl/migrations/0014_dstemail.py b/DSTBundesliga/apps/dstffbl/migrations/0014_dstemail.py index edff9b2..e111c8b 100644 --- a/DSTBundesliga/apps/dstffbl/migrations/0014_dstemail.py +++ b/DSTBundesliga/apps/dstffbl/migrations/0014_dstemail.py @@ -4,23 +4,30 @@ class Migration(migrations.Migration): - dependencies = [ - ('dstffbl', '0013_auto_20220724_1311'), + ("dstffbl", "0013_auto_20220724_1311"), ] operations = [ migrations.CreateModel( - name='DSTEmail', + name="DSTEmail", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('recipient', models.EmailField(max_length=254)), - ('subject', models.CharField(max_length=998)), - ('text', models.TextField()), - ('html', models.TextField()), - ('send_ts', models.DateTimeField(null=True)), - ('has_erros', models.BooleanField(default=False)), - ('error_message', models.CharField(max_length=500)), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("recipient", models.EmailField(max_length=254)), + ("subject", models.CharField(max_length=998)), + ("text", models.TextField()), + ("html", models.TextField()), + ("send_ts", models.DateTimeField(null=True)), + ("has_erros", models.BooleanField(default=False)), + ("error_message", models.CharField(max_length=500)), ], ), ] diff --git a/DSTBundesliga/apps/dstffbl/migrations/0015_dstemail_type.py b/DSTBundesliga/apps/dstffbl/migrations/0015_dstemail_type.py index bfe18de..e9b3d5f 100644 --- a/DSTBundesliga/apps/dstffbl/migrations/0015_dstemail_type.py +++ b/DSTBundesliga/apps/dstffbl/migrations/0015_dstemail_type.py @@ -4,16 +4,22 @@ class Migration(migrations.Migration): - dependencies = [ - ('dstffbl', '0014_dstemail'), + ("dstffbl", "0014_dstemail"), ] operations = [ migrations.AddField( - model_name='dstemail', - name='type', - field=models.IntegerField(choices=[(1, 'CONFIRM_REGISTRATION'), (2, 'REGISTRATION_SUCCESSFUL'), (3, 'LEAGUE_INVITATION')], default=1), + model_name="dstemail", + name="type", + field=models.IntegerField( + choices=[ + (1, "CONFIRM_REGISTRATION"), + (2, "REGISTRATION_SUCCESSFUL"), + (3, "LEAGUE_INVITATION"), + ], + default=1, + ), preserve_default=False, ), ] diff --git a/DSTBundesliga/apps/dstffbl/migrations/0016_auto_20220724_1336.py b/DSTBundesliga/apps/dstffbl/migrations/0016_auto_20220724_1336.py index dfa0368..de76fbd 100644 --- a/DSTBundesliga/apps/dstffbl/migrations/0016_auto_20220724_1336.py +++ b/DSTBundesliga/apps/dstffbl/migrations/0016_auto_20220724_1336.py @@ -6,16 +6,17 @@ class Migration(migrations.Migration): - dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('dstffbl', '0015_dstemail_type'), + ("dstffbl", "0015_dstemail_type"), ] operations = [ migrations.AlterField( - model_name='seasonuser', - name='user', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + model_name="seasonuser", + name="user", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL + ), ), ] diff --git a/DSTBundesliga/apps/dstffbl/migrations/0017_auto_20220727_2036.py b/DSTBundesliga/apps/dstffbl/migrations/0017_auto_20220727_2036.py index f3c58ac..ab4d396 100644 --- a/DSTBundesliga/apps/dstffbl/migrations/0017_auto_20220727_2036.py +++ b/DSTBundesliga/apps/dstffbl/migrations/0017_auto_20220727_2036.py @@ -4,20 +4,51 @@ class Migration(migrations.Migration): - dependencies = [ - ('dstffbl', '0016_auto_20220724_1336'), + ("dstffbl", "0016_auto_20220724_1336"), ] operations = [ migrations.AlterField( - model_name='seasonregistration', - name='region', - field=models.IntegerField(choices=[(1, 'Nord (Niedersachsen, Bremen, Hamburg, Mecklenburg-Vorpommern , Schleswig-Holstein)'), (2, 'Ost (Thüringen, Berlin, Sachsen, Sachsen-Anhalt, Brandenburg)'), (3, 'Süd (Bayern, Baden-Württemberg)'), (4, 'West (Nordrhein-Westfalen, Hessen, Saarland, Rheinland-Pfalz)')]), + model_name="seasonregistration", + name="region", + field=models.IntegerField( + choices=[ + ( + 1, + "Nord (Niedersachsen, Bremen, Hamburg, Mecklenburg-Vorpommern , Schleswig-Holstein)", + ), + ( + 2, + "Ost (Thüringen, Berlin, Sachsen, Sachsen-Anhalt, Brandenburg)", + ), + (3, "Süd (Bayern, Baden-Württemberg)"), + ( + 4, + "West (Nordrhein-Westfalen, Hessen, Saarland, Rheinland-Pfalz)", + ), + ] + ), ), migrations.AlterField( - model_name='seasonuser', - name='region', - field=models.IntegerField(choices=[(1, 'Nord (Niedersachsen, Bremen, Hamburg, Mecklenburg-Vorpommern , Schleswig-Holstein)'), (2, 'Ost (Thüringen, Berlin, Sachsen, Sachsen-Anhalt, Brandenburg)'), (3, 'Süd (Bayern, Baden-Württemberg)'), (4, 'West (Nordrhein-Westfalen, Hessen, Saarland, Rheinland-Pfalz)')]), + model_name="seasonuser", + name="region", + field=models.IntegerField( + choices=[ + ( + 1, + "Nord (Niedersachsen, Bremen, Hamburg, Mecklenburg-Vorpommern , Schleswig-Holstein)", + ), + ( + 2, + "Ost (Thüringen, Berlin, Sachsen, Sachsen-Anhalt, Brandenburg)", + ), + (3, "Süd (Bayern, Baden-Württemberg)"), + ( + 4, + "West (Nordrhein-Westfalen, Hessen, Saarland, Rheinland-Pfalz)", + ), + ] + ), ), ] diff --git a/DSTBundesliga/apps/dstffbl/migrations/0018_auto_20230730_1959.py b/DSTBundesliga/apps/dstffbl/migrations/0018_auto_20230730_1959.py index e1deeb3..6298ae6 100644 --- a/DSTBundesliga/apps/dstffbl/migrations/0018_auto_20230730_1959.py +++ b/DSTBundesliga/apps/dstffbl/migrations/0018_auto_20230730_1959.py @@ -6,16 +6,17 @@ class Migration(migrations.Migration): - dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('dstffbl', '0017_auto_20220727_2036'), + ("dstffbl", "0017_auto_20220727_2036"), ] operations = [ migrations.AlterField( - model_name='seasonregistration', - name='user', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + model_name="seasonregistration", + name="user", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL + ), ), ] diff --git a/DSTBundesliga/apps/dstffbl/models.py b/DSTBundesliga/apps/dstffbl/models.py index daffb8c..41d459c 100644 --- a/DSTBundesliga/apps/dstffbl/models.py +++ b/DSTBundesliga/apps/dstffbl/models.py @@ -14,7 +14,13 @@ from django.db import models from django.utils import timezone -from DSTBundesliga.apps.leagues.models import Season, DSTPlayer, League +from DSTBundesliga.apps.leagues.models import ( + Season, + DSTPlayer, + League, + Roster, + FinalSeasonStanding, +) from DSTBundesliga.apps.services.state_service import StateService state_service = StateService() @@ -23,14 +29,17 @@ EMAIL_TYPES = ( (1, "CONFIRM_REGISTRATION"), (2, "REGISTRATION_SUCCESSFUL"), - (3, "LEAGUE_INVITATION") + (3, "LEAGUE_INVITATION"), ) REGIONS = ( - (1, 'Nord (Niedersachsen, Bremen, Hamburg, Mecklenburg-Vorpommern , Schleswig-Holstein)'), - (2, 'Ost (Thüringen, Berlin, Sachsen, Sachsen-Anhalt, Brandenburg)'), - (3, 'Süd (Bayern, Baden-Württemberg)'), - (4, 'West (Nordrhein-Westfalen, Hessen, Saarland, Rheinland-Pfalz)'), + ( + 1, + "Nord (Niedersachsen, Bremen, Hamburg, Mecklenburg-Vorpommern , Schleswig-Holstein)", + ), + (2, "Ost (Thüringen, Berlin, Sachsen, Sachsen-Anhalt, Brandenburg)"), + (3, "Süd (Bayern, Baden-Württemberg)"), + (4, "West (Nordrhein-Westfalen, Hessen, Saarland, Rheinland-Pfalz)"), ) @@ -60,7 +69,7 @@ def send_mail(self): None, None, None, - self.html + self.html, ) success = True @@ -90,7 +99,6 @@ def send_mail(self): class EmailCreationMixin: - def get_email_to(self): pass @@ -109,38 +117,40 @@ def create_mail(self): subject=self.get_email_subject(), text=self.get_email_text(), html=self.get_email_html(), - type=self.get_email_type() + type=self.get_email_type(), ) class SeasonRegistration(models.Model, EmailCreationMixin): - EMAIL_SUBJECT = 'Bitte bestätige deine Anmmeldung zur Down, Set, Talk! Fantasy Football Bundesliga {current_season}' + EMAIL_SUBJECT = "Bitte bestätige deine Anmmeldung zur Down, Set, Talk! Fantasy Football Bundesliga {current_season}" - EMAIL_TEXT = '''' + EMAIL_TEXT = """' Hallo {sleeper_name}, - + bitte bestätige deine Anmeldung zur Saison {current_season}, indem du den folgenden Link aufrufst: {confirm_link} - + Beste Grüße von Michael und dem gesamten Organisationsteam der DSTFanFooBL - ''' + """ - EMAIL_HTML = ''' + EMAIL_HTML = """

Hallo {sleeper_name},

- +

bitte bestätige deine Anmeldung zur Saison {current_season}, indem du den folgenden Link aufrufst:

- +

{confirm_link}

- +

Beste Grüße von
Michael und dem gesamten Organisationsteam der DSTFanFooBL

- ''' + """ id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) user = models.ForeignKey(User, on_delete=models.CASCADE) dst_player = models.ForeignKey(DSTPlayer, on_delete=models.CASCADE, null=True) - season = models.ForeignKey(Season, on_delete=models.DO_NOTHING, default=Season.get_active) + season = models.ForeignKey( + Season, on_delete=models.DO_NOTHING, default=Season.get_active + ) sleeper_id = models.CharField(max_length=50) region = models.IntegerField(choices=REGIONS) new_player = models.BooleanField(default=False) @@ -155,17 +165,23 @@ def get_email_subject(self): return self.EMAIL_SUBJECT.format(current_season=Season.get_active()) def get_confirm_link(self): - return "https://www.fantasybundesliga.de" + reverse('dstffbl:accept_invite', kwargs={"registration_id": self.id}) + return "https://www.fantasybundesliga.de" + reverse( + "dstffbl:accept_invite", kwargs={"registration_id": self.id} + ) def get_email_text(self): - return self.EMAIL_TEXT.format(current_season=state_service.get_season(), - sleeper_name=self.dst_player.display_name, - confirm_link=self.get_confirm_link()) + return self.EMAIL_TEXT.format( + current_season=state_service.get_season(), + sleeper_name=self.dst_player.display_name, + confirm_link=self.get_confirm_link(), + ) def get_email_html(self): - return self.EMAIL_HTML.format(current_season=state_service.get_season(), - sleeper_name=self.dst_player.display_name, - confirm_link=self.get_confirm_link()) + return self.EMAIL_HTML.format( + current_season=state_service.get_season(), + sleeper_name=self.dst_player.display_name, + confirm_link=self.get_confirm_link(), + ) def get_email_to(self): return self.user.email @@ -181,8 +197,12 @@ def url(self): class SeasonUser(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) dst_player = models.ForeignKey(DSTPlayer, on_delete=models.CASCADE, null=True) - registration = models.ForeignKey(SeasonRegistration, on_delete=models.CASCADE, null=True) - season = models.ForeignKey(Season, on_delete=models.DO_NOTHING, default=Season.get_active) + registration = models.ForeignKey( + SeasonRegistration, on_delete=models.CASCADE, null=True + ) + season = models.ForeignKey( + Season, on_delete=models.DO_NOTHING, default=Season.get_active + ) sleeper_id = models.CharField(max_length=50) region = models.IntegerField(choices=REGIONS) new_player = models.BooleanField(default=False) @@ -193,44 +213,56 @@ class SeasonUser(models.Model): def email(self): return self.user.email + def get_last_season_roster(self): + try: + return Roster.objects.get(season=Season.get_last(), owner=self.dst_player) + except Roster.DoesNotExist: + return None + + def get_last_season_standing(self): + try: + FinalSeasonStanding.objects.get(roster=self.get_last_season_roster()) + except FinalSeasonStanding.DoesNotExist: + return None + class SeasonInvitation(models.Model, EmailCreationMixin): - EMAIL_SUBJECT = 'Deine Einladung zur Down, Set, Talk! Fantasy Football Bundesliga {current_season}' + EMAIL_SUBJECT = "Deine Einladung zur Down, Set, Talk! Fantasy Football Bundesliga {current_season}" - EMAIL_TEXT = '''' + EMAIL_TEXT = """' Hallo {sleeper_name}, - + wir freuen uns sehr, dass du dich für die Saison {season} der Down, Set, Talk! Fantasy Football Bundesliga angemeldet hast. Jetzt dürfen wir dich in deine Liga einladen. - + Du wirst in der {league_name} spielen. In deine Liga kommst du über diesen Link: {league_link} - + Weitere Informationen findest du als angepinnte Nachricht in deiner Liga. Bitte beachte, dass du die Einladung in deine Liga bis zum 20. August 2022 um 24:00 Uhr angenommen haben musst. Ansonsten müssen wir deinen Platz leider an eine(n) andere(n) Mitspieler(in) vergeben. Da wir aber davon ausgehen, dass dies nicht erfolgen muss, wünschen wir dir viel Erfolg und vor allem Spaß in der kommenden Fantasy-Saison. - + Beste Grüße von Michael und dem gesamten Organisationsteam der DSTFanFooBL - - PS: Bei Fragen kannst du dich jederzeit gerne an uns wenden. Du findest uns bei Twitter und Instagram unter @dstfanfoobl. Hört auch gerne mal in unseren Podcast zur DSTFanFooBL rein: https://anchor.fm/dstfanfoobl - ''' - EMAIL_HTML = ''' + PS: Bei Fragen kannst du dich jederzeit gerne an uns wenden. Du findest uns bei Twitter und Instagram unter @dstfanfoobl. Hört auch gerne mal in unseren Podcast zur DSTFanFooBL rein: https://anchor.fm/dstfanfoobl + """ + + EMAIL_HTML = """

Hallo {sleeper_name},

- +

wir freuen uns sehr, dass du dich für die Saison {season} der Down, Set, Talk! Fantasy Football Bundesliga angemeldet hast. Jetzt dürfen wir dich in deine Liga einladen.

- +

Du wirst in der {league_name} spielen. In deine Liga kommst du über diesen Link: {league_link}

- +

Weitere Informationen findest du als angepinnte Nachricht in deiner Liga. Bitte beachte, dass du die Einladung in deine Liga bis zum 20. August 2022 um 24:00 Uhr angenommen haben musst. Ansonsten müssen wir deinen Platz leider an eine(n) andere(n) Mitspieler(in) vergeben. Da wir aber davon ausgehen, dass dies nicht erfolgen muss, wünschen wir dir viel Erfolg und vor allem Spaß in der kommenden Fantasy-Saison.

- +

Beste Grüße von
Michael und dem gesamten Organisationsteam der DSTFanFooBL

- +
-

PS: Bei Fragen kannst du dich jederzeit gerne an uns wenden. Du findest uns bei Twitter und Instagram unter @dstfanfoobl. Hör auch gerne mal in unseren Podcast zur DSTFanFooBL rein!

- ''' +

PS: Bei Fragen kannst du dich jederzeit gerne an uns wenden. Du findest uns bei Twitter und Instagram unter @dstfanfoobl. Hör auch gerne mal in unseren Podcast zur DSTFanFooBL rein!

+ """ season_user = models.ForeignKey(SeasonUser, on_delete=models.SET_NULL, null=True) sleeper_username = models.CharField(max_length=50) @@ -243,16 +275,20 @@ def get_email_subject(self): return self.EMAIL_SUBJECT.format(current_season=Season.get_active()) def get_email_text(self): - return self.EMAIL_TEXT.format(season=state_service.get_season(), - sleeper_name=self.sleeper_username, - league_name=self.sleeper_league_name, - league_link=self.sleeper_league_link) + return self.EMAIL_TEXT.format( + season=state_service.get_season(), + sleeper_name=self.sleeper_username, + league_name=self.sleeper_league_name, + league_link=self.sleeper_league_link, + ) def get_email_html(self): - return self.EMAIL_HTML.format(season=state_service.get_season(), - sleeper_name=self.sleeper_username, - league_name=self.sleeper_league_name, - league_link=self.sleeper_league_link) + return self.EMAIL_HTML.format( + season=state_service.get_season(), + sleeper_name=self.sleeper_username, + league_name=self.sleeper_league_name, + league_link=self.sleeper_league_link, + ) def get_email_to(self): return self.season_user.user.email @@ -284,28 +320,34 @@ class Meta: title = models.TextField() content = HTMLField() - image = models.CharField(null=False, blank=False, default=settings.DEFAULT_NEWS_LOGO, max_length=255) + image = models.CharField( + null=False, blank=False, default=settings.DEFAULT_NEWS_LOGO, max_length=255 + ) date = models.DateTimeField(auto_now=True) class CustomSocialAccountAdapter(DefaultSocialAccountAdapter): - def populate_user(self, request, sociallogin, data): user = super().populate_user(request, sociallogin, data) user.username = user.email return user def authentication_error( - self, - request, - provider_id, - error=None, - exception=None, - extra_context=None, + self, + request, + provider_id, + error=None, + exception=None, + extra_context=None, ): import traceback + logger.exception( "\nerror: {error}\nexception: {exception}\nextra_content: {extra_context}\nstacktrace: {trace}\nrequest: {request}".format( - error=error, exception=exception, extra_context=extra_context, trace=traceback.format_exc(), - request=request.__dict__) + error=error, + exception=exception, + extra_context=extra_context, + trace=traceback.format_exc(), + request=request.__dict__, + ) ) diff --git a/DSTBundesliga/apps/dstffbl/services/season_service.py b/DSTBundesliga/apps/dstffbl/services/season_service.py index f486e2f..edc0d30 100644 --- a/DSTBundesliga/apps/dstffbl/services/season_service.py +++ b/DSTBundesliga/apps/dstffbl/services/season_service.py @@ -5,14 +5,25 @@ from django.db.models import Window, F from django.db.models.functions import RowNumber -from DSTBundesliga.apps.dstffbl.models import SeasonUser, SeasonInvitation, SeasonRegistration, DSTEmail +from DSTBundesliga.apps.dstffbl.models import ( + SeasonUser, + SeasonInvitation, + SeasonRegistration, + DSTEmail, +) from DSTBundesliga.apps.leagues.models import DSTPlayer, League, Season -from DSTBundesliga.apps.services.data_services import LeagueSetting, guess_level, guess_conference, guess_region, \ - update_or_create_league, get_league_data - -EMAIL_SUBJECT = 'Anmeldung erfolgreich!' - -EMAIL_TEXT = '''' +from DSTBundesliga.apps.services.data_services import ( + LeagueSetting, + guess_level, + guess_conference, + guess_region, + update_or_create_league, + get_league_data, +) + +EMAIL_SUBJECT = "Anmeldung erfolgreich!" + +EMAIL_TEXT = """' Hallo {sleeper_name}, Du bist für die Saison {current_season} angemeldet! Weitere Infos folgen in einigen Tagen per Mail und über unsere @@ -20,9 +31,9 @@ Beste Grüße von Michael und dem gesamten Organisationsteam der DSTFanFooBL - ''' + """ -EMAIL_HTML = ''' +EMAIL_HTML = """

Hallo {sleeper_name},

Du bist für die Saison {current_season} angemeldet! Weitere Infos folgen in einigen Tagen per Mail und über @@ -30,19 +41,23 @@

Beste Grüße von
Michael und dem gesamten Organisationsteam der DSTFanFooBL

- ''' + """ def get_last_years_league(player: DSTPlayer): try: - return League.objects.filter(season=Season.get_last(), - id__in=[r.league.id for r in player.roster_set.all()]).get(type=League.BUNDESLIGA) + return League.objects.filter( + season=Season.get_last(), + id__in=[r.league.id for r in player.roster_set.all()], + ).get(type=League.BUNDESLIGA) except League.DoesNotExist: return None def update_last_years_leagues(): - for su in SeasonUser.objects.filter(season=Season.get_active(), last_years_league=None): + for su in SeasonUser.objects.filter( + season=Season.get_active(), last_years_league=None + ): try: dst_player = DSTPlayer.objects.get(sleeper_id=su.sleeper_id) su.last_years_league = get_last_years_league(dst_player) @@ -71,9 +86,9 @@ def create_season_users(users): last_years_league = get_last_years_league(player=dst_player) new_player = False except DSTPlayer.DoesNotExist: - dst_player, _ = DSTPlayer.objects.update_or_create(sleeper_id=sleeper_id, defaults={ - "display_name": sleeper_username - }) + dst_player, _ = DSTPlayer.objects.update_or_create( + sleeper_id=sleeper_id, defaults={"display_name": sleeper_username} + ) dummy_user, _ = User.objects.get_or_create(username=email, email=email) @@ -85,7 +100,7 @@ def create_season_users(users): new_player=new_player, last_years_league=last_years_league, region=region, - possible_commish=commish + possible_commish=commish, ) su, _ = SeasonUser.objects.get_or_create( @@ -97,25 +112,23 @@ def create_season_users(users): new_player=new_player, last_years_league=last_years_league, region=region, - possible_commish=commish + possible_commish=commish, ) - DSTPlayer.objects.update_or_create(sleeper_id=sleeper_id, defaults={ - "display_name": sleeper_username - }) + DSTPlayer.objects.update_or_create( + sleeper_id=sleeper_id, defaults={"display_name": sleeper_username} + ) DSTEmail.objects.create( recipient=su.user.email, subject=EMAIL_SUBJECT, text=EMAIL_TEXT.format( - sleeper_name=su.dst_player.display_name, - current_season=su.season + sleeper_name=su.dst_player.display_name, current_season=su.season ), html=EMAIL_HTML.format( - sleeper_name=su.dst_player.display_name, - current_season=su.season + sleeper_name=su.dst_player.display_name, current_season=su.season ), - type=2 + type=2, ) @@ -124,15 +137,12 @@ def send_email_chunk(chunk_size=12): for mail in open_mails: success = mail.send_mail() if success: - print("{type} send to {email}".format( - type=mail.type, - email=mail.recipient - )) + print("{type} send to {email}".format(type=mail.type, email=mail.recipient)) def import_invitations(filepath): - with open(filepath, 'r') as csv_file: - csv_reader = csv.DictReader(csv_file, delimiter=';') + with open(filepath, "r") as csv_file: + csv_reader = csv.DictReader(csv_file, delimiter=";") for row in csv_reader: league_id = row.get("Liga-ID") league_name = row.get("Liga-Name") @@ -150,31 +160,43 @@ def import_invitations(filepath): row.get("Teilnehmer9"), row.get("Teilnehmer10"), row.get("Teilnehmer11"), - row.get("Teilnehmer12") + row.get("Teilnehmer12"), ] if not all(players): - print(f"League {league_id} - {league_name} incomplete!".format(league_id=league_id, - league_name=league_name)) + print( + f"League {league_id} - {league_name} incomplete!".format( + league_id=league_id, league_name=league_name + ) + ) else: - print("Creating Invitations for league {league_id} - {league_name}".format(league_id=league_id, - league_name=league_name)) + print( + "Creating Invitations for league {league_id} - {league_name}".format( + league_id=league_id, league_name=league_name + ) + ) counter = 0 for player in players: try: su, created = SeasonInvitation.objects.get_or_create( - season_user=SeasonUser.objects.get(dst_player__display_name=player, - season=Season.get_active()), + season_user=SeasonUser.objects.get( + dst_player__display_name=player, + season=Season.get_active(), + ), sleeper_username=player, sleeper_league_name=league_name, sleeper_league_id=league_id, - sleeper_league_link=league_link + sleeper_league_link=league_link, ) if created: su.create_mail() counter += 1 except SeasonUser.DoesNotExist: - print("SeasonUser for Sleeper-Name {sleeper_name} does not exist!".format(sleeper_name=player)) + print( + "SeasonUser for Sleeper-Name {sleeper_name} does not exist!".format( + sleeper_name=player + ) + ) print("Created {count} Invitations".format(count=counter)) @@ -189,7 +211,7 @@ def create_leagues_from_invitations(): level=guess_level(si.sleeper_league_name), conference=guess_conference(si.sleeper_league_name), region=guess_region(si.sleeper_league_name), - type=League.BUNDESLIGA + type=League.BUNDESLIGA, ) league_data = get_league_data(si.sleeper_league_id) @@ -198,5 +220,10 @@ def create_leagues_from_invitations(): def get_waiting_list(): - return SeasonUser.objects.exclude(id__in=SeasonInvitation.objects.values_list('season_user', flat=True)).filter( - season=Season.get_active()).order_by('registration__registration_ts', 'sleeper_id') + return ( + SeasonUser.objects.exclude( + id__in=SeasonInvitation.objects.values_list("season_user", flat=True) + ) + .filter(season=Season.get_active()) + .order_by("registration__registration_ts", "sleeper_id") + ) diff --git a/DSTBundesliga/apps/dstffbl/templatetags/dstffbl_tags.py b/DSTBundesliga/apps/dstffbl/templatetags/dstffbl_tags.py index d4051ec..7998795 100644 --- a/DSTBundesliga/apps/dstffbl/templatetags/dstffbl_tags.py +++ b/DSTBundesliga/apps/dstffbl/templatetags/dstffbl_tags.py @@ -27,10 +27,12 @@ def get_registration_starts(): @register.simple_tag() def show_registration_countdown(): - return datetime.date.fromisoformat(settings.REGISTRATION_STARTS) > datetime.date.today() + return ( + datetime.date.fromisoformat(settings.REGISTRATION_STARTS) + > datetime.date.today() + ) @register.simple_tag() def get_current_season(): return StateService().get_season() - diff --git a/DSTBundesliga/apps/dstffbl/urls.py b/DSTBundesliga/apps/dstffbl/urls.py index 706828c..040cf02 100644 --- a/DSTBundesliga/apps/dstffbl/urls.py +++ b/DSTBundesliga/apps/dstffbl/urls.py @@ -3,11 +3,15 @@ from DSTBundesliga.apps.dstffbl import views urlpatterns = [ - path('', views.home, name='home'), - path('anmeldung/', views.register, name='anmeldung'), - path('early-bird/', views.early_bird, name='early-bird'), - path('accept_invite//', views.confirm_registration, name='accept_invite'), - path('login/', views.login, name='login'), - path('profile/', views.profile, name='profile'), - path('resend_invite', views.resend_invite, name='resend_invite') + path("", views.home, name="home"), + path("anmeldung/", views.register, name="anmeldung"), + path("early-bird/", views.early_bird, name="early-bird"), + path( + "accept_invite//", + views.confirm_registration, + name="accept_invite", + ), + path("login/", views.login, name="login"), + path("profile/", views.profile, name="profile"), + path("resend_invite", views.resend_invite, name="resend_invite"), ] diff --git a/DSTBundesliga/apps/dstffbl/views.py b/DSTBundesliga/apps/dstffbl/views.py index 6ab5d13..7da8c35 100644 --- a/DSTBundesliga/apps/dstffbl/views.py +++ b/DSTBundesliga/apps/dstffbl/views.py @@ -8,7 +8,13 @@ from django.urls import reverse from DSTBundesliga.apps.dstffbl.forms import RegisterForm, ProfileForm -from DSTBundesliga.apps.dstffbl.models import SeasonUser, News, SeasonRegistration, DSTEmail, REGIONS +from DSTBundesliga.apps.dstffbl.models import ( + SeasonUser, + News, + SeasonRegistration, + DSTEmail, + REGIONS, +) from DSTBundesliga.apps.dstffbl.services import season_service from DSTBundesliga.apps.leagues.models import Matchup, Season, DSTPlayer, League from DSTBundesliga.apps.services.awards_service import AwardService @@ -16,17 +22,21 @@ def home(request): - week = Matchup.objects.filter(season=Season.get_active(), - league_id__in=League.objects.filter(type=League.BUNDESLIGA).values_list( - 'sleeper_id')).aggregate(Max('week')).get('week__max') + week = ( + Matchup.objects.filter( + season=Season.get_active(), + league_id__in=League.objects.filter(type=League.BUNDESLIGA).values_list( + "sleeper_id" + ), + ) + .aggregate(Max("week")) + .get("week__max") + ) awards_service = AwardService(request, week) awards = awards_service.get_random(0) - news = News.objects.all().order_by('-date')[:3] + news = News.objects.all().order_by("-date")[:3] - return render(request, "dstffbl/home.html", { - "news_list": news, - "awards": awards - }) + return render(request, "dstffbl/home.html", {"news_list": news, "awards": awards}) def register(request, early_bird=False): @@ -36,18 +46,22 @@ def register(request, early_bird=False): form = None if user.is_authenticated: - if request.method == 'POST': + if request.method == "POST": form = RegisterForm(request.POST) if form.is_valid(): - sleeper_id = form.cleaned_data.get('sleeper_username') + sleeper_id = form.cleaned_data.get("sleeper_username") dst_player = None last_years_league = None try: - dst_player = DSTPlayer.objects.get(sleeper_id=form.cleaned_data.get('sleeper_username')) + dst_player = DSTPlayer.objects.get( + sleeper_id=form.cleaned_data.get("sleeper_username") + ) if dst_player: - last_years_league = season_service.get_last_years_league(player=dst_player) + last_years_league = season_service.get_last_years_league( + player=dst_player + ) except: pass @@ -55,29 +69,33 @@ def register(request, early_bird=False): user=user, season=Season.get_active(), defaults={ - 'sleeper_id': sleeper_id, - 'region': form.cleaned_data.get('region'), - 'new_player': dst_player is None, - 'last_years_league': last_years_league, - 'possible_commish': form.cleaned_data.get('possible_commish') - } + "sleeper_id": sleeper_id, + "region": form.cleaned_data.get("region"), + "new_player": dst_player is None, + "last_years_league": last_years_league, + "possible_commish": form.cleaned_data.get("possible_commish"), + }, ) sleeper_user = sleeper_wrapper.User(sleeper_id) sleeper_username = sleeper_user.get_username() - dst_player, _ = DSTPlayer.objects.update_or_create(sleeper_id=sleeper_id, defaults={ - "display_name": sleeper_username - }) + dst_player, _ = DSTPlayer.objects.update_or_create( + sleeper_id=sleeper_id, defaults={"display_name": sleeper_username} + ) season_registration.dst_player = dst_player season_registration.save() if created: season_registration.create_mail() - elif request.method == 'GET': + elif request.method == "GET": try: - season_registration = SeasonRegistration.objects.get(user=user, season=Season.get_active()) - season_user = SeasonUser.objects.get(user=user, season=Season.get_active()) + season_registration = SeasonRegistration.objects.get( + user=user, season=Season.get_active() + ) + season_user = SeasonUser.objects.get( + user=user, season=Season.get_active() + ) except SeasonRegistration.DoesNotExist as e: season_registration = None except SeasonUser.DoesNotExist as e: @@ -87,18 +105,24 @@ def register(request, early_bird=False): if is_registration_open() or early_bird: if season_registration and not season_user: - return render(request, 'dstffbl/registration_success.html') + return render(request, "dstffbl/registration_success.html") else: - return render(request, 'dstffbl/register.html', - {'form': form, 'region_choices': REGIONS, - 'current_season': Season.get_active(), - 'season_user': season_user}) + return render( + request, + "dstffbl/register.html", + { + "form": form, + "region_choices": REGIONS, + "current_season": Season.get_active(), + "season_user": season_user, + }, + ) else: - return render(request, 'dstffbl/waiting_for_register.html') + return render(request, "dstffbl/waiting_for_register.html") else: - login_url = reverse('dstffbl:login') - return redirect('{}?{}'.format(login_url, urlencode({'next': '/anmeldung/'}))) + login_url = reverse("dstffbl:login") + return redirect("{}?{}".format(login_url, urlencode({"next": "/anmeldung/"}))) def early_bird(request): @@ -106,9 +130,9 @@ def early_bird(request): def confirm_registration(request, registration_id): - EMAIL_SUBJECT = 'Anmeldung erfolgreich!' + EMAIL_SUBJECT = "Anmeldung erfolgreich!" - EMAIL_TEXT = '''' + EMAIL_TEXT = """' Hallo {sleeper_name}, Du bist für die Saison {current_season} angemeldet! Weitere Infos folgen in einigen Tagen per Mail und über unsere @@ -116,9 +140,9 @@ def confirm_registration(request, registration_id): Beste Grüße von Michael und dem gesamten Organisationsteam der DSTFanFooBL - ''' + """ - EMAIL_HTML = ''' + EMAIL_HTML = """

Hallo {sleeper_name},

Du bist für die Saison {current_season} angemeldet! Weitere Infos folgen in einigen Tagen per Mail und über @@ -126,10 +150,12 @@ def confirm_registration(request, registration_id):

Beste Grüße von
Michael und dem gesamten Organisationsteam der DSTFanFooBL

- ''' + """ try: - registration = SeasonRegistration.objects.filter(season=Season.get_active()).get(id=registration_id) + registration = SeasonRegistration.objects.filter( + season=Season.get_active() + ).get(id=registration_id) season_user, created = SeasonUser.objects.get_or_create( user=registration.user, @@ -140,7 +166,7 @@ def confirm_registration(request, registration_id): region=registration.region, new_player=registration.new_player, last_years_league=registration.last_years_league, - possible_commish=registration.possible_commish + possible_commish=registration.possible_commish, ) DSTEmail.objects.create( @@ -148,31 +174,39 @@ def confirm_registration(request, registration_id): subject=EMAIL_SUBJECT, text=EMAIL_TEXT.format( sleeper_name=registration.dst_player.display_name, - current_season=registration.season + current_season=registration.season, ), html=EMAIL_HTML.format( sleeper_name=registration.dst_player.display_name, - current_season=registration.season + current_season=registration.season, ), - type=2 + type=2, ) - return render(request, 'dstffbl/register.html', - {'current_season': Season.get_active(), 'season_user': season_user}) + return render( + request, + "dstffbl/register.html", + {"current_season": Season.get_active(), "season_user": season_user}, + ) except SeasonRegistration.DoesNotExist as e: logging.error(f"Registration with id {registration_id} not found.", e) - return render(request, 'dstffbl/confirmation_error.html', { - 'confirmation_error': "Es tut uns leid, deine Registierung ist nicht mehr gültig. Bitte melde dich erneut an."}) + return render( + request, + "dstffbl/confirmation_error.html", + { + "confirmation_error": "Es tut uns leid, deine Registierung ist nicht mehr gültig. Bitte melde dich erneut an." + }, + ) def login(request): - next = request.GET.get('next', '/') + next = request.GET.get("next", "/") if request.user.is_authenticated: return redirect(next) - return render(request, 'dstffbl/login.html', {'next': next}) + return render(request, "dstffbl/login.html", {"next": next}) def profile(request): @@ -191,31 +225,32 @@ def profile(request): registration_status = "confirmed" except SeasonUser.DoesNotExist: try: - season_registration = SeasonRegistration.objects.get(user=user, season=Season.get_active()) + season_registration = SeasonRegistration.objects.get( + user=user, season=Season.get_active() + ) season_data = season_registration registration_status = "pending" except SeasonRegistration.DoesNotExist: - registration_status = "not_registered" - if request.method == 'POST': + if request.method == "POST": form = ProfileForm(request.POST) if form.is_valid(): - submitted_sleeper_id = form.cleaned_data.get('sleeper_username') + submitted_sleeper_id = form.cleaned_data.get("sleeper_username") sleeper_user = sleeper_wrapper.User(submitted_sleeper_id) sleeper_id = sleeper_user.get_user_id() sleeper_username = sleeper_user.get_username() - dst_player, _ = DSTPlayer.objects.update_or_create(sleeper_id=sleeper_id, defaults={ - "display_name": sleeper_username - }) + dst_player, _ = DSTPlayer.objects.update_or_create( + sleeper_id=sleeper_id, defaults={"display_name": sleeper_username} + ) season_data.sleeper_id = sleeper_id season_data.dst_player.display_name = sleeper_username - season_data.user.email = form.cleaned_data.get('email') - season_data.region = form.cleaned_data.get('region') - season_data.possible_commish = form.cleaned_data.get('possible_commish') + season_data.user.email = form.cleaned_data.get("email") + season_data.region = form.cleaned_data.get("region") + season_data.possible_commish = form.cleaned_data.get("possible_commish") season_data.save() season_data.user.save() season_data.dst_player.save() @@ -224,33 +259,41 @@ def profile(request): else: if season_data: - form = ProfileForm(data={ - "sleeper_username": season_data.dst_player.display_name, - "email": season_data.user.email, - "possible_commish": season_data.possible_commish, - "region": season_data.region - }) + form = ProfileForm( + data={ + "sleeper_username": season_data.dst_player.display_name, + "email": season_data.user.email, + "possible_commish": season_data.possible_commish, + "region": season_data.region, + } + ) else: form = ProfileForm() - return render(request, "dstffbl/profile.html", { - "season": season, - "season_data": season_data, - "registration_status": registration_status, - "registration_open": registration_open, - 'region_choices': REGIONS, - "form": form, - "message": message, - "resend_url": reverse("dstffbl:resend_invite"), - "register_url": reverse("dstffbl:anmeldung") - }) + return render( + request, + "dstffbl/profile.html", + { + "season": season, + "season_data": season_data, + "registration_status": registration_status, + "registration_open": registration_open, + "region_choices": REGIONS, + "form": form, + "message": message, + "resend_url": reverse("dstffbl:resend_invite"), + "register_url": reverse("dstffbl:anmeldung"), + }, + ) def resend_invite(request): try: - season_registration = SeasonRegistration.objects.get(user=request.user, season=Season.get_active()) + season_registration = SeasonRegistration.objects.get( + user=request.user, season=Season.get_active() + ) season_registration.create_mail() except SeasonRegistration.DoesNotExist: pass - return render(request, 'dstffbl/registration_success.html') + return render(request, "dstffbl/registration_success.html") diff --git a/DSTBundesliga/apps/leagues/admin.py b/DSTBundesliga/apps/leagues/admin.py index 7551e54..4eaaf51 100644 --- a/DSTBundesliga/apps/leagues/admin.py +++ b/DSTBundesliga/apps/leagues/admin.py @@ -4,7 +4,7 @@ class SeasonAdmin(admin.ModelAdmin): - list_display = ['year', 'name', 'active'] + list_display = ["year", "name", "active"] class FinalSeasonStandingAdmin(admin.ModelAdmin): @@ -12,12 +12,25 @@ def get_owner(self, obj): if obj.roster.owner: return str(obj.roster.owner) return "deleted" - search_fields = ['roster__owner__display_name', 'roster__owner__sleeper_id', 'league__sleeper_name'] - list_display = ['points_ranking_overall', 'points_ranking_on_level', 'points_ranking_in_league', 'get_owner', 'league', 'season', 'rank_in_league', 'points', 'points_decimal'] - list_filter = ('season', 'league__level', 'rank_in_league') + + search_fields = [ + "roster__owner__display_name", + "roster__owner__sleeper_id", + "league__sleeper_name", + ] + list_display = [ + "points_ranking_overall", + "points_ranking_on_level", + "points_ranking_in_league", + "get_owner", + "league", + "season", + "rank_in_league", + "points", + "points_decimal", + ] + list_filter = ("season", "league__level", "rank_in_league") admin.site.register(Season, SeasonAdmin) admin.site.register(FinalSeasonStanding, FinalSeasonStandingAdmin) - - diff --git a/DSTBundesliga/apps/leagues/cms_menus.py b/DSTBundesliga/apps/leagues/cms_menus.py index 7797bc5..b323625 100644 --- a/DSTBundesliga/apps/leagues/cms_menus.py +++ b/DSTBundesliga/apps/leagues/cms_menus.py @@ -9,7 +9,6 @@ class LeaguesMenu(Menu): - def get_nodes(self, request): """ This method is used to build the menu tree. @@ -19,7 +18,9 @@ def get_nodes(self, request): nodes.append(NavigationNode("Startseite", "/", counter)) counter += 1 - nodes.append(NavigationNode("Champions League", reverse('champions-league'), counter)) + nodes.append( + NavigationNode("Champions League", reverse("champions-league"), counter) + ) all_leagues = League.objects.get_active() conferences = {} regions = {} @@ -29,12 +30,23 @@ def get_nodes(self, request): level_leagues = all_leagues.filter(level=level) - for conference in level_leagues.values_list("conference", flat=True).distinct().order_by('conference'): + for conference in ( + level_leagues.values_list("conference", flat=True) + .distinct() + .order_by("conference") + ): if conference: conference_node = conferences.get(conference) if not conference_node: counter += 1 - conference_node = NavigationNode(conference, reverse('conference-overview', kwargs={"conference": conference}), conference, attr={'li_class': conference}) + conference_node = NavigationNode( + conference, + reverse( + "conference-overview", kwargs={"conference": conference} + ), + conference, + attr={"li_class": conference}, + ) nodes.append(conference_node) conferences[conference] = conference_node conference_id = conference_node.id @@ -43,26 +55,49 @@ def get_nodes(self, request): counter += 1 kwargs = {"level": level} - url = reverse('level-detail', kwargs=kwargs) + url = reverse("level-detail", kwargs=kwargs) if conference: kwargs["conference"] = conference - url = reverse('conference-detail', kwargs=kwargs) + url = reverse("conference-detail", kwargs=kwargs) node_id = "league-%i" % level if conference: node_id = conference + "-" + node_id - league_node = NavigationNode(title, url, node_id, parent_id=conference_id, attr={'li_class': conference}) + league_node = NavigationNode( + title, + url, + node_id, + parent_id=conference_id, + attr={"li_class": conference}, + ) league_id = league_node.id nodes.append(league_node) - for region in conference_leagues.values_list("region", flat=True).distinct().order_by('region'): + for region in ( + conference_leagues.values_list("region", flat=True) + .distinct() + .order_by("region") + ): if region: - if region == 'Süd': - region = 'Sued' + if region == "Süd": + region = "Sued" region_node = regions.get(conference, {}).get(region) if not region_node: counter += 1 - region_node = NavigationNode(region, reverse('region-detail', kwargs={"level": level, "conference": conference, "region": region}), node_id+"-"+region, parent_id=league_id, attr={'li_class': conference}) + region_node = NavigationNode( + region, + reverse( + "region-detail", + kwargs={ + "level": level, + "conference": conference, + "region": region, + }, + ), + node_id + "-" + region, + parent_id=league_id, + attr={"li_class": conference}, + ) nodes.append(region_node) if not regions.get(conference): regions[conference] = {} @@ -72,27 +107,42 @@ def get_nodes(self, request): # Stats counter += 1 - nodes.append(NavigationNode("Stats", '#', counter, attr={'li_class': "stats-node"})) + nodes.append( + NavigationNode("Stats", "#", counter, attr={"li_class": "stats-node"}) + ) stats_parent = counter - #counter += 1 - #nodes.append(NavigationNode("Facts & Figures", reverse('facts_and_figures'), counter, stats_parent)) + # counter += 1 + # nodes.append(NavigationNode("Facts & Figures", reverse('facts_and_figures'), counter, stats_parent)) counter += 1 - nodes.append(NavigationNode("CL Quali", reverse('cl-quali'), counter, stats_parent)) + nodes.append( + NavigationNode("CL Quali", reverse("cl-quali"), counter, stats_parent) + ) counter += 1 - nodes.append(NavigationNode("Waiver", reverse('waiver_stats'), counter, stats_parent)) + nodes.append( + NavigationNode("Waiver", reverse("waiver_stats"), counter, stats_parent) + ) counter += 1 - nodes.append(NavigationNode("Draft", reverse('draft-stats'), counter, stats_parent)) + nodes.append( + NavigationNode("Draft", reverse("draft-stats"), counter, stats_parent) + ) # Hörerliga counter += 1 - nodes.append(NavigationNode("DST - Hörerliga", reverse('dst-league'), counter)) + nodes.append(NavigationNode("DST - Hörerliga", reverse("dst-league"), counter)) counter += 1 - nodes.append(NavigationNode("Deine Anmeldung", reverse('dstffbl:profile'), counter, attr={'visible_for_anonymous': False})) + nodes.append( + NavigationNode( + "Deine Anmeldung", + reverse("dstffbl:profile"), + counter, + attr={"visible_for_anonymous": False}, + ) + ) return nodes diff --git a/DSTBundesliga/apps/leagues/config.py b/DSTBundesliga/apps/leagues/config.py index 4e4790b..7aa82bf 100644 --- a/DSTBundesliga/apps/leagues/config.py +++ b/DSTBundesliga/apps/leagues/config.py @@ -3,28 +3,27 @@ 2: "2. Bundesliga", 3: "Conference-Liga", 4: "Divisionsliga", - 5: "Regionalliga" + 5: "Regionalliga", + 6: "Kreisliga", } LOGO_MAP = { - 1: { - None: "dst_bl_logo" - }, - 2: { - None: "dst_bl2_logo" - }, - 3: { - "CFFC": "dst_cffc_conf_logo", - "AFFC": "dst_affc_conf_logo" - }, - 4: { - "CFFC": "dst_cffc_div_logo", - "AFFC": "dst_affc_div_logo" - }, - 5: { - "CFFC": "dst_cffc_reg_logo", - "AFFC": "dst_affc_reg_logo" - } + 1: {None: "dst_bl_logo"}, + 2: {None: "dst_bl2_logo"}, + 3: {"CFFC": "dst_cffc_conf_logo", "AFFC": "dst_affc_conf_logo"}, + 4: {"CFFC": "dst_cffc_div_logo", "AFFC": "dst_affc_div_logo"}, + 5: {"CFFC": "dst_cffc_reg_logo", "AFFC": "dst_affc_reg_logo"}, + 6: {"CFFC": "dst_cffc_reg_logo", "AFFC": "dst_affc_reg_logo"}, } +LEAGUE_SETTINGS_MAP = { + 1: {"max_league_count": 1, "risers": 0, "ascenders": 8}, + 2: {"max_league_count": 4, "risers": 2, "ascenders": 6}, + 3: {"max_league_count": 20, "risers": 2, "ascenders": 6}, + 4: {"max_league_count": 32, "risers": 3, "ascenders": 6}, + 5: {"max_league_count": 60, "risers": 3, "ascenders": 8}, + 6: {"max_league_count": 128, "risers": 3, "ascenders": 8}, +} + + POSITIONS = ["QB", "RB", "WR", "TE", "K", "DEF"] diff --git a/DSTBundesliga/apps/leagues/management/commands/calc_final_standings.py b/DSTBundesliga/apps/leagues/management/commands/calc_final_standings.py index 571cbf8..0f945c2 100644 --- a/DSTBundesliga/apps/leagues/management/commands/calc_final_standings.py +++ b/DSTBundesliga/apps/leagues/management/commands/calc_final_standings.py @@ -5,15 +5,12 @@ class Command(BaseCommand): - help = 'Calculate the final standings for the given season' + help = "Calculate the final standings for the given season" def add_arguments(self, parser): - parser.add_argument( - 'season', - type=int - ) + parser.add_argument("season", type=int) def handle(self, *args, **options): - season = Season.objects.get(year=options['season']) + season = Season.objects.get(year=options["season"]) calc_final_standings(season) diff --git a/DSTBundesliga/apps/leagues/management/commands/delete_old_leagues.py b/DSTBundesliga/apps/leagues/management/commands/delete_old_leagues.py index 47d8664..8feb47e 100644 --- a/DSTBundesliga/apps/leagues/management/commands/delete_old_leagues.py +++ b/DSTBundesliga/apps/leagues/management/commands/delete_old_leagues.py @@ -1,17 +1,18 @@ from django.core.management import BaseCommand -from DSTBundesliga.apps.services.data_services import delete_old_leagues, get_league_settings +from DSTBundesliga.apps.services.data_services import ( + delete_old_leagues, + get_league_settings, +) class Command(BaseCommand): - help = 'Delete old leagues.' + help = "Delete old leagues." def add_arguments(self, parser): parser.add_argument( - '--force', - action='store_false', - help='Force delete (instead of dry run)' + "--force", action="store_false", help="Force delete (instead of dry run)" ) def handle(self, *args, **options): - delete_old_leagues(get_league_settings(), dry_run=options['force']) + delete_old_leagues(get_league_settings(), dry_run=options["force"]) diff --git a/DSTBundesliga/apps/leagues/management/commands/set_champions_league.py b/DSTBundesliga/apps/leagues/management/commands/set_champions_league.py index f449060..89e7a16 100644 --- a/DSTBundesliga/apps/leagues/management/commands/set_champions_league.py +++ b/DSTBundesliga/apps/leagues/management/commands/set_champions_league.py @@ -1,28 +1,29 @@ from django.core.management import BaseCommand from DSTBundesliga.apps.leagues.models import League -from DSTBundesliga.apps.services.data_services import LeagueSetting, get_league_data, update_or_create_league, \ - update_drafts_for_league +from DSTBundesliga.apps.services.data_services import ( + LeagueSetting, + get_league_data, + update_or_create_league, + update_drafts_for_league, +) class Command(BaseCommand): - help = 'Update Draft for selected League' + help = "Update Draft for selected League" def add_arguments(self, parser): - parser.add_argument( - 'league_id', - type=str - ) + parser.add_argument("league_id", type=str) def handle(self, *args, **options): - league_id = options['league_id'] + league_id = options["league_id"] league_settings = LeagueSetting( id=league_id, - name='Champions League', + name="Champions League", type=League.CL, level=99, conference=None, - region=None + region=None, ) league_data = get_league_data(league_id) diff --git a/DSTBundesliga/apps/leagues/management/commands/set_listener_league.py b/DSTBundesliga/apps/leagues/management/commands/set_listener_league.py index e65d6fa..aeb5fd0 100644 --- a/DSTBundesliga/apps/leagues/management/commands/set_listener_league.py +++ b/DSTBundesliga/apps/leagues/management/commands/set_listener_league.py @@ -1,28 +1,29 @@ from django.core.management import BaseCommand from DSTBundesliga.apps.leagues.models import League -from DSTBundesliga.apps.services.data_services import LeagueSetting, get_league_data, update_or_create_league, \ - update_drafts_for_league +from DSTBundesliga.apps.services.data_services import ( + LeagueSetting, + get_league_data, + update_or_create_league, + update_drafts_for_league, +) class Command(BaseCommand): - help = 'Update Draft for selected League' + help = "Update Draft for selected League" def add_arguments(self, parser): - parser.add_argument( - 'league_id', - type=str - ) + parser.add_argument("league_id", type=str) def handle(self, *args, **options): - league_id = options['league_id'] + league_id = options["league_id"] league_settings = LeagueSetting( id=league_id, - name='DST Hörerliga', + name="DST Hörerliga", type=League.LISTENER, level=99, conference=None, - region=None + region=None, ) league_data = get_league_data(league_id) diff --git a/DSTBundesliga/apps/leagues/management/commands/update_draft_for_league.py b/DSTBundesliga/apps/leagues/management/commands/update_draft_for_league.py index d4aaf40..36732e8 100644 --- a/DSTBundesliga/apps/leagues/management/commands/update_draft_for_league.py +++ b/DSTBundesliga/apps/leagues/management/commands/update_draft_for_league.py @@ -1,21 +1,23 @@ from django.core.management import BaseCommand -from DSTBundesliga.apps.services.data_services import get_draft_data, update_drafts_for_league, \ - get_pick_data, update_picks_for_draft +from DSTBundesliga.apps.services.data_services import ( + get_draft_data, + update_drafts_for_league, + get_pick_data, + update_picks_for_draft, +) class Command(BaseCommand): - help = 'Update Draft for selected League' + help = "Update Draft for selected League" def add_arguments(self, parser): parser.add_argument( - 'league_id', - type=str, - help='Force delete (instead of dry run)' + "league_id", type=str, help="Force delete (instead of dry run)" ) def handle(self, *args, **options): - league_id = options['league_id'] + league_id = options["league_id"] draft = update_drafts_for_league(league_id) picks_data = get_pick_data(draft.draft_id) diff --git a/DSTBundesliga/apps/leagues/management/commands/update_draft_stats_for_season.py b/DSTBundesliga/apps/leagues/management/commands/update_draft_stats_for_season.py index b6770d3..06c1f3c 100644 --- a/DSTBundesliga/apps/leagues/management/commands/update_draft_stats_for_season.py +++ b/DSTBundesliga/apps/leagues/management/commands/update_draft_stats_for_season.py @@ -1,19 +1,21 @@ from django.core.management import BaseCommand from DSTBundesliga.apps.leagues.models import Season -from DSTBundesliga.apps.services.data_services import update_player_draft_stats_from_picks +from DSTBundesliga.apps.services.data_services import ( + update_player_draft_stats_from_picks, +) class Command(BaseCommand): - help = 'Update PlayerDraftStats for a given Season based on all Picks.' + help = "Update PlayerDraftStats for a given Season based on all Picks." def add_arguments(self, parser): parser.add_argument( - 'season', + "season", type=str, - help='Starting-Year of the Season, e.g. Season 2021/2022 the requested input is 2021' + help="Starting-Year of the Season, e.g. Season 2021/2022 the requested input is 2021", ) def handle(self, *args, **options): - season = Season.objects.get(year=options['season']) + season = Season.objects.get(year=options["season"]) update_player_draft_stats_from_picks(season) diff --git a/DSTBundesliga/apps/leagues/management/commands/update_drafts.py b/DSTBundesliga/apps/leagues/management/commands/update_drafts.py index 28fa636..c990441 100644 --- a/DSTBundesliga/apps/leagues/management/commands/update_drafts.py +++ b/DSTBundesliga/apps/leagues/management/commands/update_drafts.py @@ -4,7 +4,7 @@ class Command(BaseCommand): - help = 'Updaties all Leagues from Sleeper-API' + help = "Updaties all Leagues from Sleeper-API" def handle(self, *args, **options): update_drafts() diff --git a/DSTBundesliga/apps/leagues/management/commands/update_everything.py b/DSTBundesliga/apps/leagues/management/commands/update_everything.py index 39d4171..afbd974 100644 --- a/DSTBundesliga/apps/leagues/management/commands/update_everything.py +++ b/DSTBundesliga/apps/leagues/management/commands/update_everything.py @@ -4,7 +4,7 @@ class Command(BaseCommand): - help = 'Updates all Leagues from Sleeper-API' + help = "Updates all Leagues from Sleeper-API" def handle(self, *args, **options): update_everything() diff --git a/DSTBundesliga/apps/leagues/management/commands/update_leagues.py b/DSTBundesliga/apps/leagues/management/commands/update_leagues.py index e7f2256..196577e 100644 --- a/DSTBundesliga/apps/leagues/management/commands/update_leagues.py +++ b/DSTBundesliga/apps/leagues/management/commands/update_leagues.py @@ -4,7 +4,7 @@ class Command(BaseCommand): - help = 'Updates all Leagues from Sleeper-API' + help = "Updates all Leagues from Sleeper-API" def handle(self, *args, **options): update_leagues() diff --git a/DSTBundesliga/apps/leagues/management/commands/update_listener_draft.py b/DSTBundesliga/apps/leagues/management/commands/update_listener_draft.py index 17ff94a..477556f 100644 --- a/DSTBundesliga/apps/leagues/management/commands/update_listener_draft.py +++ b/DSTBundesliga/apps/leagues/management/commands/update_listener_draft.py @@ -4,7 +4,7 @@ class Command(BaseCommand): - help = 'Update Hörerliga' + help = "Update Hörerliga" def handle(self, *args, **options): update_listener_draft() diff --git a/DSTBundesliga/apps/leagues/management/commands/update_listener_league.py b/DSTBundesliga/apps/leagues/management/commands/update_listener_league.py index 62b72c4..edfa20a 100644 --- a/DSTBundesliga/apps/leagues/management/commands/update_listener_league.py +++ b/DSTBundesliga/apps/leagues/management/commands/update_listener_league.py @@ -4,7 +4,7 @@ class Command(BaseCommand): - help = 'Update Hörerliga' + help = "Update Hörerliga" def handle(self, *args, **options): update_listener_league() diff --git a/DSTBundesliga/apps/leagues/management/commands/update_matchups.py b/DSTBundesliga/apps/leagues/management/commands/update_matchups.py index 68bab31..6fb2717 100644 --- a/DSTBundesliga/apps/leagues/management/commands/update_matchups.py +++ b/DSTBundesliga/apps/leagues/management/commands/update_matchups.py @@ -4,7 +4,7 @@ class Command(BaseCommand): - help = 'Updates all Matchups from Sleeper-API' + help = "Updates all Matchups from Sleeper-API" def handle(self, *args, **options): update_matchups() diff --git a/DSTBundesliga/apps/leagues/management/commands/update_players.py b/DSTBundesliga/apps/leagues/management/commands/update_players.py index 87aaf92..1d69b51 100644 --- a/DSTBundesliga/apps/leagues/management/commands/update_players.py +++ b/DSTBundesliga/apps/leagues/management/commands/update_players.py @@ -4,7 +4,7 @@ class Command(BaseCommand): - help = 'Updates all Leagues from Sleeper-API' + help = "Updates all Leagues from Sleeper-API" def handle(self, *args, **options): update_players() diff --git a/DSTBundesliga/apps/leagues/management/commands/update_playoffs.py b/DSTBundesliga/apps/leagues/management/commands/update_playoffs.py index ded15dd..e1b78c1 100644 --- a/DSTBundesliga/apps/leagues/management/commands/update_playoffs.py +++ b/DSTBundesliga/apps/leagues/management/commands/update_playoffs.py @@ -4,7 +4,7 @@ class Command(BaseCommand): - help = 'Updates all Playoffs from Sleeper-API' + help = "Updates all Playoffs from Sleeper-API" def handle(self, *args, **options): update_playoffs() diff --git a/DSTBundesliga/apps/leagues/management/commands/update_rss.py b/DSTBundesliga/apps/leagues/management/commands/update_rss.py index b424cf6..b28678b 100644 --- a/DSTBundesliga/apps/leagues/management/commands/update_rss.py +++ b/DSTBundesliga/apps/leagues/management/commands/update_rss.py @@ -4,7 +4,7 @@ class Command(BaseCommand): - help = 'Updates News from Podcast-RSS-Feed' + help = "Updates News from Podcast-RSS-Feed" def handle(self, *args, **options): update_rss() diff --git a/DSTBundesliga/apps/leagues/management/commands/update_stats.py b/DSTBundesliga/apps/leagues/management/commands/update_stats.py index 53ddd83..45d809f 100644 --- a/DSTBundesliga/apps/leagues/management/commands/update_stats.py +++ b/DSTBundesliga/apps/leagues/management/commands/update_stats.py @@ -4,7 +4,7 @@ class Command(BaseCommand): - help = 'Updates all Stats from Sleeper-API' + help = "Updates all Stats from Sleeper-API" def handle(self, *args, **options): update_stats() diff --git a/DSTBundesliga/apps/leagues/management/commands/update_stats_for_weeks.py b/DSTBundesliga/apps/leagues/management/commands/update_stats_for_weeks.py index 1322ae7..c5cea63 100644 --- a/DSTBundesliga/apps/leagues/management/commands/update_stats_for_weeks.py +++ b/DSTBundesliga/apps/leagues/management/commands/update_stats_for_weeks.py @@ -1,11 +1,14 @@ from django.core.management import BaseCommand -from DSTBundesliga.apps.services.data_services import update_stats_for_weeks, get_current_week +from DSTBundesliga.apps.services.data_services import ( + update_stats_for_weeks, + get_current_week, +) class Command(BaseCommand): - help = 'Updates all Stats from Sleeper-API' + help = "Updates all Stats from Sleeper-API" def handle(self, *args, **options): - weeks = range(1, get_current_week()+1) + weeks = range(1, get_current_week() + 1) update_stats_for_weeks(weeks) diff --git a/DSTBundesliga/apps/leagues/management/commands/update_trades.py b/DSTBundesliga/apps/leagues/management/commands/update_trades.py index 875e0f3..6cc78d7 100644 --- a/DSTBundesliga/apps/leagues/management/commands/update_trades.py +++ b/DSTBundesliga/apps/leagues/management/commands/update_trades.py @@ -4,9 +4,9 @@ class Command(BaseCommand): - help = 'Updates all Stats from Sleeper-API' + help = "Updates all Stats from Sleeper-API" def handle(self, *args, **options): - weeks = range(1, get_current_week()+2) + weeks = range(1, get_current_week() + 2) for week in weeks: update_trades(week) diff --git a/DSTBundesliga/apps/leagues/migrations/0001_initial.py b/DSTBundesliga/apps/leagues/migrations/0001_initial.py index 7fe790a..09334e1 100644 --- a/DSTBundesliga/apps/leagues/migrations/0001_initial.py +++ b/DSTBundesliga/apps/leagues/migrations/0001_initial.py @@ -6,126 +6,228 @@ class Migration(migrations.Migration): - initial = True - dependencies = [ - ] + dependencies = [] operations = [ migrations.CreateModel( - name='Draft', + name="Draft", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('draft_type', models.CharField(max_length=20)), - ('status', models.CharField(max_length=20)), - ('start_time', models.DateTimeField()), - ('settings', jsonfield.fields.JSONField()), - ('season_type', models.CharField(max_length=20)), - ('season', models.IntegerField()), - ('metadata', jsonfield.fields.JSONField()), - ('last_picked', models.DateTimeField()), - ('last_message_time', models.DateTimeField()), - ('last_message_id', models.CharField(max_length=50)), - ('draft_id', models.CharField(max_length=50)), - ('draft_order', jsonfield.fields.JSONField()), - ('slot_to_roster_id', jsonfield.fields.JSONField()), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("draft_type", models.CharField(max_length=20)), + ("status", models.CharField(max_length=20)), + ("start_time", models.DateTimeField()), + ("settings", jsonfield.fields.JSONField()), + ("season_type", models.CharField(max_length=20)), + ("season", models.IntegerField()), + ("metadata", jsonfield.fields.JSONField()), + ("last_picked", models.DateTimeField()), + ("last_message_time", models.DateTimeField()), + ("last_message_id", models.CharField(max_length=50)), + ("draft_id", models.CharField(max_length=50)), + ("draft_order", jsonfield.fields.JSONField()), + ("slot_to_roster_id", jsonfield.fields.JSONField()), ], ), migrations.CreateModel( - name='DSTPlayer', + name="DSTPlayer", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('sleeper_id', models.CharField(db_index=True, max_length=50, unique=True)), - ('display_name', models.CharField(db_index=True, max_length=50)), - ('avatar_id', models.CharField(max_length=100, null=True)), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "sleeper_id", + models.CharField(db_index=True, max_length=50, unique=True), + ), + ("display_name", models.CharField(db_index=True, max_length=50)), + ("avatar_id", models.CharField(max_length=100, null=True)), ], ), migrations.CreateModel( - name='League', + name="League", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('level', models.IntegerField(default=0)), - ('total_rosters', models.IntegerField(default=12)), - ('status', models.CharField(max_length=20)), - ('sport', models.CharField(max_length=30)), - ('settings', jsonfield.fields.JSONField()), - ('season_type', models.CharField(max_length=30)), - ('season', models.IntegerField(default=2020)), - ('scoring_settings', jsonfield.fields.JSONField()), - ('roster_positions', jsonfield.fields.JSONField()), - ('previous_league_id', models.CharField(max_length=100, null=True)), - ('sleeper_name', models.CharField(max_length=50)), - ('sleeper_id', models.CharField(db_index=True, max_length=50, unique=True)), - ('draft_id', models.CharField(max_length=50)), - ('avatar_id', models.CharField(max_length=100)), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("level", models.IntegerField(default=0)), + ("total_rosters", models.IntegerField(default=12)), + ("status", models.CharField(max_length=20)), + ("sport", models.CharField(max_length=30)), + ("settings", jsonfield.fields.JSONField()), + ("season_type", models.CharField(max_length=30)), + ("season", models.IntegerField(default=2020)), + ("scoring_settings", jsonfield.fields.JSONField()), + ("roster_positions", jsonfield.fields.JSONField()), + ("previous_league_id", models.CharField(max_length=100, null=True)), + ("sleeper_name", models.CharField(max_length=50)), + ( + "sleeper_id", + models.CharField(db_index=True, max_length=50, unique=True), + ), + ("draft_id", models.CharField(max_length=50)), + ("avatar_id", models.CharField(max_length=100)), ], ), migrations.CreateModel( - name='Team', + name="Team", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=50)), - ('abbr', models.CharField(max_length=10)), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("name", models.CharField(max_length=50)), + ("abbr", models.CharField(max_length=10)), ], ), migrations.CreateModel( - name='Roster', + name="Roster", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=100, null=True)), - ('starters', models.CharField(max_length=100)), - ('settings', jsonfield.fields.JSONField()), - ('roster_id', models.IntegerField()), - ('reserve', models.CharField(max_length=100)), - ('players', models.CharField(max_length=255)), - ('league', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='leagues.League')), - ('owner', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='leagues.DSTPlayer')), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("name", models.CharField(max_length=100, null=True)), + ("starters", models.CharField(max_length=100)), + ("settings", jsonfield.fields.JSONField()), + ("roster_id", models.IntegerField()), + ("reserve", models.CharField(max_length=100)), + ("players", models.CharField(max_length=255)), + ( + "league", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="leagues.League" + ), + ), + ( + "owner", + models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.CASCADE, + to="leagues.DSTPlayer", + ), + ), ], ), migrations.CreateModel( - name='Player', + name="Player", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('sleeper_id', models.IntegerField()), - ('hashtag', models.CharField(max_length=50)), - ('depth_chart_position', models.IntegerField()), - ('status', models.CharField(max_length=20)), - ('fantasy_positions', models.CharField(max_length=50)), - ('number', models.IntegerField()), - ('last_name', models.CharField(max_length=50)), - ('first_name', models.CharField(max_length=50)), - ('weight', models.IntegerField()), - ('position', models.CharField(max_length=50)), - ('height', models.CharField(max_length=10)), - ('age', models.IntegerField()), - ('espn_id', models.CharField(max_length=50)), - ('yahoo_id', models.CharField(max_length=50)), - ('team', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='leagues.Team')), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("sleeper_id", models.IntegerField()), + ("hashtag", models.CharField(max_length=50)), + ("depth_chart_position", models.IntegerField()), + ("status", models.CharField(max_length=20)), + ("fantasy_positions", models.CharField(max_length=50)), + ("number", models.IntegerField()), + ("last_name", models.CharField(max_length=50)), + ("first_name", models.CharField(max_length=50)), + ("weight", models.IntegerField()), + ("position", models.CharField(max_length=50)), + ("height", models.CharField(max_length=10)), + ("age", models.IntegerField()), + ("espn_id", models.CharField(max_length=50)), + ("yahoo_id", models.CharField(max_length=50)), + ( + "team", + models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.SET_NULL, + to="leagues.Team", + ), + ), ], ), migrations.CreateModel( - name='Pick', + name="Pick", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('round', models.IntegerField(default=1)), - ('draft_slot', models.IntegerField(default=1)), - ('pick_no', models.IntegerField(default=1)), - ('metadata', jsonfield.fields.JSONField()), - ('draft', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='leagues.Draft')), - ('player', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='leagues.Player')), - ('roster', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='leagues.Roster')), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='leagues.DSTPlayer')), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("round", models.IntegerField(default=1)), + ("draft_slot", models.IntegerField(default=1)), + ("pick_no", models.IntegerField(default=1)), + ("metadata", jsonfield.fields.JSONField()), + ( + "draft", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="leagues.Draft" + ), + ), + ( + "player", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="leagues.Player" + ), + ), + ( + "roster", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="leagues.Roster" + ), + ), + ( + "user", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="leagues.DSTPlayer", + ), + ), ], ), migrations.AddField( - model_name='dstplayer', - name='leagues', - field=models.ManyToManyField(to='leagues.League'), + model_name="dstplayer", + name="leagues", + field=models.ManyToManyField(to="leagues.League"), ), migrations.AddField( - model_name='draft', - name='league', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='leagues.League'), + model_name="draft", + name="league", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="leagues.League" + ), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0002_auto_20200711_1232.py b/DSTBundesliga/apps/leagues/migrations/0002_auto_20200711_1232.py index f24ee28..a6bc20c 100644 --- a/DSTBundesliga/apps/leagues/migrations/0002_auto_20200711_1232.py +++ b/DSTBundesliga/apps/leagues/migrations/0002_auto_20200711_1232.py @@ -4,60 +4,59 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0001_initial'), + ("leagues", "0001_initial"), ] operations = [ migrations.AddField( - model_name='roster', - name='fpts', + model_name="roster", + name="fpts", field=models.IntegerField(default=0), ), migrations.AddField( - model_name='roster', - name='fpts_against', + model_name="roster", + name="fpts_against", field=models.IntegerField(default=0), ), migrations.AddField( - model_name='roster', - name='fpts_against_decimal', + model_name="roster", + name="fpts_against_decimal", field=models.IntegerField(default=0), ), migrations.AddField( - model_name='roster', - name='fpts_decimal', + model_name="roster", + name="fpts_decimal", field=models.IntegerField(default=0), ), migrations.AddField( - model_name='roster', - name='losses', + model_name="roster", + name="losses", field=models.IntegerField(default=0), ), migrations.AddField( - model_name='roster', - name='ties', + model_name="roster", + name="ties", field=models.IntegerField(default=0), ), migrations.AddField( - model_name='roster', - name='total_moves', + model_name="roster", + name="total_moves", field=models.IntegerField(default=0), ), migrations.AddField( - model_name='roster', - name='waiver_budget_used', + model_name="roster", + name="waiver_budget_used", field=models.IntegerField(default=0), ), migrations.AddField( - model_name='roster', - name='waiver_position', + model_name="roster", + name="waiver_position", field=models.IntegerField(default=1), ), migrations.AddField( - model_name='roster', - name='wins', + model_name="roster", + name="wins", field=models.IntegerField(default=0), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0003_league_region.py b/DSTBundesliga/apps/leagues/migrations/0003_league_region.py index 850a164..6496346 100644 --- a/DSTBundesliga/apps/leagues/migrations/0003_league_region.py +++ b/DSTBundesliga/apps/leagues/migrations/0003_league_region.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0002_auto_20200711_1232'), + ("leagues", "0002_auto_20200711_1232"), ] operations = [ migrations.AddField( - model_name='league', - name='region', + model_name="league", + name="region", field=models.CharField(max_length=30, null=True), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0004_auto_20200806_1650.py b/DSTBundesliga/apps/leagues/migrations/0004_auto_20200806_1650.py index f73a7a5..d9e1e88 100644 --- a/DSTBundesliga/apps/leagues/migrations/0004_auto_20200806_1650.py +++ b/DSTBundesliga/apps/leagues/migrations/0004_auto_20200806_1650.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0003_league_region'), + ("leagues", "0003_league_region"), ] operations = [ migrations.AlterField( - model_name='player', - name='depth_chart_position', + model_name="player", + name="depth_chart_position", field=models.CharField(max_length=50), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0005_auto_20200806_1651.py b/DSTBundesliga/apps/leagues/migrations/0005_auto_20200806_1651.py index 0c3cbd6..f44e94d 100644 --- a/DSTBundesliga/apps/leagues/migrations/0005_auto_20200806_1651.py +++ b/DSTBundesliga/apps/leagues/migrations/0005_auto_20200806_1651.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0004_auto_20200806_1650'), + ("leagues", "0004_auto_20200806_1650"), ] operations = [ migrations.AlterField( - model_name='player', - name='depth_chart_position', + model_name="player", + name="depth_chart_position", field=models.CharField(max_length=50, null=True), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0006_auto_20200806_1711.py b/DSTBundesliga/apps/leagues/migrations/0006_auto_20200806_1711.py index 6af9972..54dae3f 100644 --- a/DSTBundesliga/apps/leagues/migrations/0006_auto_20200806_1711.py +++ b/DSTBundesliga/apps/leagues/migrations/0006_auto_20200806_1711.py @@ -4,20 +4,19 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0005_auto_20200806_1651'), + ("leagues", "0005_auto_20200806_1651"), ] operations = [ migrations.AlterField( - model_name='player', - name='espn_id', + model_name="player", + name="espn_id", field=models.CharField(max_length=50, null=True), ), migrations.AlterField( - model_name='player', - name='yahoo_id', + model_name="player", + name="yahoo_id", field=models.CharField(max_length=50, null=True), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0007_auto_20200806_1857.py b/DSTBundesliga/apps/leagues/migrations/0007_auto_20200806_1857.py index d28f1ad..820e94e 100644 --- a/DSTBundesliga/apps/leagues/migrations/0007_auto_20200806_1857.py +++ b/DSTBundesliga/apps/leagues/migrations/0007_auto_20200806_1857.py @@ -4,70 +4,69 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0006_auto_20200806_1711'), + ("leagues", "0006_auto_20200806_1711"), ] operations = [ migrations.AddField( - model_name='player', - name='type', - field=models.IntegerField(choices=[(1, 'Player'), (2, 'Team')], default=1), + model_name="player", + name="type", + field=models.IntegerField(choices=[(1, "Player"), (2, "Team")], default=1), ), migrations.AlterField( - model_name='player', - name='age', + model_name="player", + name="age", field=models.IntegerField(default=0), ), migrations.AlterField( - model_name='player', - name='fantasy_positions', - field=models.CharField(default='', max_length=50), + model_name="player", + name="fantasy_positions", + field=models.CharField(default="", max_length=50), ), migrations.AlterField( - model_name='player', - name='first_name', - field=models.CharField(default='', max_length=50), + model_name="player", + name="first_name", + field=models.CharField(default="", max_length=50), ), migrations.AlterField( - model_name='player', - name='hashtag', + model_name="player", + name="hashtag", field=models.CharField(max_length=50, null=True), ), migrations.AlterField( - model_name='player', - name='height', + model_name="player", + name="height", field=models.CharField(max_length=10, null=True), ), migrations.AlterField( - model_name='player', - name='last_name', - field=models.CharField(default='', max_length=50), + model_name="player", + name="last_name", + field=models.CharField(default="", max_length=50), ), migrations.AlterField( - model_name='player', - name='number', + model_name="player", + name="number", field=models.IntegerField(default=0), ), migrations.AlterField( - model_name='player', - name='position', + model_name="player", + name="position", field=models.CharField(max_length=50, null=True), ), migrations.AlterField( - model_name='player', - name='sleeper_id', + model_name="player", + name="sleeper_id", field=models.CharField(db_index=True, max_length=10, unique=True), ), migrations.AlterField( - model_name='player', - name='status', + model_name="player", + name="status", field=models.CharField(max_length=20, null=True), ), migrations.AlterField( - model_name='player', - name='weight', + model_name="player", + name="weight", field=models.IntegerField(default=0), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0008_auto_20200806_1910.py b/DSTBundesliga/apps/leagues/migrations/0008_auto_20200806_1910.py index b36eb42..deaae9b 100644 --- a/DSTBundesliga/apps/leagues/migrations/0008_auto_20200806_1910.py +++ b/DSTBundesliga/apps/leagues/migrations/0008_auto_20200806_1910.py @@ -4,25 +4,24 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0007_auto_20200806_1857'), + ("leagues", "0007_auto_20200806_1857"), ] operations = [ migrations.AlterField( - model_name='draft', - name='last_message_id', + model_name="draft", + name="last_message_id", field=models.CharField(max_length=50, null=True), ), migrations.AlterField( - model_name='draft', - name='last_message_time', + model_name="draft", + name="last_message_time", field=models.DateTimeField(null=True), ), migrations.AlterField( - model_name='draft', - name='last_picked', + model_name="draft", + name="last_picked", field=models.DateTimeField(null=True), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0009_auto_20200806_2116.py b/DSTBundesliga/apps/leagues/migrations/0009_auto_20200806_2116.py index d1c29c2..5379c66 100644 --- a/DSTBundesliga/apps/leagues/migrations/0009_auto_20200806_2116.py +++ b/DSTBundesliga/apps/leagues/migrations/0009_auto_20200806_2116.py @@ -5,20 +5,19 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0008_auto_20200806_1910'), + ("leagues", "0008_auto_20200806_1910"), ] operations = [ migrations.AlterField( - model_name='draft', - name='draft_order', + model_name="draft", + name="draft_order", field=jsonfield.fields.JSONField(blank=True, null=True), ), migrations.AlterField( - model_name='draft', - name='slot_to_roster_id', + model_name="draft", + name="slot_to_roster_id", field=jsonfield.fields.JSONField(blank=True, null=True), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0010_auto_20200807_1910.py b/DSTBundesliga/apps/leagues/migrations/0010_auto_20200807_1910.py index e25ff2d..2336fa8 100644 --- a/DSTBundesliga/apps/leagues/migrations/0010_auto_20200807_1910.py +++ b/DSTBundesliga/apps/leagues/migrations/0010_auto_20200807_1910.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0009_auto_20200806_2116'), + ("leagues", "0009_auto_20200806_2116"), ] operations = [ migrations.AlterField( - model_name='draft', - name='start_time', + model_name="draft", + name="start_time", field=models.DateTimeField(blank=True, null=True), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0011_news.py b/DSTBundesliga/apps/leagues/migrations/0011_news.py index 6535b63..d7f27e9 100644 --- a/DSTBundesliga/apps/leagues/migrations/0011_news.py +++ b/DSTBundesliga/apps/leagues/migrations/0011_news.py @@ -4,19 +4,26 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0010_auto_20200807_1910'), + ("leagues", "0010_auto_20200807_1910"), ] operations = [ migrations.CreateModel( - name='News', + name="News", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('title', models.TextField()), - ('content', models.TextField()), - ('date', models.DateField(auto_now=True)), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("title", models.TextField()), + ("content", models.TextField()), + ("date", models.DateField(auto_now=True)), ], ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0012_auto_20200809_1102.py b/DSTBundesliga/apps/leagues/migrations/0012_auto_20200809_1102.py index 789ee16..c658e71 100644 --- a/DSTBundesliga/apps/leagues/migrations/0012_auto_20200809_1102.py +++ b/DSTBundesliga/apps/leagues/migrations/0012_auto_20200809_1102.py @@ -4,19 +4,18 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0011_news'), + ("leagues", "0011_news"), ] operations = [ migrations.AlterModelOptions( - name='news', - options={'verbose_name_plural': 'News'}, + name="news", + options={"verbose_name_plural": "News"}, ), migrations.AlterField( - model_name='news', - name='date', + model_name="news", + name="date", field=models.DateTimeField(auto_now=True), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0013_auto_20200809_1141.py b/DSTBundesliga/apps/leagues/migrations/0013_auto_20200809_1141.py index c19ac79..15535fa 100644 --- a/DSTBundesliga/apps/leagues/migrations/0013_auto_20200809_1141.py +++ b/DSTBundesliga/apps/leagues/migrations/0013_auto_20200809_1141.py @@ -5,15 +5,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0012_auto_20200809_1102'), + ("leagues", "0012_auto_20200809_1102"), ] operations = [ migrations.AlterField( - model_name='news', - name='content', + model_name="news", + name="content", field=tinymce.models.HTMLField(), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0014_auto_20200816_1703.py b/DSTBundesliga/apps/leagues/migrations/0014_auto_20200816_1703.py index 8d2186c..26590d2 100644 --- a/DSTBundesliga/apps/leagues/migrations/0014_auto_20200816_1703.py +++ b/DSTBundesliga/apps/leagues/migrations/0014_auto_20200816_1703.py @@ -5,19 +5,23 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0013_auto_20200809_1141'), + ("leagues", "0013_auto_20200809_1141"), ] operations = [ migrations.RemoveField( - model_name='pick', - name='user', + model_name="pick", + name="user", ), migrations.AddField( - model_name='pick', - name='owner', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='picks', to='leagues.DSTPlayer'), + model_name="pick", + name="owner", + field=models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name="picks", + to="leagues.DSTPlayer", + ), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0015_league_conference.py b/DSTBundesliga/apps/leagues/migrations/0015_league_conference.py index c1c7520..a5981e4 100644 --- a/DSTBundesliga/apps/leagues/migrations/0015_league_conference.py +++ b/DSTBundesliga/apps/leagues/migrations/0015_league_conference.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0014_auto_20200816_1703'), + ("leagues", "0014_auto_20200816_1703"), ] operations = [ migrations.AddField( - model_name='league', - name='conference', + model_name="league", + name="conference", field=models.CharField(max_length=30, null=True), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0016_auto_20200818_2031.py b/DSTBundesliga/apps/leagues/migrations/0016_auto_20200818_2031.py index 3db4652..0d6cc42 100644 --- a/DSTBundesliga/apps/leagues/migrations/0016_auto_20200818_2031.py +++ b/DSTBundesliga/apps/leagues/migrations/0016_auto_20200818_2031.py @@ -4,20 +4,19 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0015_league_conference'), + ("leagues", "0015_league_conference"), ] operations = [ migrations.AlterField( - model_name='roster', - name='players', + model_name="roster", + name="players", field=models.CharField(max_length=255, null=True), ), migrations.AlterField( - model_name='roster', - name='reserve', + model_name="roster", + name="reserve", field=models.CharField(max_length=100, null=True), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0017_auto_20200903_2012.py b/DSTBundesliga/apps/leagues/migrations/0017_auto_20200903_2012.py index 8c76fff..87120df 100644 --- a/DSTBundesliga/apps/leagues/migrations/0017_auto_20200903_2012.py +++ b/DSTBundesliga/apps/leagues/migrations/0017_auto_20200903_2012.py @@ -5,20 +5,27 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0016_auto_20200818_2031'), + ("leagues", "0016_auto_20200818_2031"), ] operations = [ migrations.AlterField( - model_name='draft', - name='league', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='drafts', to='leagues.League'), + model_name="draft", + name="league", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="drafts", + to="leagues.League", + ), ), migrations.AlterField( - model_name='pick', - name='draft', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='picks', to='leagues.Draft'), + model_name="pick", + name="draft", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="picks", + to="leagues.Draft", + ), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0018_matchup.py b/DSTBundesliga/apps/leagues/migrations/0018_matchup.py index 1542263..1609848 100644 --- a/DSTBundesliga/apps/leagues/migrations/0018_matchup.py +++ b/DSTBundesliga/apps/leagues/migrations/0018_matchup.py @@ -4,27 +4,34 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0017_auto_20200903_2012'), + ("leagues", "0017_auto_20200903_2012"), ] operations = [ migrations.CreateModel( - name='Matchup', + name="Matchup", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('week', models.IntegerField(db_index=True)), - ('matchup_id', models.IntegerField(db_index=True)), - ('league_id', models.CharField(db_index=True, max_length=50)), - ('roster_id_one', models.IntegerField()), - ('starters_one', models.CharField(max_length=255, null=True)), - ('players_one', models.CharField(max_length=255, null=True)), - ('points_one', models.DecimalField(decimal_places=3, max_digits=6)), - ('roster_id_two', models.IntegerField()), - ('starters_two', models.CharField(max_length=255, null=True)), - ('players_two', models.CharField(max_length=255, null=True)), - ('points_two', models.DecimalField(decimal_places=3, max_digits=6)), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("week", models.IntegerField(db_index=True)), + ("matchup_id", models.IntegerField(db_index=True)), + ("league_id", models.CharField(db_index=True, max_length=50)), + ("roster_id_one", models.IntegerField()), + ("starters_one", models.CharField(max_length=255, null=True)), + ("players_one", models.CharField(max_length=255, null=True)), + ("points_one", models.DecimalField(decimal_places=3, max_digits=6)), + ("roster_id_two", models.IntegerField()), + ("starters_two", models.CharField(max_length=255, null=True)), + ("players_two", models.CharField(max_length=255, null=True)), + ("points_two", models.DecimalField(decimal_places=3, max_digits=6)), ], ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0019_auto_20200915_1913.py b/DSTBundesliga/apps/leagues/migrations/0019_auto_20200915_1913.py index 577f5f1..06db94a 100644 --- a/DSTBundesliga/apps/leagues/migrations/0019_auto_20200915_1913.py +++ b/DSTBundesliga/apps/leagues/migrations/0019_auto_20200915_1913.py @@ -6,26 +6,38 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0018_matchup'), + ("leagues", "0018_matchup"), ] operations = [ migrations.AlterModelOptions( - name='roster', - options={'ordering': ['-wins', '-ties', '-fpts', '-fpts_decimal']}, + name="roster", + options={"ordering": ["-wins", "-ties", "-fpts", "-fpts_decimal"]}, ), migrations.CreateModel( - name='StatsWeek', + name="StatsWeek", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('week', models.IntegerField(db_index=True)), - ('season_type', models.CharField(max_length=30)), - ('season', models.IntegerField(default=2020)), - ('points', models.DecimalField(decimal_places=3, max_digits=6)), - ('stats', jsonfield.fields.JSONField()), - ('player', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='leagues.Player')), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("week", models.IntegerField(db_index=True)), + ("season_type", models.CharField(max_length=30)), + ("season", models.IntegerField(default=2020)), + ("points", models.DecimalField(decimal_places=3, max_digits=6)), + ("stats", jsonfield.fields.JSONField()), + ( + "player", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="leagues.Player" + ), + ), ], ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0020_auto_20200915_2009.py b/DSTBundesliga/apps/leagues/migrations/0020_auto_20200915_2009.py index d624ebe..32e2c9d 100644 --- a/DSTBundesliga/apps/leagues/migrations/0020_auto_20200915_2009.py +++ b/DSTBundesliga/apps/leagues/migrations/0020_auto_20200915_2009.py @@ -5,21 +5,20 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0019_auto_20200915_1913'), + ("leagues", "0019_auto_20200915_1913"), ] operations = [ migrations.AddField( - model_name='statsweek', - name='projected_points', + model_name="statsweek", + name="projected_points", field=models.DecimalField(decimal_places=3, default=0, max_digits=6), preserve_default=False, ), migrations.AddField( - model_name='statsweek', - name='projected_stats', + model_name="statsweek", + name="projected_stats", field=jsonfield.fields.JSONField(default={}), preserve_default=False, ), diff --git a/DSTBundesliga/apps/leagues/migrations/0021_auto_20201028_1933.py b/DSTBundesliga/apps/leagues/migrations/0021_auto_20201028_1933.py index 7ba48fb..21ad418 100644 --- a/DSTBundesliga/apps/leagues/migrations/0021_auto_20201028_1933.py +++ b/DSTBundesliga/apps/leagues/migrations/0021_auto_20201028_1933.py @@ -5,25 +5,28 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0020_auto_20200915_2009'), + ("leagues", "0020_auto_20200915_2009"), ] operations = [ migrations.AlterField( - model_name='roster', - name='league', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='rosters', to='leagues.League'), + model_name="roster", + name="league", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="rosters", + to="leagues.League", + ), ), migrations.AlterField( - model_name='statsweek', - name='points', + model_name="statsweek", + name="points", field=models.DecimalField(decimal_places=3, default=0, max_digits=6), ), migrations.AlterField( - model_name='statsweek', - name='projected_points', + model_name="statsweek", + name="projected_points", field=models.DecimalField(decimal_places=3, default=0, max_digits=6), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0022_auto_20201028_1936.py b/DSTBundesliga/apps/leagues/migrations/0022_auto_20201028_1936.py index 3326ff2..f14d742 100644 --- a/DSTBundesliga/apps/leagues/migrations/0022_auto_20201028_1936.py +++ b/DSTBundesliga/apps/leagues/migrations/0022_auto_20201028_1936.py @@ -5,15 +5,18 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0021_auto_20201028_1933'), + ("leagues", "0021_auto_20201028_1933"), ] operations = [ migrations.AlterField( - model_name='statsweek', - name='player', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='stats', to='leagues.Player'), + model_name="statsweek", + name="player", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="stats", + to="leagues.Player", + ), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0023_auto_20201107_1629.py b/DSTBundesliga/apps/leagues/migrations/0023_auto_20201107_1629.py index ab5a5c1..6feb86e 100644 --- a/DSTBundesliga/apps/leagues/migrations/0023_auto_20201107_1629.py +++ b/DSTBundesliga/apps/leagues/migrations/0023_auto_20201107_1629.py @@ -5,15 +5,18 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0022_auto_20201028_1936'), + ("leagues", "0022_auto_20201028_1936"), ] operations = [ migrations.AlterField( - model_name='pick', - name='player', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='picks', to='leagues.Player'), + model_name="pick", + name="player", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="picks", + to="leagues.Player", + ), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0024_news_image.py b/DSTBundesliga/apps/leagues/migrations/0024_news_image.py index 8421703..d5352a4 100644 --- a/DSTBundesliga/apps/leagues/migrations/0024_news_image.py +++ b/DSTBundesliga/apps/leagues/migrations/0024_news_image.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0023_auto_20201107_1629'), + ("leagues", "0023_auto_20201107_1629"), ] operations = [ migrations.AddField( - model_name='news', - name='image', - field=models.CharField(default='dst_logo_96.png', max_length=255), + model_name="news", + name="image", + field=models.CharField(default="dst_logo_96.png", max_length=255), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0025_playoffmatchup.py b/DSTBundesliga/apps/leagues/migrations/0025_playoffmatchup.py index 806ee55..81e2a4c 100644 --- a/DSTBundesliga/apps/leagues/migrations/0025_playoffmatchup.py +++ b/DSTBundesliga/apps/leagues/migrations/0025_playoffmatchup.py @@ -4,24 +4,31 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0024_news_image'), + ("leagues", "0024_news_image"), ] operations = [ migrations.CreateModel( - name='PlayoffMatchup', + name="PlayoffMatchup", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('bracket', models.CharField(db_index=True, max_length=20)), - ('round', models.IntegerField(db_index=True)), - ('matchup_id', models.IntegerField(db_index=True)), - ('league_id', models.CharField(db_index=True, max_length=50)), - ('roster_id_one', models.IntegerField(null=True)), - ('roster_id_two', models.IntegerField(null=True)), - ('winner', models.IntegerField(null=True)), - ('loser', models.IntegerField(null=True)), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("bracket", models.CharField(db_index=True, max_length=20)), + ("round", models.IntegerField(db_index=True)), + ("matchup_id", models.IntegerField(db_index=True)), + ("league_id", models.CharField(db_index=True, max_length=50)), + ("roster_id_one", models.IntegerField(null=True)), + ("roster_id_two", models.IntegerField(null=True)), + ("winner", models.IntegerField(null=True)), + ("loser", models.IntegerField(null=True)), ], ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0026_playoffmatchup_rank.py b/DSTBundesliga/apps/leagues/migrations/0026_playoffmatchup_rank.py index b94be97..518ce55 100644 --- a/DSTBundesliga/apps/leagues/migrations/0026_playoffmatchup_rank.py +++ b/DSTBundesliga/apps/leagues/migrations/0026_playoffmatchup_rank.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0025_playoffmatchup'), + ("leagues", "0025_playoffmatchup"), ] operations = [ migrations.AddField( - model_name='playoffmatchup', - name='rank', + model_name="playoffmatchup", + name="rank", field=models.IntegerField(null=True), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0027_season.py b/DSTBundesliga/apps/leagues/migrations/0027_season.py index a55cb0a..dceee2a 100644 --- a/DSTBundesliga/apps/leagues/migrations/0027_season.py +++ b/DSTBundesliga/apps/leagues/migrations/0027_season.py @@ -4,19 +4,26 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0026_playoffmatchup_rank'), + ("leagues", "0026_playoffmatchup_rank"), ] operations = [ migrations.CreateModel( - name='Season', + name="Season", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('year', models.IntegerField(default=2021)), - ('name', models.CharField(max_length=50)), - ('active', models.BooleanField(default=False)), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("year", models.IntegerField(default=2021)), + ("name", models.CharField(max_length=50)), + ("active", models.BooleanField(default=False)), ], ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0028_delete_news.py b/DSTBundesliga/apps/leagues/migrations/0028_delete_news.py index 0e4c111..224fa98 100644 --- a/DSTBundesliga/apps/leagues/migrations/0028_delete_news.py +++ b/DSTBundesliga/apps/leagues/migrations/0028_delete_news.py @@ -4,14 +4,13 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0027_season'), - ('dstffbl', '0003_auto_20210501_1939'), + ("leagues", "0027_season"), + ("dstffbl", "0003_auto_20210501_1939"), ] operations = [ migrations.DeleteModel( - name='News', + name="News", ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0029_league_type.py b/DSTBundesliga/apps/leagues/migrations/0029_league_type.py index b4bb5a3..cca1546 100644 --- a/DSTBundesliga/apps/leagues/migrations/0029_league_type.py +++ b/DSTBundesliga/apps/leagues/migrations/0029_league_type.py @@ -4,15 +4,17 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0028_delete_news'), + ("leagues", "0028_delete_news"), ] operations = [ migrations.AddField( - model_name='league', - name='type', - field=models.IntegerField(choices=[(1, 'Bundesliga'), (2, 'Champions League'), (3, 'Hörerliga')], default=1), + model_name="league", + name="type", + field=models.IntegerField( + choices=[(1, "Bundesliga"), (2, "Champions League"), (3, "Hörerliga")], + default=1, + ), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0030_auto_20210725_1424.py b/DSTBundesliga/apps/leagues/migrations/0030_auto_20210725_1424.py index 64769b8..00229f2 100644 --- a/DSTBundesliga/apps/leagues/migrations/0030_auto_20210725_1424.py +++ b/DSTBundesliga/apps/leagues/migrations/0030_auto_20210725_1424.py @@ -4,14 +4,13 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0029_league_type'), + ("leagues", "0029_league_type"), ] operations = [ migrations.AlterModelOptions( - name='league', - options={'ordering': ['-level', 'sleeper_name']}, + name="league", + options={"ordering": ["-level", "sleeper_name"]}, ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0031_auto_20210808_1100.py b/DSTBundesliga/apps/leagues/migrations/0031_auto_20210808_1100.py index 9053230..fb2f03e 100644 --- a/DSTBundesliga/apps/leagues/migrations/0031_auto_20210808_1100.py +++ b/DSTBundesliga/apps/leagues/migrations/0031_auto_20210808_1100.py @@ -4,18 +4,17 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0030_auto_20210725_1424'), + ("leagues", "0030_auto_20210725_1424"), ] operations = [ migrations.RemoveField( - model_name='league', - name='season', + model_name="league", + name="season", ), migrations.RemoveField( - model_name='statsweek', - name='season', + model_name="statsweek", + name="season", ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0032_auto_20210808_1101.py b/DSTBundesliga/apps/leagues/migrations/0032_auto_20210808_1101.py index 6437afa..1de6bfd 100644 --- a/DSTBundesliga/apps/leagues/migrations/0032_auto_20210808_1101.py +++ b/DSTBundesliga/apps/leagues/migrations/0032_auto_20210808_1101.py @@ -6,30 +6,45 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0031_auto_20210808_1100'), + ("leagues", "0031_auto_20210808_1100"), ] operations = [ migrations.AddField( - model_name='league', - name='season', - field=models.ForeignKey(default=DSTBundesliga.apps.leagues.models.Season.get_last_id, on_delete=django.db.models.deletion.CASCADE, to='leagues.season'), + model_name="league", + name="season", + field=models.ForeignKey( + default=DSTBundesliga.apps.leagues.models.Season.get_last_id, + on_delete=django.db.models.deletion.CASCADE, + to="leagues.season", + ), ), migrations.AddField( - model_name='matchup', - name='season', - field=models.ForeignKey(default=DSTBundesliga.apps.leagues.models.Season.get_last_id, on_delete=django.db.models.deletion.CASCADE, to='leagues.season'), + model_name="matchup", + name="season", + field=models.ForeignKey( + default=DSTBundesliga.apps.leagues.models.Season.get_last_id, + on_delete=django.db.models.deletion.CASCADE, + to="leagues.season", + ), ), migrations.AddField( - model_name='playoffmatchup', - name='season', - field=models.ForeignKey(default=DSTBundesliga.apps.leagues.models.Season.get_last_id, on_delete=django.db.models.deletion.CASCADE, to='leagues.season'), + model_name="playoffmatchup", + name="season", + field=models.ForeignKey( + default=DSTBundesliga.apps.leagues.models.Season.get_last_id, + on_delete=django.db.models.deletion.CASCADE, + to="leagues.season", + ), ), migrations.AddField( - model_name='statsweek', - name='season', - field=models.ForeignKey(default=DSTBundesliga.apps.leagues.models.Season.get_last_id, on_delete=django.db.models.deletion.CASCADE, to='leagues.season'), + model_name="statsweek", + name="season", + field=models.ForeignKey( + default=DSTBundesliga.apps.leagues.models.Season.get_last_id, + on_delete=django.db.models.deletion.CASCADE, + to="leagues.season", + ), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0033_auto_20210808_1101.py b/DSTBundesliga/apps/leagues/migrations/0033_auto_20210808_1101.py index 8bcb939..5ddb5ec 100644 --- a/DSTBundesliga/apps/leagues/migrations/0033_auto_20210808_1101.py +++ b/DSTBundesliga/apps/leagues/migrations/0033_auto_20210808_1101.py @@ -6,30 +6,45 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0032_auto_20210808_1101'), + ("leagues", "0032_auto_20210808_1101"), ] operations = [ migrations.AlterField( - model_name='league', - name='season', - field=models.ForeignKey(default=DSTBundesliga.apps.leagues.models.Season.get_active_id, on_delete=django.db.models.deletion.CASCADE, to='leagues.season'), + model_name="league", + name="season", + field=models.ForeignKey( + default=DSTBundesliga.apps.leagues.models.Season.get_active_id, + on_delete=django.db.models.deletion.CASCADE, + to="leagues.season", + ), ), migrations.AlterField( - model_name='matchup', - name='season', - field=models.ForeignKey(default=DSTBundesliga.apps.leagues.models.Season.get_active_id, on_delete=django.db.models.deletion.CASCADE, to='leagues.season'), + model_name="matchup", + name="season", + field=models.ForeignKey( + default=DSTBundesliga.apps.leagues.models.Season.get_active_id, + on_delete=django.db.models.deletion.CASCADE, + to="leagues.season", + ), ), migrations.AlterField( - model_name='playoffmatchup', - name='season', - field=models.ForeignKey(default=DSTBundesliga.apps.leagues.models.Season.get_active_id, on_delete=django.db.models.deletion.CASCADE, to='leagues.season'), + model_name="playoffmatchup", + name="season", + field=models.ForeignKey( + default=DSTBundesliga.apps.leagues.models.Season.get_active_id, + on_delete=django.db.models.deletion.CASCADE, + to="leagues.season", + ), ), migrations.AlterField( - model_name='statsweek', - name='season', - field=models.ForeignKey(default=DSTBundesliga.apps.leagues.models.Season.get_active_id, on_delete=django.db.models.deletion.CASCADE, to='leagues.season'), + model_name="statsweek", + name="season", + field=models.ForeignKey( + default=DSTBundesliga.apps.leagues.models.Season.get_active_id, + on_delete=django.db.models.deletion.CASCADE, + to="leagues.season", + ), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0034_playerdraftstats.py b/DSTBundesliga/apps/leagues/migrations/0034_playerdraftstats.py index a7f8a11..99d3330 100644 --- a/DSTBundesliga/apps/leagues/migrations/0034_playerdraftstats.py +++ b/DSTBundesliga/apps/leagues/migrations/0034_playerdraftstats.py @@ -6,25 +6,39 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0033_auto_20210808_1101'), + ("leagues", "0033_auto_20210808_1101"), ] operations = [ migrations.CreateModel( - name='PlayerDraftStats', + name="PlayerDraftStats", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('player_id', models.CharField(max_length=10, null=True)), - ('player_name', models.CharField(max_length=100)), - ('player_team', models.CharField(max_length=10)), - ('player_position', models.CharField(max_length=10)), - ('pick_count', models.IntegerField(default=0)), - ('adp', models.DecimalField(decimal_places=2, max_digits=6)), - ('highest_pick', models.IntegerField()), - ('lowest_pick', models.IntegerField()), - ('season', models.ForeignKey(default=DSTBundesliga.apps.leagues.models.Season.get_active_id, on_delete=django.db.models.deletion.CASCADE, to='leagues.season')), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("player_id", models.CharField(max_length=10, null=True)), + ("player_name", models.CharField(max_length=100)), + ("player_team", models.CharField(max_length=10)), + ("player_position", models.CharField(max_length=10)), + ("pick_count", models.IntegerField(default=0)), + ("adp", models.DecimalField(decimal_places=2, max_digits=6)), + ("highest_pick", models.IntegerField()), + ("lowest_pick", models.IntegerField()), + ( + "season", + models.ForeignKey( + default=DSTBundesliga.apps.leagues.models.Season.get_active_id, + on_delete=django.db.models.deletion.CASCADE, + to="leagues.season", + ), + ), ], ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0035_waiverpickup.py b/DSTBundesliga/apps/leagues/migrations/0035_waiverpickup.py index 98cac0c..d62aa4b 100644 --- a/DSTBundesliga/apps/leagues/migrations/0035_waiverpickup.py +++ b/DSTBundesliga/apps/leagues/migrations/0035_waiverpickup.py @@ -6,23 +6,47 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0034_playerdraftstats'), + ("leagues", "0034_playerdraftstats"), ] operations = [ migrations.CreateModel( - name='WaiverPickup', + name="WaiverPickup", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('week', models.IntegerField(default=1)), - ('status', models.CharField(db_index=True, max_length=20)), - ('bid', models.IntegerField(default=0)), - ('changed_ts', models.DateTimeField(null=True)), - ('player', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='leagues.player')), - ('roster', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='leagues.roster')), - ('season', models.ForeignKey(default=DSTBundesliga.apps.leagues.models.Season.get_active_id, on_delete=django.db.models.deletion.CASCADE, to='leagues.season')), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("week", models.IntegerField(default=1)), + ("status", models.CharField(db_index=True, max_length=20)), + ("bid", models.IntegerField(default=0)), + ("changed_ts", models.DateTimeField(null=True)), + ( + "player", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="leagues.player" + ), + ), + ( + "roster", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="leagues.roster" + ), + ), + ( + "season", + models.ForeignKey( + default=DSTBundesliga.apps.leagues.models.Season.get_active_id, + on_delete=django.db.models.deletion.CASCADE, + to="leagues.season", + ), + ), ], ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0036_auto_20211016_1344.py b/DSTBundesliga/apps/leagues/migrations/0036_auto_20211016_1344.py index 11ad6be..2988665 100644 --- a/DSTBundesliga/apps/leagues/migrations/0036_auto_20211016_1344.py +++ b/DSTBundesliga/apps/leagues/migrations/0036_auto_20211016_1344.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0035_waiverpickup'), + ("leagues", "0035_waiverpickup"), ] operations = [ migrations.AlterField( - model_name='waiverpickup', - name='changed_ts', + model_name="waiverpickup", + name="changed_ts", field=models.DateTimeField(db_index=True, null=True), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0037_auto_20220720_1847.py b/DSTBundesliga/apps/leagues/migrations/0037_auto_20220720_1847.py index 0c91a2c..48e1a3d 100644 --- a/DSTBundesliga/apps/leagues/migrations/0037_auto_20220720_1847.py +++ b/DSTBundesliga/apps/leagues/migrations/0037_auto_20220720_1847.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0036_auto_20211016_1344'), + ("leagues", "0036_auto_20211016_1344"), ] operations = [ migrations.AlterField( - model_name='season', - name='year', + model_name="season", + name="year", field=models.IntegerField(default=2022), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0038_auto_20220727_2036.py b/DSTBundesliga/apps/leagues/migrations/0038_auto_20220727_2036.py index 77ed561..80cddd2 100644 --- a/DSTBundesliga/apps/leagues/migrations/0038_auto_20220727_2036.py +++ b/DSTBundesliga/apps/leagues/migrations/0038_auto_20220727_2036.py @@ -6,29 +6,54 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0037_auto_20220720_1847'), + ("leagues", "0037_auto_20220720_1847"), ] operations = [ migrations.AlterModelOptions( - name='season', - options={'ordering': ['-year']}, + name="season", + options={"ordering": ["-year"]}, ), migrations.CreateModel( - name='FinalSeasonStanding', + name="FinalSeasonStanding", fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('rank_in_league', models.IntegerField()), - ('points', models.IntegerField(default=0)), - ('points_decimal', models.IntegerField(default=0)), - ('points_ranking_overall', models.IntegerField()), - ('points_ranking_on_level', models.IntegerField()), - ('points_ranking_in_league', models.IntegerField()), - ('dst_player', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='leagues.dstplayer')), - ('league', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='leagues.league')), - ('season', models.ForeignKey(default=DSTBundesliga.apps.leagues.models.Season.get_active_id, on_delete=django.db.models.deletion.CASCADE, to='leagues.season')), + ( + "id", + models.AutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("rank_in_league", models.IntegerField()), + ("points", models.IntegerField(default=0)), + ("points_decimal", models.IntegerField(default=0)), + ("points_ranking_overall", models.IntegerField()), + ("points_ranking_on_level", models.IntegerField()), + ("points_ranking_in_league", models.IntegerField()), + ( + "dst_player", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="leagues.dstplayer", + ), + ), + ( + "league", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="leagues.league" + ), + ), + ( + "season", + models.ForeignKey( + default=DSTBundesliga.apps.leagues.models.Season.get_active_id, + on_delete=django.db.models.deletion.CASCADE, + to="leagues.season", + ), + ), ], ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0039_auto_20220727_2121.py b/DSTBundesliga/apps/leagues/migrations/0039_auto_20220727_2121.py index af55f92..6090bce 100644 --- a/DSTBundesliga/apps/leagues/migrations/0039_auto_20220727_2121.py +++ b/DSTBundesliga/apps/leagues/migrations/0039_auto_20220727_2121.py @@ -4,30 +4,29 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0038_auto_20220727_2036'), + ("leagues", "0038_auto_20220727_2036"), ] operations = [ migrations.AlterField( - model_name='finalseasonstanding', - name='points_ranking_in_league', + model_name="finalseasonstanding", + name="points_ranking_in_league", field=models.IntegerField(default=0), ), migrations.AlterField( - model_name='finalseasonstanding', - name='points_ranking_on_level', + model_name="finalseasonstanding", + name="points_ranking_on_level", field=models.IntegerField(default=0), ), migrations.AlterField( - model_name='finalseasonstanding', - name='points_ranking_overall', + model_name="finalseasonstanding", + name="points_ranking_overall", field=models.IntegerField(default=0), ), migrations.AlterField( - model_name='finalseasonstanding', - name='rank_in_league', + model_name="finalseasonstanding", + name="rank_in_league", field=models.IntegerField(default=0), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0040_auto_20220728_2020.py b/DSTBundesliga/apps/leagues/migrations/0040_auto_20220728_2020.py index c173049..50c58f1 100644 --- a/DSTBundesliga/apps/leagues/migrations/0040_auto_20220728_2020.py +++ b/DSTBundesliga/apps/leagues/migrations/0040_auto_20220728_2020.py @@ -5,34 +5,43 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0039_auto_20220727_2121'), + ("leagues", "0039_auto_20220727_2121"), ] operations = [ migrations.AlterModelOptions( - name='finalseasonstanding', - options={'ordering': ['points_ranking_overall', 'points_ranking_on_level', 'points_ranking_in_league']}, + name="finalseasonstanding", + options={ + "ordering": [ + "points_ranking_overall", + "points_ranking_on_level", + "points_ranking_in_league", + ] + }, ), migrations.AlterField( - model_name='finalseasonstanding', - name='dst_player', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='leagues.dstplayer'), + model_name="finalseasonstanding", + name="dst_player", + field=models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.CASCADE, + to="leagues.dstplayer", + ), ), migrations.AlterField( - model_name='finalseasonstanding', - name='points_ranking_in_league', - field=models.IntegerField(default=0, verbose_name='#league'), + model_name="finalseasonstanding", + name="points_ranking_in_league", + field=models.IntegerField(default=0, verbose_name="#league"), ), migrations.AlterField( - model_name='finalseasonstanding', - name='points_ranking_on_level', - field=models.IntegerField(default=0, verbose_name='#level'), + model_name="finalseasonstanding", + name="points_ranking_on_level", + field=models.IntegerField(default=0, verbose_name="#level"), ), migrations.AlterField( - model_name='finalseasonstanding', - name='points_ranking_overall', - field=models.IntegerField(default=0, verbose_name='#overall'), + model_name="finalseasonstanding", + name="points_ranking_overall", + field=models.IntegerField(default=0, verbose_name="#overall"), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0041_auto_20220728_2034.py b/DSTBundesliga/apps/leagues/migrations/0041_auto_20220728_2034.py index 7ea0429..241d5ba 100644 --- a/DSTBundesliga/apps/leagues/migrations/0041_auto_20220728_2034.py +++ b/DSTBundesliga/apps/leagues/migrations/0041_auto_20220728_2034.py @@ -5,19 +5,22 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0040_auto_20220728_2020'), + ("leagues", "0040_auto_20220728_2020"), ] operations = [ migrations.RemoveField( - model_name='finalseasonstanding', - name='dst_player', + model_name="finalseasonstanding", + name="dst_player", ), migrations.AddField( - model_name='finalseasonstanding', - name='roster', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to='leagues.roster'), + model_name="finalseasonstanding", + name="roster", + field=models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.CASCADE, + to="leagues.roster", + ), ), ] diff --git a/DSTBundesliga/apps/leagues/migrations/0042_auto_20230730_1959.py b/DSTBundesliga/apps/leagues/migrations/0042_auto_20230730_1959.py index cf2e7ba..4a75521 100644 --- a/DSTBundesliga/apps/leagues/migrations/0042_auto_20230730_1959.py +++ b/DSTBundesliga/apps/leagues/migrations/0042_auto_20230730_1959.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('leagues', '0041_auto_20220728_2034'), + ("leagues", "0041_auto_20220728_2034"), ] operations = [ migrations.AlterField( - model_name='season', - name='year', + model_name="season", + name="year", field=models.IntegerField(default=2023), ), ] diff --git a/DSTBundesliga/apps/leagues/models.py b/DSTBundesliga/apps/leagues/models.py index af8bb47..62a5e44 100644 --- a/DSTBundesliga/apps/leagues/models.py +++ b/DSTBundesliga/apps/leagues/models.py @@ -30,11 +30,16 @@ def __str__(self): def get_active(): current_season = int(state_servive.get_season()) - season, _ = Season.objects.get_or_create(active=True, year=current_season, defaults={ - 'year': current_season, - 'name': 'Saison {current_year}/{next_year}'.format(current_year=current_season, - next_year=current_season + 1) - }) + season, _ = Season.objects.get_or_create( + active=True, + year=current_season, + defaults={ + "year": current_season, + "name": "Saison {current_year}/{next_year}".format( + current_year=current_season, next_year=current_season + 1 + ), + }, + ) return season @@ -45,13 +50,16 @@ def get_active_id(): @staticmethod def get_last(): previous_season = int(state_servive.get_previous_season()) - season, _ = Season.objects.get_or_create(active=False, year=previous_season, - defaults={ - 'year': previous_season, - 'name': 'Saison {last_year}/{current_year}'.format( - last_year=previous_season, current_year=previous_season + 1) - } - ) + season, _ = Season.objects.get_or_create( + active=False, + year=previous_season, + defaults={ + "year": previous_season, + "name": "Saison {last_year}/{current_year}".format( + last_year=previous_season, current_year=previous_season + 1 + ), + }, + ) return season @@ -67,21 +75,23 @@ def get_active(self): class League(models.Model): class Meta: - ordering = ['-level', 'sleeper_name'] + ordering = ["-level", "sleeper_name"] BUNDESLIGA = 1 CL = 2 LISTENER = 3 TYPES = [ - (BUNDESLIGA, 'Bundesliga'), - (CL, 'Champions League'), - (LISTENER, 'Hörerliga'), + (BUNDESLIGA, "Bundesliga"), + (CL, "Champions League"), + (LISTENER, "Hörerliga"), ] objects = LeagueManager() - season = models.ForeignKey(Season, default=Season.get_active_id, on_delete=models.CASCADE) + season = models.ForeignKey( + Season, default=Season.get_active_id, on_delete=models.CASCADE + ) type = models.IntegerField(choices=TYPES, default=BUNDESLIGA) level = models.IntegerField(default=0) @@ -111,7 +121,7 @@ def __str__(self): @property def url(self): - return reverse('league-detail', kwargs={'league_id': self.sleeper_id}) + return reverse("league-detail", kwargs={"league_id": self.sleeper_id}) class DSTPlayer(models.Model): @@ -122,7 +132,9 @@ class DSTPlayer(models.Model): leagues = models.ManyToManyField(League) def __str__(self): - return "{display_name} - {sleeper_id}".format(display_name=self.display_name, sleeper_id=self.sleeper_id) + return "{display_name} - {sleeper_id}".format( + display_name=self.display_name, sleeper_id=self.sleeper_id + ) class Team(models.Model): @@ -136,17 +148,14 @@ def __str__(self): class Player(models.Model): PLAYER = 1 TEAM = 2 - TYPES = [ - (PLAYER, 'Player'), - (TEAM, 'Team') - ] + TYPES = [(PLAYER, "Player"), (TEAM, "Team")] type = models.IntegerField(choices=TYPES, default=PLAYER) # Sleeper Data sleeper_id = models.CharField(max_length=10, db_index=True, unique=True) - last_name = models.CharField(max_length=50, default='') - first_name = models.CharField(max_length=50, default='') - fantasy_positions = models.CharField(max_length=50, default='') + last_name = models.CharField(max_length=50, default="") + first_name = models.CharField(max_length=50, default="") + fantasy_positions = models.CharField(max_length=50, default="") team = models.ForeignKey(Team, on_delete=models.SET_NULL, null=True) hashtag = models.CharField(max_length=50, null=True) depth_chart_position = models.CharField(max_length=50, null=True) @@ -161,7 +170,9 @@ class Player(models.Model): @property def name(self): - return "{first_name} {last_name}".format(first_name=self.first_name, last_name=self.last_name) + return "{first_name} {last_name}".format( + first_name=self.first_name, last_name=self.last_name + ) def __str__(self): return self.name @@ -189,7 +200,7 @@ class Meta: reserve = models.CharField(max_length=100, null=True) players = models.CharField(max_length=255, null=True) owner = models.ForeignKey(DSTPlayer, on_delete=models.CASCADE, null=True) - league = models.ForeignKey(League, related_name='rosters', on_delete=models.CASCADE) + league = models.ForeignKey(League, related_name="rosters", on_delete=models.CASCADE) @property def points(self): @@ -217,7 +228,9 @@ class Draft(models.Model): class Pick(models.Model): # Sleeper Data player = models.ForeignKey(Player, on_delete=models.CASCADE, related_name="picks") - owner = models.ForeignKey(DSTPlayer, related_name="picks", on_delete=models.CASCADE, null=True) + owner = models.ForeignKey( + DSTPlayer, related_name="picks", on_delete=models.CASCADE, null=True + ) roster = models.ForeignKey(Roster, on_delete=models.CASCADE) draft = models.ForeignKey(Draft, related_name="picks", on_delete=models.CASCADE) round = models.IntegerField(default=1) @@ -226,14 +239,18 @@ class Pick(models.Model): metadata = JSONField() def __str__(self): - return "{round}.{draft_slot} ({pick_no}) - {player}".format(round=self.round, - draft_slot=self.draft_slot, - pick_no=self.pick_no, - player=self.player.name) + return "{round}.{draft_slot} ({pick_no}) - {player}".format( + round=self.round, + draft_slot=self.draft_slot, + pick_no=self.pick_no, + player=self.player.name, + ) class Matchup(models.Model): - season = models.ForeignKey(Season, default=Season.get_active_id, on_delete=models.CASCADE) + season = models.ForeignKey( + Season, default=Season.get_active_id, on_delete=models.CASCADE + ) week = models.IntegerField(db_index=True) matchup_id = models.IntegerField(db_index=True) @@ -249,7 +266,9 @@ class Matchup(models.Model): class PlayoffMatchup(models.Model): - season = models.ForeignKey(Season, default=Season.get_active_id, on_delete=models.CASCADE) + season = models.ForeignKey( + Season, default=Season.get_active_id, on_delete=models.CASCADE + ) bracket = models.CharField(max_length=20, db_index=True) round = models.IntegerField(db_index=True) @@ -263,7 +282,9 @@ class PlayoffMatchup(models.Model): class StatsWeek(models.Model): - season = models.ForeignKey(Season, default=Season.get_active_id, on_delete=models.CASCADE) + season = models.ForeignKey( + Season, default=Season.get_active_id, on_delete=models.CASCADE + ) week = models.IntegerField(db_index=True) season_type = models.CharField(max_length=30) @@ -275,7 +296,9 @@ class StatsWeek(models.Model): class PlayerDraftStats(models.Model): - season = models.ForeignKey(Season, default=Season.get_active_id, on_delete=models.CASCADE) + season = models.ForeignKey( + Season, default=Season.get_active_id, on_delete=models.CASCADE + ) player_id = models.CharField(max_length=10, null=True) player_name = models.CharField(max_length=100) player_team = models.CharField(max_length=10) @@ -287,7 +310,9 @@ class PlayerDraftStats(models.Model): class WaiverPickup(models.Model): - season = models.ForeignKey(Season, default=Season.get_active_id, on_delete=models.CASCADE, db_index=True) + season = models.ForeignKey( + Season, default=Season.get_active_id, on_delete=models.CASCADE, db_index=True + ) week = models.IntegerField(default=1) roster = models.ForeignKey(Roster, on_delete=models.CASCADE) status = models.CharField(max_length=20, db_index=True) @@ -301,18 +326,21 @@ def owner(self): class FinalSeasonStanding(models.Model): - class Meta: - ordering = ["points_ranking_overall", "points_ranking_on_level", "points_ranking_in_league"] + ordering = [ + "points_ranking_overall", + "points_ranking_on_level", + "points_ranking_in_league", + ] roster = models.ForeignKey(Roster, on_delete=models.CASCADE, null=True) league = models.ForeignKey(League, on_delete=models.CASCADE) - season = models.ForeignKey(Season, default=Season.get_active_id, on_delete=models.CASCADE, db_index=True) + season = models.ForeignKey( + Season, default=Season.get_active_id, on_delete=models.CASCADE, db_index=True + ) rank_in_league = models.IntegerField(default=0) points = models.IntegerField(default=0) points_decimal = models.IntegerField(default=0) points_ranking_overall = models.IntegerField(default=0, verbose_name="#overall") points_ranking_on_level = models.IntegerField(default=0, verbose_name="#level") points_ranking_in_league = models.IntegerField(default=0, verbose_name="#league") - - diff --git a/DSTBundesliga/apps/leagues/tables.py b/DSTBundesliga/apps/leagues/tables.py index 1842375..67c19d5 100644 --- a/DSTBundesliga/apps/leagues/tables.py +++ b/DSTBundesliga/apps/leagues/tables.py @@ -6,28 +6,38 @@ from django_tables2.utils import A import pytz -from DSTBundesliga.apps.leagues.models import League, Roster, Pick, Draft, Player, PlayerDraftStats, WaiverPickup +from DSTBundesliga.apps.leagues.models import ( + League, + Roster, + Pick, + Draft, + Player, + PlayerDraftStats, + WaiverPickup, +) def _get_date(record): if record.start_time < datetime.utcnow().replace(tzinfo=pytz.utc): return "Running" - return record.start_time.astimezone(pytz.timezone('Europe/Berlin')).strftime("%d.%m. %H:%M") + return record.start_time.astimezone(pytz.timezone("Europe/Berlin")).strftime( + "%d.%m. %H:%M" + ) class LeagueTable(tables.Table): - class Meta: model = League orderable = False - fields = ['league_title'] + fields = ["league_title"] - league_title = tables.TemplateColumn(template_name="Columns/league_title.html", empty_values=()) + league_title = tables.TemplateColumn( + template_name="Columns/league_title.html", empty_values=() + ) class RosterTable(tables.Table): - def __init__(self, data=None, ranking_offset=0): self.ranking_offset = ranking_offset super(RosterTable, self).__init__(data) @@ -35,27 +45,64 @@ def __init__(self, data=None, ranking_offset=0): class Meta: model = Roster orderable = False - fields = ['ranking', 'playoff_indicator', 'team_manager', 'faab', 'wins', 'losses', 'ties', 'points'] - - ranking = tables.Column(verbose_name='Pl.', empty_values=(), orderable=False, attrs={"td": {"class": "ranking"}, "th": {"class": "ranking"}}, ) - playoff_indicator = tables.TemplateColumn(verbose_name='', template_name="Columns/playoff_indicator.html", empty_values=(), attrs={"td": {"class": "playoff-indicator"}, "th": {"class": "playoff-indicator"}}) - team_manager = tables.TemplateColumn(verbose_name='Team Manager', template_name="Columns/team_manager.html", empty_values=(), attrs={"td": {"class": "team-manager"}, "th": {"class": "team-manager"}}) - faab = tables.Column(verbose_name='FAAB', accessor="waiver_budget_used") - wins = tables.Column(verbose_name='W', attrs={"td": {"class": "wins"}, "th": {"class": "wins"}}) - losses = tables.Column(verbose_name='L', attrs={"td": {"class": "losses"}, "th": {"class": "losses"}}) - ties = tables.Column(verbose_name='T', attrs={"td": {"class": "ties"}, "th": {"class": "ties"}}) - points = tables.Column(verbose_name='Punkte', attrs={"td": {"class": "points"}, "th": {"class": "points"}}) + fields = [ + "ranking", + "playoff_indicator", + "team_manager", + "faab", + "wins", + "losses", + "ties", + "points", + ] + + ranking = tables.Column( + verbose_name="Pl.", + empty_values=(), + orderable=False, + attrs={"td": {"class": "ranking"}, "th": {"class": "ranking"}}, + ) + playoff_indicator = tables.TemplateColumn( + verbose_name="", + template_name="Columns/playoff_indicator.html", + empty_values=(), + attrs={ + "td": {"class": "playoff-indicator"}, + "th": {"class": "playoff-indicator"}, + }, + ) + team_manager = tables.TemplateColumn( + verbose_name="Team Manager", + template_name="Columns/team_manager.html", + empty_values=(), + attrs={"td": {"class": "team-manager"}, "th": {"class": "team-manager"}}, + ) + faab = tables.Column(verbose_name="FAAB", accessor="waiver_budget_used") + wins = tables.Column( + verbose_name="W", attrs={"td": {"class": "wins"}, "th": {"class": "wins"}} + ) + losses = tables.Column( + verbose_name="L", attrs={"td": {"class": "losses"}, "th": {"class": "losses"}} + ) + ties = tables.Column( + verbose_name="T", attrs={"td": {"class": "ties"}, "th": {"class": "ties"}} + ) + points = tables.Column( + verbose_name="Punkte", + attrs={"td": {"class": "points"}, "th": {"class": "points"}}, + ) def render_ranking(self): - self.ranking = getattr(self, 'ranking', itertools.count(start=1+self.ranking_offset)) + self.ranking = getattr( + self, "ranking", itertools.count(start=1 + self.ranking_offset) + ) return next(self.ranking) def render_faab(self, value): - return "{faab}$".format(faab=100-value) + return "{faab}$".format(faab=100 - value) class DraftsADPTable(tables.Table): - def __init__(self, *args, **kwargs): self.pos_ranking_counter = defaultdict(int) super().__init__(*args, **kwargs) @@ -64,145 +111,298 @@ class Meta: empty_text = "Es haben noch keine Drafts stattgefunden" model = PlayerDraftStats orderable = False - fields = ['ranking', 'player', 'pos', 'adp'] - - ranking = tables.Column(verbose_name='Platz', empty_values=(), orderable=False, attrs={"td": {"class": "ranking"}, "th": {"class": "ranking"}}, ) - player = tables.TemplateColumn(verbose_name='Spieler', template_name="Columns/player_stats.html", empty_values=(), attrs={"td": {"class": "player"}, "th": {"class": "player"}}) - pos = tables.Column(verbose_name='Position', accessor="player_position", attrs={"td": {"class": "player_position"}, "th": {"class": "position"}}) - adp = tables.Column(verbose_name='ADP', attrs={"td": {"class": "adp"}, "th": {"class": "adp"}}) - highest_pick = tables.Column(verbose_name='Highest', attrs={"td": {"class": "highest_pick"}, "th": {"class": "highest_pick"}}) - lowest_pick = tables.Column(verbose_name='Lowest', attrs={"td": {"class": "lowest_pick"}, "th": {"class": "lowest_pick"}}) + fields = ["ranking", "player", "pos", "adp"] + + ranking = tables.Column( + verbose_name="Platz", + empty_values=(), + orderable=False, + attrs={"td": {"class": "ranking"}, "th": {"class": "ranking"}}, + ) + player = tables.TemplateColumn( + verbose_name="Spieler", + template_name="Columns/player_stats.html", + empty_values=(), + attrs={"td": {"class": "player"}, "th": {"class": "player"}}, + ) + pos = tables.Column( + verbose_name="Position", + accessor="player_position", + attrs={"td": {"class": "player_position"}, "th": {"class": "position"}}, + ) + adp = tables.Column( + verbose_name="ADP", attrs={"td": {"class": "adp"}, "th": {"class": "adp"}} + ) + highest_pick = tables.Column( + verbose_name="Highest", + attrs={"td": {"class": "highest_pick"}, "th": {"class": "highest_pick"}}, + ) + lowest_pick = tables.Column( + verbose_name="Lowest", + attrs={"td": {"class": "lowest_pick"}, "th": {"class": "lowest_pick"}}, + ) def render_ranking(self): - self.ranking = getattr(self, 'ranking', itertools.count(start=1)) + self.ranking = getattr(self, "ranking", itertools.count(start=1)) return next(self.ranking) def render_adp(self, value): - return '{:0.1f}'.format(value) + return "{:0.1f}".format(value) def render_pos(self, value): self.pos_ranking_counter[value] += 1 - return "{pos} {pos_rank}".format(pos=value, pos_rank=self.pos_ranking_counter[value]) + return "{pos} {pos_rank}".format( + pos=value, pos_rank=self.pos_ranking_counter[value] + ) class PlayerStatsTable(tables.Table): - class Meta: empty_text = "Es gibt noch keine Stats" model = Player orderable = False - fields = ['ranking', 'player', 'pos', 'points', 'avg_points', 'games_played', 'adp'] - - ranking = tables.Column(verbose_name='Platz', empty_values=(), orderable=False, attrs={"td": {"class": "ranking"}, "th": {"class": "ranking"}}, ) - player = tables.TemplateColumn(verbose_name='Spieler', template_name="Columns/player.html", empty_values=(), attrs={"td": {"class": "player"}, "th": {"class": "player"}}) - pos = tables.Column(verbose_name='Position', accessor="position", attrs={"td": {"class": "position"}, "th": {"class": "position"}}) - points = tables.Column(verbose_name='Punkte', accessor="points", attrs={"td": {"class": "points"}, "th": {"class": "points"}}) - avg_points = tables.Column(verbose_name='Ø-Punkte', attrs={"td": {"class": "avg_points"}, "th": {"class": "avg_points"}}) - games_played = tables.Column(verbose_name='#Spiele', attrs={"td": {"class": "games_played"}, "th": {"class": "games_played"}}) - adp = tables.Column(verbose_name='ADP', attrs={"td": {"class": "adp"}, "th": {"class": "adp"}}) + fields = [ + "ranking", + "player", + "pos", + "points", + "avg_points", + "games_played", + "adp", + ] + + ranking = tables.Column( + verbose_name="Platz", + empty_values=(), + orderable=False, + attrs={"td": {"class": "ranking"}, "th": {"class": "ranking"}}, + ) + player = tables.TemplateColumn( + verbose_name="Spieler", + template_name="Columns/player.html", + empty_values=(), + attrs={"td": {"class": "player"}, "th": {"class": "player"}}, + ) + pos = tables.Column( + verbose_name="Position", + accessor="position", + attrs={"td": {"class": "position"}, "th": {"class": "position"}}, + ) + points = tables.Column( + verbose_name="Punkte", + accessor="points", + attrs={"td": {"class": "points"}, "th": {"class": "points"}}, + ) + avg_points = tables.Column( + verbose_name="Ø-Punkte", + attrs={"td": {"class": "avg_points"}, "th": {"class": "avg_points"}}, + ) + games_played = tables.Column( + verbose_name="#Spiele", + attrs={"td": {"class": "games_played"}, "th": {"class": "games_played"}}, + ) + adp = tables.Column( + verbose_name="ADP", attrs={"td": {"class": "adp"}, "th": {"class": "adp"}} + ) def render_ranking(self): - self.ranking = getattr(self, 'ranking', itertools.count(start=1)) + self.ranking = getattr(self, "ranking", itertools.count(start=1)) return next(self.ranking) def render_adp(self, value): - return '{:0.1f}'.format(value) + return "{:0.1f}".format(value) def render_points(self, value): - return '{:0.1f}'.format(value) + return "{:0.1f}".format(value) def render_avg_points(self, value): - return '{:0.1f}'.format(value) + return "{:0.1f}".format(value) class NextDraftsTable(tables.Table): - class Meta: empty_text = "Alle Drafts abgeschlossen" model = Draft orderable = False - fields = ['league', 'date'] - - league = tables.Column(verbose_name='Liga', accessor="league__sleeper_name", attrs={"td": {"class": "league"}, "th": {"class": "league"}}) - date = tables.LinkColumn("draft-board", args=[A("league.sleeper_id")] , text=_get_date, verbose_name='Datum', attrs={"td": {"class": "date"}, "th": {"class": "date"}}) + fields = ["league", "date"] + + league = tables.Column( + verbose_name="Liga", + accessor="league__sleeper_name", + attrs={"td": {"class": "league"}, "th": {"class": "league"}}, + ) + date = tables.LinkColumn( + "draft-board", + args=[A("league.sleeper_id")], + text=_get_date, + verbose_name="Datum", + attrs={"td": {"class": "date"}, "th": {"class": "date"}}, + ) class UpsetAndStealPickTable(tables.Table): - class Meta: empty_text = "Es haben noch nicht ausreichend Drafts stattgefunden" model = Pick orderable = False - fields = ['ranking', 'player', 'pick_no', 'adp', 'picked_by'] - - ranking = tables.Column(verbose_name='Platz', empty_values=(), orderable=False, attrs={"td": {"class": "ranking"}, "th": {"class": "ranking"}}, ) - player = tables.TemplateColumn(verbose_name='Spieler', template_name="Columns/player_pick.html", empty_values=(), attrs={"td": {"class": "player"}, "th": {"class": "player"}}) - pick_no = tables.Column(verbose_name='Picked at', attrs={"td": {"class": "pick_no"}, "th": {"class": "pick_no"}}) - adp = tables.Column(verbose_name='ADP', attrs={"td": {"class": "adp"}, "th": {"class": "adp"}}) - picked_by = tables.TemplateColumn(verbose_name='Team Manager', template_name="Columns/team_manager.html", empty_values=(), attrs={"td": {"class": "team-manager"}, "th": {"class": "team-manager"}}) + fields = ["ranking", "player", "pick_no", "adp", "picked_by"] + + ranking = tables.Column( + verbose_name="Platz", + empty_values=(), + orderable=False, + attrs={"td": {"class": "ranking"}, "th": {"class": "ranking"}}, + ) + player = tables.TemplateColumn( + verbose_name="Spieler", + template_name="Columns/player_pick.html", + empty_values=(), + attrs={"td": {"class": "player"}, "th": {"class": "player"}}, + ) + pick_no = tables.Column( + verbose_name="Picked at", + attrs={"td": {"class": "pick_no"}, "th": {"class": "pick_no"}}, + ) + adp = tables.Column( + verbose_name="ADP", attrs={"td": {"class": "adp"}, "th": {"class": "adp"}} + ) + picked_by = tables.TemplateColumn( + verbose_name="Team Manager", + template_name="Columns/team_manager.html", + empty_values=(), + attrs={"td": {"class": "team-manager"}, "th": {"class": "team-manager"}}, + ) def render_ranking(self): - self.ranking = getattr(self, 'ranking', itertools.count(start=1)) + self.ranking = getattr(self, "ranking", itertools.count(start=1)) return next(self.ranking) def render_adp(self, value): - return '{:0.1f}'.format(value) + return "{:0.1f}".format(value) class WaiverTopBids(tables.Table): - class Meta: empty_text = "Noch kein Waiver Daten vorhanden" model = WaiverPickup orderable = False - fields = ['ranking', 'player', 'bid', 'picked_up_by', 'league'] - - ranking = tables.Column(verbose_name='Platz', empty_values=(), orderable=False, attrs={"td": {"class": "ranking"}, "th": {"class": "ranking"}}, ) - player = tables.TemplateColumn(verbose_name='Spieler', template_name="Columns/player_pick.html", empty_values=(), attrs={"td": {"class": "player"}, "th": {"class": "player"}}) - bid = tables.Column(verbose_name='Bid', empty_values=(), orderable=False, attrs={"td": {"class": "bid"}, "th": {"class": "bid"}}, ) - picked_up_by = tables.TemplateColumn(verbose_name='Team Manager', template_name="Columns/team_manager.html", empty_values=(), attrs={"td": {"class": "team-manager"}, "th": {"class": "team-manager"}}) - league = tables.Column(verbose_name='Liga', accessor="roster__league", attrs={"td": {"class": "league"}, "th": {"class": "league"}}) + fields = ["ranking", "player", "bid", "picked_up_by", "league"] + + ranking = tables.Column( + verbose_name="Platz", + empty_values=(), + orderable=False, + attrs={"td": {"class": "ranking"}, "th": {"class": "ranking"}}, + ) + player = tables.TemplateColumn( + verbose_name="Spieler", + template_name="Columns/player_pick.html", + empty_values=(), + attrs={"td": {"class": "player"}, "th": {"class": "player"}}, + ) + bid = tables.Column( + verbose_name="Bid", + empty_values=(), + orderable=False, + attrs={"td": {"class": "bid"}, "th": {"class": "bid"}}, + ) + picked_up_by = tables.TemplateColumn( + verbose_name="Team Manager", + template_name="Columns/team_manager.html", + empty_values=(), + attrs={"td": {"class": "team-manager"}, "th": {"class": "team-manager"}}, + ) + league = tables.Column( + verbose_name="Liga", + accessor="roster__league", + attrs={"td": {"class": "league"}, "th": {"class": "league"}}, + ) def render_ranking(self): - self.ranking = getattr(self, 'ranking', itertools.count(start=1)) + self.ranking = getattr(self, "ranking", itertools.count(start=1)) return next(self.ranking) def render_bid(self, value): - return '{:0}$'.format(value) + return "{:0}$".format(value) class WaiverTopPlayers(tables.Table): - class Meta: empty_text = "Noch kein Waiver Daten vorhanden" - fields = ['ranking', 'player', 'bid_sum', 'bid_avg', 'bid_sum_success', 'bid_avg_success', 'bid_count', 'leagues'] - - ranking = tables.Column(verbose_name='Platz', empty_values=(), orderable=False, attrs={"td": {"class": "ranking"}, "th": {"class": "ranking"}}, ) - player = tables.TemplateColumn(verbose_name='Spieler', orderable=False, template_name="Columns/player_pick.html", empty_values=(), attrs={"td": {"class": "player"}, "th": {"class": "player"}}) - - bid_sum = tables.Column(verbose_name='Summe $FAAB', empty_values=(), orderable=False, attrs={"td": {"class": "bid_sum"}, "th": {"class": "bid_sum"}}, ) - bid_sum_success = tables.Column(verbose_name='Summe $FAAB (erfolgreich)', empty_values=(), orderable=False, attrs={"td": {"class": "bid_sum"}, "th": {"class": "bid_sum"}}, ) - bid_count = tables.Column(verbose_name='#Bids insgesamt', empty_values=(), orderable=False, attrs={"td": {"class": "bid_count"}, "th": {"class": "bid_count"}}, ) - leagues = tables.Column(verbose_name='#Beteiligte Ligen', empty_values=(), orderable=False, attrs={"td": {"class": "bid_count"}, "th": {"class": "bid_count"}}, ) - bid_avg = tables.Column(verbose_name='Ø $FAAB', empty_values=(), orderable=False, attrs={"td": {"class": "bid_avg"}, "th": {"class": "bid_avg"}}, ) - bid_avg_success = tables.Column(verbose_name='Ø $FAAB (erfolgreich)', empty_values=(), orderable=False, attrs={"td": {"class": "bid_avg"}, "th": {"class": "bid_avg"}}, ) + fields = [ + "ranking", + "player", + "bid_sum", + "bid_avg", + "bid_sum_success", + "bid_avg_success", + "bid_count", + "leagues", + ] + + ranking = tables.Column( + verbose_name="Platz", + empty_values=(), + orderable=False, + attrs={"td": {"class": "ranking"}, "th": {"class": "ranking"}}, + ) + player = tables.TemplateColumn( + verbose_name="Spieler", + orderable=False, + template_name="Columns/player_pick.html", + empty_values=(), + attrs={"td": {"class": "player"}, "th": {"class": "player"}}, + ) + + bid_sum = tables.Column( + verbose_name="Summe $FAAB", + empty_values=(), + orderable=False, + attrs={"td": {"class": "bid_sum"}, "th": {"class": "bid_sum"}}, + ) + bid_sum_success = tables.Column( + verbose_name="Summe $FAAB (erfolgreich)", + empty_values=(), + orderable=False, + attrs={"td": {"class": "bid_sum"}, "th": {"class": "bid_sum"}}, + ) + bid_count = tables.Column( + verbose_name="#Bids insgesamt", + empty_values=(), + orderable=False, + attrs={"td": {"class": "bid_count"}, "th": {"class": "bid_count"}}, + ) + leagues = tables.Column( + verbose_name="#Beteiligte Ligen", + empty_values=(), + orderable=False, + attrs={"td": {"class": "bid_count"}, "th": {"class": "bid_count"}}, + ) + bid_avg = tables.Column( + verbose_name="Ø $FAAB", + empty_values=(), + orderable=False, + attrs={"td": {"class": "bid_avg"}, "th": {"class": "bid_avg"}}, + ) + bid_avg_success = tables.Column( + verbose_name="Ø $FAAB (erfolgreich)", + empty_values=(), + orderable=False, + attrs={"td": {"class": "bid_avg"}, "th": {"class": "bid_avg"}}, + ) def render_ranking(self): - self.ranking = getattr(self, 'ranking', itertools.count(start=1)) + self.ranking = getattr(self, "ranking", itertools.count(start=1)) return next(self.ranking) def render_bid_sum(self, value): - return '{:0}$'.format(value) + return "{:0}$".format(value) def render_bid_sum_success(self, value): - return '{:0}$'.format(value) + return "{:0}$".format(value) def render_bid_avg(self, value): - return '{:0.1f}$'.format(value) + return "{:0.1f}$".format(value) def render_bid_avg_success(self, value): - return '{:0.1f}$'.format(value) - - - - + return "{:0.1f}$".format(value) diff --git a/DSTBundesliga/apps/leagues/templatetags/league_tags.py b/DSTBundesliga/apps/leagues/templatetags/league_tags.py index 7e25035..4fd218d 100644 --- a/DSTBundesliga/apps/leagues/templatetags/league_tags.py +++ b/DSTBundesliga/apps/leagues/templatetags/league_tags.py @@ -13,6 +13,7 @@ def modulo(num, val): def times(number): return range(number) + # settings value @register.simple_tag def settings_value(name): diff --git a/DSTBundesliga/apps/leagues/urls.py b/DSTBundesliga/apps/leagues/urls.py index c9d8a2d..d6c4a5d 100644 --- a/DSTBundesliga/apps/leagues/urls.py +++ b/DSTBundesliga/apps/leagues/urls.py @@ -3,26 +3,36 @@ from DSTBundesliga.apps.leagues import views urlpatterns = [ - path('', views.LeagueView.as_view(), name='league-list'), - path('/', views.roster_list, name='league-detail'), - path('lev//', views.level_detail, name='level-detail'), - path('conf//', views.level_detail, name='conference-overview'), - path('conf//lev//', views.level_detail, name='conference-detail'), - path('conf//lev//reg//', views.level_detail, name='region-detail'), - path('my-league/', views.my_league, name='my-league'), - path('dst-league/', views.listener_league, name='dst-league'), - path('champions-league/', views.champions_league, name='champions-league'), - path('stats/draft/', views.draft_stats, name='draft-stats'), - path('stats/draft//', views.draft_stats, name='draft-stats'), - path('stats/players/', views.player_stats, name='player-stats'), - path('stats/players//', views.player_stats, name='player-stats'), - path('stats/draftboard//', views.draftboard, name='draft-board'), - path('stats/facts_and_figures//', views.facts_and_figures_for_league, name='facts_and_figures_league'), - path('stats/cl_quali/', views.cl_quali, name='cl-quali'), - path('stats/some_quali/', views.some_quali, name='some-quali'), - path('stats/facts_and_figures/', views.facts_and_figures, name='facts_and_figures'), - path('stats/waiver/', views.waiver_stats, name='waiver_stats'), - path('playoffs//', views.playoffs, name='playoffs'), + path("", views.LeagueView.as_view(), name="league-list"), + path("/", views.roster_list, name="league-detail"), + path("lev//", views.level_detail, name="level-detail"), + path("conf//", views.level_detail, name="conference-overview"), + path( + "conf//lev//", + views.level_detail, + name="conference-detail", + ), + path( + "conf//lev//reg//", + views.level_detail, + name="region-detail", + ), + path("my-league/", views.my_league, name="my-league"), + path("dst-league/", views.listener_league, name="dst-league"), + path("champions-league/", views.champions_league, name="champions-league"), + path("stats/draft/", views.draft_stats, name="draft-stats"), + path("stats/draft//", views.draft_stats, name="draft-stats"), + path("stats/players/", views.player_stats, name="player-stats"), + path("stats/players//", views.player_stats, name="player-stats"), + path("stats/draftboard//", views.draftboard, name="draft-board"), + path( + "stats/facts_and_figures//", + views.facts_and_figures_for_league, + name="facts_and_figures_league", + ), + path("stats/cl_quali/", views.cl_quali, name="cl-quali"), + path("stats/some_quali/", views.some_quali, name="some-quali"), + path("stats/facts_and_figures/", views.facts_and_figures, name="facts_and_figures"), + path("stats/waiver/", views.waiver_stats, name="waiver_stats"), + path("playoffs//", views.playoffs, name="playoffs"), ] - - diff --git a/DSTBundesliga/apps/leagues/views.py b/DSTBundesliga/apps/leagues/views.py index 83b18d8..0898e5b 100644 --- a/DSTBundesliga/apps/leagues/views.py +++ b/DSTBundesliga/apps/leagues/views.py @@ -4,22 +4,53 @@ import django_tables2 as tables import pytz from django.core.exceptions import ObjectDoesNotExist -from django.db.models import Avg, ExpressionWrapper, F, IntegerField, Sum, Count, Min, Max, Window, Value, FloatField +from django.db.models import ( + Avg, + ExpressionWrapper, + F, + IntegerField, + Sum, + Count, + Min, + Max, + Window, + Value, + FloatField, +) from django.db.models.functions import RowNumber from django.shortcuts import render from django.urls import reverse from DSTBundesliga.apps.leagues.config import LEVEL_MAP, LOGO_MAP -from DSTBundesliga.apps.leagues.models import League, Roster, Draft, Pick, Player, DSTPlayer, Matchup, \ - PlayoffMatchup, Season, PlayerDraftStats, WaiverPickup -from DSTBundesliga.apps.leagues.tables import LeagueTable, RosterTable, DraftsADPTable, NextDraftsTable, \ - UpsetAndStealPickTable, PlayerStatsTable, WaiverTopBids, WaiverTopPlayers +from DSTBundesliga.apps.leagues.models import ( + League, + Roster, + Draft, + Pick, + Player, + DSTPlayer, + Matchup, + PlayoffMatchup, + Season, + PlayerDraftStats, + WaiverPickup, +) +from DSTBundesliga.apps.leagues.tables import ( + LeagueTable, + RosterTable, + DraftsADPTable, + NextDraftsTable, + UpsetAndStealPickTable, + PlayerStatsTable, + WaiverTopBids, + WaiverTopPlayers, +) from DSTBundesliga.apps.services.awards_service import AwardService class LeagueView(tables.SingleTableView): table_class = LeagueTable - queryset = League.objects.get_active().order_by('level', 'sleeper_name') + queryset = League.objects.get_active().order_by("level", "sleeper_name") template_name = "leagues/league_list.html" @@ -29,14 +60,11 @@ def roster_list(request, league_id): title = league.sleeper_name table = RosterTable(Roster.objects.filter(league=league)) - return render(request, "leagues/roster_list.html", { - "title": title, - "table": table - }) + return render(request, "leagues/roster_list.html", {"title": title, "table": table}) def level_detail(request, level=None, conference=None, region=None, season=None): - league_objects = League.objects.all().order_by('sleeper_id') + league_objects = League.objects.all().order_by("sleeper_id") header_logo = None if season: @@ -55,36 +83,52 @@ def level_detail(request, level=None, conference=None, region=None, season=None) if region: if region == "Sued": - region = 'Süd' + region = "Süd" league_objects = league_objects.filter(region=region) - leagues = [{ - "title": league.sleeper_name, - "table": RosterTable(Roster.objects.filter(league=league)), - "conference": league.conference or "", - "stats_link": reverse('facts_and_figures_league', kwargs={'league_id': league.sleeper_id}), - "playoffs_link": reverse('playoffs', kwargs={'league_id': league.sleeper_id}), - "draft_link": reverse('draft-board', - kwargs={'league_id': league.sleeper_id}) if league.draft.status != 'pre_draft' else None - } for league in league_objects] + leagues = [ + { + "title": league.sleeper_name, + "table": RosterTable(Roster.objects.filter(league=league)), + "conference": league.conference or "", + "stats_link": reverse( + "facts_and_figures_league", kwargs={"league_id": league.sleeper_id} + ), + "playoffs_link": reverse( + "playoffs", kwargs={"league_id": league.sleeper_id} + ), + "draft_link": reverse( + "draft-board", kwargs={"league_id": league.sleeper_id} + ) + if league.draft.status != "pre_draft" + else None, + } + for league in league_objects + ] - return render(request, "leagues/level_detail.html", { - "leagues": leagues, - "header_logo": header_logo - }) + return render( + request, + "leagues/level_detail.html", + {"leagues": leagues, "header_logo": header_logo}, + ) def my_league(request): all_leagues = League.objects.get_active() context = { - "levels": [{ - "title": LEVEL_MAP.get(level), - "leagues": all_leagues.filter(level=level).order_by("sleeper_name") - } for level in all_leagues.order_by("level").values_list("level", flat=True).distinct()] + "levels": [ + { + "title": LEVEL_MAP.get(level), + "leagues": all_leagues.filter(level=level).order_by("sleeper_name"), + } + for level in all_leagues.order_by("level") + .values_list("level", flat=True) + .distinct() + ] } - my_league_id = request.COOKIES.get('my_league') + my_league_id = request.COOKIES.get("my_league") if my_league_id: league = all_leagues.get(sleeper_id=my_league_id) title = league.sleeper_name @@ -97,18 +141,25 @@ def my_league(request): context["table"] = table context["conference"] = league.conference or "" context["header_logo"] = header_logo - context["stats_link"] = reverse('facts_and_figures_league', kwargs={'league_id': league.sleeper_id}) - context["draft_link"] = reverse('draft-board', kwargs={ - 'league_id': league.sleeper_id}) if league.draft.status != 'pre_draft' else None + context["stats_link"] = reverse( + "facts_and_figures_league", kwargs={"league_id": league.sleeper_id} + ) + context["draft_link"] = ( + reverse("draft-board", kwargs={"league_id": league.sleeper_id}) + if league.draft.status != "pre_draft" + else None + ) return render(request, "leagues/my_league.html", context) def draft_stats(request, position=None): - drafts = Draft.objects.filter(league__season__active=True).filter(league__type=League.BUNDESLIGA) + drafts = Draft.objects.filter(league__season__active=True).filter( + league__type=League.BUNDESLIGA + ) - drafts_done = drafts.filter(status='complete').count() - drafts_running = drafts.filter(status__in=['drafting', 'paused']).count() + drafts_done = drafts.filter(status="complete").count() + drafts_running = drafts.filter(status__in=["drafting", "paused"]).count() drafts_overall = League.objects.get_active().filter(type=League.BUNDESLIGA).count() drafts_done_percent = drafts_done / max(drafts_overall, 1) * 100 @@ -120,30 +171,57 @@ def draft_stats(request, position=None): else: player_stats = player_stats.filter(pick_count__gte=drafts_done * 0.5) - adp_table = DraftsADPTable(player_stats.order_by('adp')[:200]) + adp_table = DraftsADPTable(player_stats.order_by("adp")[:200]) next_drafts_table = NextDraftsTable( - drafts.exclude(start_time=None).exclude(start_time__lte=datetime.utcnow().replace(tzinfo=pytz.utc)).exclude( - status__in=['complete', 'drafting', 'paused']).order_by('start_time', 'league__level', - 'league__sleeper_name')[:10]) - - upset_and_value_picks = player_stats.filter(pick_count__gte=drafts_done * 0.8).annotate( - upset_value=ExpressionWrapper(F('adp') - F('highest_pick'), output_field=IntegerField()), - steal_value=ExpressionWrapper(F('lowest_pick') - F('adp'), output_field=IntegerField())) + drafts.exclude(start_time=None) + .exclude(start_time__lte=datetime.utcnow().replace(tzinfo=pytz.utc)) + .exclude(status__in=["complete", "drafting", "paused"]) + .order_by("start_time", "league__level", "league__sleeper_name")[:10] + ) + + upset_and_value_picks = player_stats.filter( + pick_count__gte=drafts_done * 0.8 + ).annotate( + upset_value=ExpressionWrapper( + F("adp") - F("highest_pick"), output_field=IntegerField() + ), + steal_value=ExpressionWrapper( + F("lowest_pick") - F("adp"), output_field=IntegerField() + ), + ) upset_picks = [] - for upset_pick in upset_and_value_picks.order_by('-upset_value'): - pick = picks.filter(player__sleeper_id=upset_pick.player_id, pick_no=upset_pick.highest_pick).annotate( - adp=ExpressionWrapper(Value(float(upset_pick.adp)), output_field=FloatField())).first() + for upset_pick in upset_and_value_picks.order_by("-upset_value"): + pick = ( + picks.filter( + player__sleeper_id=upset_pick.player_id, pick_no=upset_pick.highest_pick + ) + .annotate( + adp=ExpressionWrapper( + Value(float(upset_pick.adp)), output_field=FloatField() + ) + ) + .first() + ) upset_picks.append(pick) if len(upset_picks) >= 5: break steal_picks = [] - for steal_pick in upset_and_value_picks.order_by('-steal_value'): - pick = picks.filter(player__sleeper_id=steal_pick.player_id, pick_no=steal_pick.lowest_pick).annotate( - adp=ExpressionWrapper(Value(float(steal_pick.adp)), output_field=FloatField())).first() + for steal_pick in upset_and_value_picks.order_by("-steal_value"): + pick = ( + picks.filter( + player__sleeper_id=steal_pick.player_id, pick_no=steal_pick.lowest_pick + ) + .annotate( + adp=ExpressionWrapper( + Value(float(steal_pick.adp)), output_field=FloatField() + ) + ) + .first() + ) steal_picks.append(pick) if len(steal_picks) >= 5: @@ -159,21 +237,25 @@ def draft_stats(request, position=None): {"title": "WR", "position": "WR"}, {"title": "TE", "position": "TE"}, {"title": "K", "position": "K"}, - {"title": "DEF", "position": "DEF"} + {"title": "DEF", "position": "DEF"}, ] - return render(request, "stats/draft.html", { - "drafts_done": drafts_done, - "drafts_running": drafts_running, - "drafts_overall": drafts_overall, - "drafts_done_percent": drafts_done_percent, - "adp_table": adp_table, - "positions": positions, - "selected_position": position or "", - "upset_table": upset_table, - "steal_table": steal_table, - "next_drafts_table": next_drafts_table - }) + return render( + request, + "stats/draft.html", + { + "drafts_done": drafts_done, + "drafts_running": drafts_running, + "drafts_overall": drafts_overall, + "drafts_done_percent": drafts_done_percent, + "adp_table": adp_table, + "positions": positions, + "selected_position": position or "", + "upset_table": upset_table, + "steal_table": steal_table, + "next_drafts_table": next_drafts_table, + }, + ) def player_stats(request, position=None): @@ -183,7 +265,10 @@ def player_stats(request, position=None): pos_filter = "where position = '{position}'".format(position=position) players = players.raw( - "select * from (select id, first_name, last_name, position, points, games_played, points/games_played as avg_points from leagues_player as whatever left join (select player_id, sum(points) as points, Sum(Case when stats = '""' then 0 when stats='{}' then 0 else 1 end) as games_played from leagues_statsweek group by player_id) as asdf on id=player_id %s) as player_data left join (select player_id, AVG(pick_no) as adp from leagues_pick group by player_id) as adp_picks on id=player_id order by points desc, adp asc;" % pos_filter) + "select * from (select id, first_name, last_name, position, points, games_played, points/games_played as avg_points from leagues_player as whatever left join (select player_id, sum(points) as points, Sum(Case when stats = '" + "' then 0 when stats='{}' then 0 else 1 end) as games_played from leagues_statsweek group by player_id) as asdf on id=player_id %s) as player_data left join (select player_id, AVG(pick_no) as adp from leagues_pick group by player_id) as adp_picks on id=player_id order by points desc, adp asc;" + % pos_filter + ) player_stats = players[:200] @@ -196,20 +281,24 @@ def player_stats(request, position=None): {"title": "WR", "position": "WR"}, {"title": "TE", "position": "TE"}, {"title": "K", "position": "K"}, - {"title": "DEF", "position": "DEF"} + {"title": "DEF", "position": "DEF"}, ] - return render(request, "stats/player_stats.html", { - "player_stats_table": player_stats_table, - "positions": positions, - "selected_position": position or "" - }) + return render( + request, + "stats/player_stats.html", + { + "player_stats_table": player_stats_table, + "positions": positions, + "selected_position": position or "", + }, + ) def draftboard(request, league_id): draft = Draft.objects.get(league__sleeper_id=league_id) rosters = draft.league.total_rosters - picks = draft.picks.order_by('round', 'draft_slot') + picks = draft.picks.order_by("round", "draft_slot") picks_count = picks.count() fill_picks = [] fill_pick_round = 16 @@ -226,17 +315,24 @@ def draftboard(request, league_id): owners = DSTPlayer.objects.filter(sleeper_id__in=draft.draft_order.keys()) - draft_order = sorted([(draft.draft_order.get(owner.sleeper_id), owner) for owner in owners], key=lambda do: do[0]) - - return render(request, "stats/draftboard.html", { - "pick_width": "{:.2f}% !important".format(100 / rosters), - "draft": draft, - "draft_order": draft_order, - "picks": picks, - "fill_picks": fill_picks, - "fill_pick_pos": fill_pick_pos, - "fill_picks_at_front": fill_picks_at_front - }) + draft_order = sorted( + [(draft.draft_order.get(owner.sleeper_id), owner) for owner in owners], + key=lambda do: do[0], + ) + + return render( + request, + "stats/draftboard.html", + { + "pick_width": "{:.2f}% !important".format(100 / rosters), + "draft": draft, + "draft_order": draft_order, + "picks": picks, + "fill_picks": fill_picks, + "fill_pick_pos": fill_pick_pos, + "fill_picks_at_front": fill_picks_at_front, + }, + ) def playoffs(request, league_id): @@ -244,26 +340,41 @@ def playoffs(request, league_id): playoff_matchups = PlayoffMatchup.objects.filter(league_id=league_id) bracket_names = ["Playoffs", "Toilet Bowl"] - brackets = [{ - "bracket": bracket, - "rounds": [ - { - "round": round, - "matchups": [ - { - "roster_one": league.rosters.get( - roster_id=matchup.roster_id_one) if matchup.roster_id_one else None, - "roster_two": league.rosters.get( - roster_id=matchup.roster_id_two) if matchup.roster_id_two else None - } for matchup in playoff_matchups.filter(round=round, bracket=bracket)] - } for round in sorted(playoff_matchups.filter(bracket=bracket).values_list('round', flat=True).distinct()) - ] - } for bracket in bracket_names] + brackets = [ + { + "bracket": bracket, + "rounds": [ + { + "round": round, + "matchups": [ + { + "roster_one": league.rosters.get( + roster_id=matchup.roster_id_one + ) + if matchup.roster_id_one + else None, + "roster_two": league.rosters.get( + roster_id=matchup.roster_id_two + ) + if matchup.roster_id_two + else None, + } + for matchup in playoff_matchups.filter( + round=round, bracket=bracket + ) + ], + } + for round in sorted( + playoff_matchups.filter(bracket=bracket) + .values_list("round", flat=True) + .distinct() + ) + ], + } + for bracket in bracket_names + ] - context = { - "league": league, - "brackets": brackets - } + context = {"league": league, "brackets": brackets} return render(request, "leagues/playoffs.html", context) @@ -277,8 +388,11 @@ def listener_league(request): try: league = League.objects.get(type=League.LISTENER, season=Season.get_active()) - context["draft_link"] = reverse('draft-board', kwargs={ - 'league_id': league.sleeper_id}) if league.draft.status != 'pre_draft' else None + context["draft_link"] = ( + reverse("draft-board", kwargs={"league_id": league.sleeper_id}) + if league.draft.status != "pre_draft" + else None + ) except ObjectDoesNotExist: pass @@ -297,8 +411,11 @@ def champions_league(request): try: league = League.objects.get(type=League.CL, season=Season.get_active()) - context["draft_link"] = reverse('draft-board', kwargs={ - 'league_id': league.sleeper_id}) if league.draft.status != 'pre_draft' else None + context["draft_link"] = ( + reverse("draft-board", kwargs={"league_id": league.sleeper_id}) + if league.draft.status != "pre_draft" + else None + ) except ObjectDoesNotExist: pass @@ -310,8 +427,9 @@ def champions_league(request): def cl_quali(request): context = {} - cl_quali_rosters = Roster.objects.filter(league__season=Season.get_active(), - league__type=League.BUNDESLIGA).order_by("-fpts", "-fpts_decimal") + cl_quali_rosters = Roster.objects.filter( + league__season=Season.get_active(), league__type=League.BUNDESLIGA + ).order_by("-fpts", "-fpts_decimal") top12_rosters = cl_quali_rosters[:12] in_the_hunt_rosters = cl_quali_rosters[12:100] @@ -323,22 +441,53 @@ def cl_quali(request): def some_quali(request): - ranked_rosters_qs = Roster.objects.annotate(rank=Window(expression=RowNumber(), partition_by=[F('league_id')], - order_by=[F('wins').desc(), F('ties').desc(), - F('fpts').desc(), F('fpts_decimal').desc()])) + ranked_rosters_qs = Roster.objects.annotate( + rank=Window( + expression=RowNumber(), + partition_by=[F("league_id")], + order_by=[ + F("wins").desc(), + F("ties").desc(), + F("fpts").desc(), + F("fpts_decimal").desc(), + ], + ) + ) rank_two_rosters = [roster for roster in ranked_rosters_qs if roster.rank == 2] rank_three_rosters = [roster for roster in ranked_rosters_qs if roster.rank == 3] - rank_two_rosters = Roster.objects.annotate(rank=Window(expression=RowNumber(), partition_by=[F('league_id')], - order_by=[F('wins').desc(), F('ties').desc(), - F('fpts').desc(), - F('fpts_decimal').desc()])).filter( - rank=2).order_by('-fpts', '-fpts_decimal') - rank_three_rosters = Roster.objects.annotate(rank=Window(expression=RowNumber(), partition_by=[F('league_id')], - order_by=[F('wins').desc(), F('ties').desc(), - F('fpts').desc(), - F('fpts_decimal').desc()])).filter( - rank=3).order_by('-fpts', '-fpts_decimal') + rank_two_rosters = ( + Roster.objects.annotate( + rank=Window( + expression=RowNumber(), + partition_by=[F("league_id")], + order_by=[ + F("wins").desc(), + F("ties").desc(), + F("fpts").desc(), + F("fpts_decimal").desc(), + ], + ) + ) + .filter(rank=2) + .order_by("-fpts", "-fpts_decimal") + ) + rank_three_rosters = ( + Roster.objects.annotate( + rank=Window( + expression=RowNumber(), + partition_by=[F("league_id")], + order_by=[ + F("wins").desc(), + F("ties").desc(), + F("fpts").desc(), + F("fpts_decimal").desc(), + ], + ) + ) + .filter(rank=3) + .order_by("-fpts", "-fpts_decimal") + ) # rank_two_rosters = Roster.objects.raw("select * from (select *, row_number() over (partition by league_id order by wins desc, ties asc, fpts desc, fpts_decimal desc) as rank from leagues_roster) where rank=2 order by fpts desc, fpts_decimal desc;") # rank_three_rosters = Roster.objects.raw("select * from (select *, row_number() over (partition by league_id order by wins desc, ties asc, fpts desc, fpts_decimal desc) as rank from leagues_roster) where rank=3 order by fpts desc, ftps_decimal desc;") @@ -347,77 +496,107 @@ def some_quali(request): context = { "top8_rank_two_roster_table": top8_rank_two_roster_table, - "top8_rank_three_roster_table": top8_rank_three_roster_table + "top8_rank_three_roster_table": top8_rank_three_roster_table, } return render(request, "leagues/some_quali.html", context) def facts_and_figures(request): - week = Matchup.objects.filter(season=Season.get_active(), - league_id__in=League.objects.filter(type=League.BUNDESLIGA).values_list( - 'sleeper_id')).aggregate(Max('week')).get('week__max') + week = ( + Matchup.objects.filter( + season=Season.get_active(), + league_id__in=League.objects.filter(type=League.BUNDESLIGA).values_list( + "sleeper_id" + ), + ) + .aggregate(Max("week")) + .get("week__max") + ) awards_service = AwardService(request, week) stat_service = StatService(week) stats = stat_service.get_all() awards = awards_service.get_all() - return render(request, "stats/facts_and_figures.html", { - "current_week": week, - "stats": stats, - "awards": awards - }) + return render( + request, + "stats/facts_and_figures.html", + {"current_week": week, "stats": stats, "awards": awards}, + ) def facts_and_figures_for_league(request, league_id, week=None): if not week: - week = Matchup.objects.filter(season=Season.get_active(), - league_id__in=League.objects.filter(type=League.BUNDESLIGA).values_list( - 'sleeper_id')).aggregate(Max('week')).get('week__max') + week = ( + Matchup.objects.filter( + season=Season.get_active(), + league_id__in=League.objects.filter(type=League.BUNDESLIGA).values_list( + "sleeper_id" + ), + ) + .aggregate(Max("week")) + .get("week__max") + ) awards_service = AwardService(request, week, league_id) stat_service = StatService(week, league_id) stats = stat_service.get_all_for_league() awards = [award for award in awards_service.get_all_for_league() if award] league = League.objects.get(sleeper_id=league_id) - return render(request, "stats/facts_and_figures.html", { - "current_week": week, - "stats": stats, - "awards": awards, - "league_name": league.sleeper_name - }) + return render( + request, + "stats/facts_and_figures.html", + { + "current_week": week, + "stats": stats, + "awards": awards, + "league_name": league.sleeper_name, + }, + ) def waiver_stats(request): - waivers = WaiverPickup.objects.filter(season=Season.get_active(), - changed_ts__gte=datetime.now() - timedelta(days=7)) - - waivers_for_sum = waivers.values('player').annotate(sum=Sum('bid'), count=Count('player'), avg=Avg('bid'), - leagues=Count('roster__league', distinct=True)).order_by( - '-sum')[:20] - players = Player.objects.filter(id__in=[w.get('player') for w in waivers_for_sum]) - - waivers = waivers.filter(status='complete').order_by('-bid') - waivers_for_sum_success = waivers.values('player').annotate(sum=Sum('bid'), count=Count('player'), avg=Avg('bid')) + waivers = WaiverPickup.objects.filter( + season=Season.get_active(), changed_ts__gte=datetime.now() - timedelta(days=7) + ) + + waivers_for_sum = ( + waivers.values("player") + .annotate( + sum=Sum("bid"), + count=Count("player"), + avg=Avg("bid"), + leagues=Count("roster__league", distinct=True), + ) + .order_by("-sum")[:20] + ) + players = Player.objects.filter(id__in=[w.get("player") for w in waivers_for_sum]) + + waivers = waivers.filter(status="complete").order_by("-bid") + waivers_for_sum_success = waivers.values("player").annotate( + sum=Sum("bid"), count=Count("player"), avg=Avg("bid") + ) waiver_sums = [] for w in waivers_for_sum: - player = players.get(id=w.get('player')) + player = players.get(id=w.get("player")) try: pickup = waivers_for_sum_success.get(player=player.id) except WaiverPickup.DoesNotExist: pickup = {} - waiver_sums.append({ - 'player': player, - 'bid_sum': w.get('sum'), - 'bid_count': w.get('count'), - 'bid_avg': w.get('avg'), - 'bid_sum_success': pickup.get('sum', 0), - 'leagues': w.get('leagues'), - 'bid_count_success': pickup.get('count', 0), - 'bid_avg_success': pickup.get('avg', 0) - }) + waiver_sums.append( + { + "player": player, + "bid_sum": w.get("sum"), + "bid_count": w.get("count"), + "bid_avg": w.get("avg"), + "bid_sum_success": pickup.get("sum", 0), + "leagues": w.get("leagues"), + "bid_count_success": pickup.get("count", 0), + "bid_avg_success": pickup.get("avg", 0), + } + ) top20_players_table = WaiverTopPlayers(waiver_sums) top20_bids_table = WaiverTopBids(waivers[:20]) @@ -429,33 +608,38 @@ def waiver_stats(request): return render(request, "stats/waiver.html", context) -class StatService(): +class StatService: def __init__(self, week=None, league_id=None): - matchups = Matchup.objects.filter(season=Season.get_active(), - league_id__in=League.objects.filter(type=League.BUNDESLIGA).values_list( - 'sleeper_id')) + matchups = Matchup.objects.filter( + season=Season.get_active(), + league_id__in=League.objects.filter(type=League.BUNDESLIGA).values_list( + "sleeper_id" + ), + ) if week: matchups = matchups.filter(week=week) self.matchups = matchups self.league_id = league_id - self.rosters = Roster.objects.filter(league__season=Season.get_active(), league__type=League.BUNDESLIGA) + self.rosters = Roster.objects.filter( + league__season=Season.get_active(), league__type=League.BUNDESLIGA + ) def get_all_for_league(self): return [ - {'title': 'Liga Rang', 'value': self.league_ranking()}, - {'title': 'Ø-Punkte/Matchup (Liga)', 'value': self.avg_points_league()}, - {'title': 'Ø-Punkte/Matchup (DST)', 'value': self.avg_points()}, - {'title': 'Ø-FAAB/Spieler', 'value': self.avg_faab()}, - {'title': 'Median', 'value': self.median_points()}, + {"title": "Liga Rang", "value": self.league_ranking()}, + {"title": "Ø-Punkte/Matchup (Liga)", "value": self.avg_points_league()}, + {"title": "Ø-Punkte/Matchup (DST)", "value": self.avg_points()}, + {"title": "Ø-FAAB/Spieler", "value": self.avg_faab()}, + {"title": "Median", "value": self.median_points()}, ] def get_all(self): if len(self.matchups) > 0: return [ - {'title': 'Ø-Punkte/Matchup', 'value': self.avg_points()}, - {'title': 'Ø-FAAB/Spieler', 'value': self.avg_faab()}, + {"title": "Ø-Punkte/Matchup", "value": self.avg_points()}, + {"title": "Ø-FAAB/Spieler", "value": self.avg_faab()}, ] else: return [] @@ -464,24 +648,37 @@ def avg_faab(self): rosters = self.rosters if self.league_id: rosters = rosters.filter(league__sleeper_id=self.league_id) - avg_faab_used = rosters.aggregate(avg_faab_used=Avg('waiver_budget_used')).get('avg_faab_used') or 0 - return "{faab}$".format(faab=int( - 100 - avg_faab_used)) + avg_faab_used = ( + rosters.aggregate(avg_faab_used=Avg("waiver_budget_used")).get( + "avg_faab_used" + ) + or 0 + ) + return "{faab}$".format(faab=int(100 - avg_faab_used)) def avg_points_league(self): matchups = self.matchups.filter(league_id=self.league_id) rosters = self.rosters.filter(league__sleeper_id=self.league_id) - sum_points = matchups.aggregate(sum_points=Sum('points_one') + Sum('points_two')).get('sum_points') + sum_points = matchups.aggregate( + sum_points=Sum("points_one") + Sum("points_two") + ).get("sum_points") return "{:.2f}".format(sum_points / rosters.count()) def avg_points(self): - sum_points = self.matchups.aggregate(sum_points=Sum('points_one') + Sum('points_two')).get('sum_points') + sum_points = self.matchups.aggregate( + sum_points=Sum("points_one") + Sum("points_two") + ).get("sum_points") return "{:.2f}".format(sum_points / self.rosters.count()) def league_ranking(self): - leagues = self.matchups.values('league_id').annotate(sum_points=Sum('points_one') + Sum('points_two')).order_by( - '-sum_points') - ranking = list(leagues.values_list('league_id', flat=True)).index(self.league_id) + 1 + leagues = ( + self.matchups.values("league_id") + .annotate(sum_points=Sum("points_one") + Sum("points_two")) + .order_by("-sum_points") + ) + ranking = ( + list(leagues.values_list("league_id", flat=True)).index(self.league_id) + 1 + ) return "#{}".format(ranking) @@ -489,7 +686,10 @@ def median_loosing_points(self): matchups = self.matchups if self.league_id: matchups = matchups.filter(league_id=self.league_id) - losing_values = [mu.points_one if mu.points_one < mu.points_two else mu.points_two for mu in matchups] + losing_values = [ + mu.points_one if mu.points_one < mu.points_two else mu.points_two + for mu in matchups + ] return "{:.2f}".format(self._median(losing_values)) @@ -508,4 +708,4 @@ def _median(self, data): if count % 2 == 1: return values[int(round(count / 2))] else: - return sum(values[int(count / 2 - 1):int(count / 2 + 1)]) / Decimal(2.0) + return sum(values[int(count / 2 - 1) : int(count / 2 + 1)]) / Decimal(2.0) diff --git a/DSTBundesliga/apps/services/awards_service.py b/DSTBundesliga/apps/services/awards_service.py index 421be75..b308e9f 100644 --- a/DSTBundesliga/apps/services/awards_service.py +++ b/DSTBundesliga/apps/services/awards_service.py @@ -5,13 +5,28 @@ from django.db.models.functions import Abs from django.template.loader import render_to_string -from DSTBundesliga.apps.leagues.models import Matchup, Roster, League, Season, WaiverPickup, Player +from DSTBundesliga.apps.leagues.models import ( + Matchup, + Roster, + League, + Season, + WaiverPickup, + Player, +) -class AwardService(): +class AwardService: def __init__(self, request, week=None, league_id=None): - matchups = Matchup.objects.filter(season=Season.get_active(), league_id__in=League.objects.filter(type=League.BUNDESLIGA).values_list('sleeper_id')) - waivers = WaiverPickup.objects.filter(season=Season.get_active(), changed_ts__gte=datetime.now()-timedelta(days=7)) + matchups = Matchup.objects.filter( + season=Season.get_active(), + league_id__in=League.objects.filter(type=League.BUNDESLIGA).values_list( + "sleeper_id" + ), + ) + waivers = WaiverPickup.objects.filter( + season=Season.get_active(), + changed_ts__gte=datetime.now() - timedelta(days=7), + ) if week: matchups = matchups.filter(week=week) @@ -23,8 +38,12 @@ def __init__(self, request, week=None, league_id=None): self.league_id = league_id self.week = week self.matchups = matchups - self.narrow_matchups = matchups.annotate(point_difference=Abs(F('points_one') - F('points_two'))) - self.rosters = Roster.objects.filter(league__season=Season.get_active(), league__type=League.BUNDESLIGA) + self.narrow_matchups = matchups.annotate( + point_difference=Abs(F("points_one") - F("points_two")) + ) + self.rosters = Roster.objects.filter( + league__season=Season.get_active(), league__type=League.BUNDESLIGA + ) self.waivers = waivers self.request = request @@ -33,225 +52,283 @@ def get_all(self): awards = [] if self.matchups.count() > 0: - awards.extend([ - self.get_highscorer(), - self.get_lowscorer(), - self.get_blowout_victory(), - self.get_narrow_victory(), - self.get_shootout(), - self.get_buli_leader(), - self.get_cffc_vs_affc(), - self.get_cffc_leader(), - self.get_affc_leader() - ]) - - if self.waivers.count() > 0: awards.extend( [ - self.get_most_wanted_waiver(), - self.get_highest_bid_waiver() + self.get_highscorer(), + self.get_lowscorer(), + self.get_blowout_victory(), + self.get_narrow_victory(), + self.get_shootout(), + self.get_buli_leader(), + self.get_cffc_vs_affc(), + self.get_cffc_leader(), + self.get_affc_leader(), ] ) + if self.waivers.count() > 0: + awards.extend( + [self.get_most_wanted_waiver(), self.get_highest_bid_waiver()] + ) + return awards def get_all_for_league(self): awards = [] if self.matchups.count() > 0: - awards.extend([ - self.get_highscorer(), - self.get_lowscorer(), - self.get_blowout_victory(), - self.get_narrow_victory(), - self.get_shootout(), - ]) - - if self.waivers.count() > 0: awards.extend( [ - self.get_most_wanted_waiver(), - self.get_highest_bid_waiver() + self.get_highscorer(), + self.get_lowscorer(), + self.get_blowout_victory(), + self.get_narrow_victory(), + self.get_shootout(), ] ) + if self.waivers.count() > 0: + awards.extend( + [self.get_most_wanted_waiver(), self.get_highest_bid_waiver()] + ) + return awards def get_random(self, count=99): return random.sample(self.get_all(), count) def get_highscorer(self): - mpo = self.matchups.order_by('-points_one').first() - mpt = self.matchups.order_by('-points_two').first() + mpo = self.matchups.order_by("-points_one").first() + mpt = self.matchups.order_by("-points_two").first() if mpo.points_one >= mpt.points_two: most_points_score = mpo.points_one - most_points_roster = self.rosters.get(league__sleeper_id=mpo.league_id, roster_id=mpo.roster_id_one) + most_points_roster = self.rosters.get( + league__sleeper_id=mpo.league_id, roster_id=mpo.roster_id_one + ) else: most_points_score = mpt.points_two - most_points_roster = self.rosters.get(league__sleeper_id=mpt.league_id, roster_id=mpt.roster_id_two) + most_points_roster = self.rosters.get( + league__sleeper_id=mpt.league_id, roster_id=mpt.roster_id_two + ) context = { - 'roster': most_points_roster, - 'league': most_points_roster.league, - 'score': most_points_score + "roster": most_points_roster, + "league": most_points_roster.league, + "score": most_points_score, } return HighscorerAward(self.request, context) def get_lowscorer(self): - mpo = self.matchups.order_by('points_one').first() - mpt = self.matchups.order_by('points_two').first() + mpo = self.matchups.order_by("points_one").first() + mpt = self.matchups.order_by("points_two").first() if mpo.points_one <= mpt.points_two: least_points_score = mpo.points_one - least_points_roster = self.rosters.get(league__sleeper_id=mpo.league_id, roster_id=mpo.roster_id_one) + least_points_roster = self.rosters.get( + league__sleeper_id=mpo.league_id, roster_id=mpo.roster_id_one + ) else: least_points_score = mpt.points_two - least_points_roster = self.rosters.get(league__sleeper_id=mpt.league_id, roster_id=mpt.roster_id_two) + least_points_roster = self.rosters.get( + league__sleeper_id=mpt.league_id, roster_id=mpt.roster_id_two + ) context = { - 'roster': least_points_roster, - 'league': least_points_roster.league, - 'score': least_points_score + "roster": least_points_roster, + "league": least_points_roster.league, + "score": least_points_score, } return LowscorerAward(self.request, context) def get_narrow_victory(self): - head_to_head = self.narrow_matchups.order_by('point_difference').first() - roster_one = self.rosters.get(league__sleeper_id=head_to_head.league_id, roster_id=head_to_head.roster_id_one) - roster_two = self.rosters.get(league__sleeper_id=head_to_head.league_id, roster_id=head_to_head.roster_id_two) + head_to_head = self.narrow_matchups.order_by("point_difference").first() + roster_one = self.rosters.get( + league__sleeper_id=head_to_head.league_id, + roster_id=head_to_head.roster_id_one, + ) + roster_two = self.rosters.get( + league__sleeper_id=head_to_head.league_id, + roster_id=head_to_head.roster_id_two, + ) context = { - 'roster_one': roster_one, - 'roster_two': roster_two, - 'score_one': head_to_head.points_one, - 'score_two': head_to_head.points_two, - 'league': roster_one.league + "roster_one": roster_one, + "roster_two": roster_two, + "score_one": head_to_head.points_one, + "score_two": head_to_head.points_two, + "league": roster_one.league, } return RaceAward(self.request, context) def get_blowout_victory(self): - blowout = self.narrow_matchups.order_by('-point_difference').first() - roster_one = self.rosters.get(league__sleeper_id=blowout.league_id, roster_id=blowout.roster_id_one) - roster_two = self.rosters.get(league__sleeper_id=blowout.league_id, roster_id=blowout.roster_id_two) + blowout = self.narrow_matchups.order_by("-point_difference").first() + roster_one = self.rosters.get( + league__sleeper_id=blowout.league_id, roster_id=blowout.roster_id_one + ) + roster_two = self.rosters.get( + league__sleeper_id=blowout.league_id, roster_id=blowout.roster_id_two + ) context = { - 'roster_one': roster_one, - 'roster_two': roster_two, - 'score_one': blowout.points_one, - 'score_two': blowout.points_two, - 'league': roster_one.league + "roster_one": roster_one, + "roster_two": roster_two, + "score_one": blowout.points_one, + "score_two": blowout.points_two, + "league": roster_one.league, } return BlowoutAward(self.request, context) def get_shootout(self): - shootout = self.narrow_matchups.filter(point_difference__lte=10).annotate( - points_sum=F('points_one') + F('points_two')).order_by('-points_sum').first() + shootout = ( + self.narrow_matchups.filter(point_difference__lte=10) + .annotate(points_sum=F("points_one") + F("points_two")) + .order_by("-points_sum") + .first() + ) if not shootout: - shootout = self.narrow_matchups.filter(point_difference__lte=20).annotate( - points_sum=F('points_one') + F('points_two')).order_by('-points_sum').first() + shootout = ( + self.narrow_matchups.filter(point_difference__lte=20) + .annotate(points_sum=F("points_one") + F("points_two")) + .order_by("-points_sum") + .first() + ) if not shootout: - shootout = self.narrow_matchups.annotate(points_sum=F('points_one') + F('points_two')).order_by( - '-points_sum').first() + shootout = ( + self.narrow_matchups.annotate( + points_sum=F("points_one") + F("points_two") + ) + .order_by("-points_sum") + .first() + ) - roster_one = self.rosters.get(league__sleeper_id=shootout.league_id, roster_id=shootout.roster_id_one) - roster_two = self.rosters.get(league__sleeper_id=shootout.league_id, roster_id=shootout.roster_id_two) + roster_one = self.rosters.get( + league__sleeper_id=shootout.league_id, roster_id=shootout.roster_id_one + ) + roster_two = self.rosters.get( + league__sleeper_id=shootout.league_id, roster_id=shootout.roster_id_two + ) context = { - 'roster_one': roster_one, - 'roster_two': roster_two, - 'score_one': shootout.points_one, - 'score_two': shootout.points_two, - 'league': roster_one.league + "roster_one": roster_one, + "roster_two": roster_two, + "score_one": shootout.points_one, + "score_two": shootout.points_two, + "league": roster_one.league, } return ShootoutAward(self.request, context) def get_cffc_vs_affc(self): - cffc_league_ids = League.objects.get_active().filter(conference="CFFC").values_list('sleeper_id', flat=True) - affc_league_ids = League.objects.get_active().filter(conference="AFFC").values_list('sleeper_id', flat=True) - - points_cffc = self.matchups.filter(league_id__in=cffc_league_ids).aggregate( - point_sum=Sum('points_one') + Sum('points_two')).get("point_sum") - points_affc = self.matchups.filter(league_id__in=affc_league_ids).aggregate( - point_sum=Sum('points_one') + Sum('points_two')).get("point_sum") + cffc_league_ids = ( + League.objects.get_active() + .filter(conference="CFFC") + .values_list("sleeper_id", flat=True) + ) + affc_league_ids = ( + League.objects.get_active() + .filter(conference="AFFC") + .values_list("sleeper_id", flat=True) + ) + + points_cffc = ( + self.matchups.filter(league_id__in=cffc_league_ids) + .aggregate(point_sum=Sum("points_one") + Sum("points_two")) + .get("point_sum") + ) + points_affc = ( + self.matchups.filter(league_id__in=affc_league_ids) + .aggregate(point_sum=Sum("points_one") + Sum("points_two")) + .get("point_sum") + ) context = { - 'name_one': 'AFFC', - 'name_two': 'CFFC', - 'score_one': points_affc, - 'score_two': points_cffc + "name_one": "AFFC", + "name_two": "CFFC", + "score_one": points_affc, + "score_two": points_cffc, } return CFFCvsAFFCAward(self.request, context) def get_buli_leader(self): - leader = Roster.objects.filter(league__season=Season.get_active(), league__level=1).first() + leader = Roster.objects.filter( + league__season=Season.get_active(), league__level=1 + ).first() context = { - 'roster': leader, - 'league': leader.league, - 'score': float(leader.points) + "roster": leader, + "league": leader.league, + "score": float(leader.points), } return BuliLeader(self.request, context) def get_cffc_leader(self): - leader = Roster.objects.filter(league__season=Season.get_active(), league__conference='CFFC').first() + leader = Roster.objects.filter( + league__season=Season.get_active(), league__conference="CFFC" + ).first() if not leader: return None context = { - 'roster': leader, - 'league': leader.league, - 'score': float(leader.points) + "roster": leader, + "league": leader.league, + "score": float(leader.points), } return CFFCLeader(self.request, context) def get_affc_leader(self): - leader = Roster.objects.filter(league__season=Season.get_active(), league__conference='AFFC').first() + leader = Roster.objects.filter( + league__season=Season.get_active(), league__conference="AFFC" + ).first() if not leader: return None context = { - 'roster': leader, - 'league': leader.league, - 'score': float(leader.points) + "roster": leader, + "league": leader.league, + "score": float(leader.points), } return AFFCLeader(self.request, context) def get_most_wanted_waiver(self): - waiver_pickup = self.waivers.values('player').annotate(target_count=Count('player')).order_by('-target_count').first() + waiver_pickup = ( + self.waivers.values("player") + .annotate(target_count=Count("player")) + .order_by("-target_count") + .first() + ) player = Player.objects.get(id=waiver_pickup.get("player")) context = { - 'player': player, - 'bid': "{bids} bids".format(bids=waiver_pickup.get("target_count")) + "player": player, + "bid": "{bids} bids".format(bids=waiver_pickup.get("target_count")), } return WaiverMostWanted(self.request, context) def get_highest_bid_waiver(self): - waiver_pickup = self.waivers.filter(status='complete').order_by('-bid').first() + waiver_pickup = self.waivers.filter(status="complete").order_by("-bid").first() context = { - 'player': waiver_pickup.player, - 'bid': "{bid}$".format(bid=waiver_pickup.bid) + "player": waiver_pickup.player, + "bid": "{bid}$".format(bid=waiver_pickup.bid), } return WaiverMostSpent(self.request, context) -class Award(): +class Award: template_name = "" must_be_first = False @@ -260,10 +337,7 @@ def __init__(self, request, context, title=None, icon=None): self.request = request - context.update({ - "title": title, - "icon": icon - }) + context.update({"title": title, "icon": icon}) self.context = context @@ -271,7 +345,9 @@ def __str__(self): return self.render(self.context) def render(self, context): - return render_to_string(self.template_name, context=context, request=self.request) + return render_to_string( + self.template_name, context=context, request=self.request + ) class HighscorerAward(Award): diff --git a/DSTBundesliga/apps/services/data_services.py b/DSTBundesliga/apps/services/data_services.py index 131f2cf..811a6ed 100644 --- a/DSTBundesliga/apps/services/data_services.py +++ b/DSTBundesliga/apps/services/data_services.py @@ -10,8 +10,21 @@ from sleeper_wrapper import BaseApi from DSTBundesliga.apps.leagues.config import POSITIONS -from DSTBundesliga.apps.leagues.models import League, DSTPlayer, Roster, Draft, Pick, Player, Team, Matchup, StatsWeek, \ - PlayoffMatchup, Season, PlayerDraftStats, WaiverPickup +from DSTBundesliga.apps.leagues.models import ( + League, + DSTPlayer, + Roster, + Draft, + Pick, + Player, + Team, + Matchup, + StatsWeek, + PlayoffMatchup, + Season, + PlayerDraftStats, + WaiverPickup, +) from DSTBundesliga.apps.services.state_service import StateService @@ -31,23 +44,26 @@ def get_league_data(league_id): def update_or_create_league(league_setting: LeagueSetting, league_data): - league, _ = League.objects.update_or_create(sleeper_id=league_setting.id, defaults={ - "total_rosters": league_data.get("total_rosters"), - "status": league_data.get("status"), - "sport": league_data.get("sport"), - "settings": league_data.get("settings"), - "season_type": league_data.get("season_type"), - "scoring_settings": league_data.get("scoring_settings"), - "roster_positions": league_data.get("roster_positions"), - "previous_league_id": league_data.get("previous_league_id"), - "sleeper_name": league_data.get("name"), - "draft_id": league_data.get("draft_id"), - "avatar_id": league_data.get("avatar"), - "type": league_setting.type or League.BUNDESLIGA, - "level": league_setting.level, - "conference": league_setting.conference, - "region": league_setting.region - }) + league, _ = League.objects.update_or_create( + sleeper_id=league_setting.id, + defaults={ + "total_rosters": league_data.get("total_rosters"), + "status": league_data.get("status"), + "sport": league_data.get("sport"), + "settings": league_data.get("settings"), + "season_type": league_data.get("season_type"), + "scoring_settings": league_data.get("scoring_settings"), + "roster_positions": league_data.get("roster_positions"), + "previous_league_id": league_data.get("previous_league_id"), + "sleeper_name": league_data.get("name"), + "draft_id": league_data.get("draft_id"), + "avatar_id": league_data.get("avatar"), + "type": league_setting.type or League.BUNDESLIGA, + "level": league_setting.level, + "conference": league_setting.conference, + "region": league_setting.region, + }, + ) return league @@ -70,7 +86,9 @@ def update_league(league: League, league_data): def delete_old_leagues(league_settings: List[LeagueSetting], dry_run=True): - leagues_to_delete = League.objects.exclude(sleeper_id__in=[l.id for l in league_settings]) + leagues_to_delete = League.objects.exclude( + sleeper_id__in=[l.id for l in league_settings] + ) if dry_run: print("DRY RUN - Would delete the following Leagues:") for league in leagues_to_delete: @@ -83,19 +101,24 @@ def delete_old_leagues(league_settings: List[LeagueSetting], dry_run=True): def delete_old_drafts(league_id, draft_id): if draft_id: - drafts_to_delete = Draft.objects.filter(league__sleeper_id=league_id).exclude(draft_id=draft_id) + drafts_to_delete = Draft.objects.filter(league__sleeper_id=league_id).exclude( + draft_id=draft_id + ) if drafts_to_delete.count() > 0: - print('Deleting old drafts for league %s' % league_id) + print("Deleting old drafts for league %s" % league_id) for draft in drafts_to_delete: print(draft.id, draft.start_time) drafts_to_delete.delete() def update_or_create_dst_player(league_id, player_data): - player, _ = DSTPlayer.objects.update_or_create(sleeper_id=player_data.get("user_id"), defaults={ - "display_name": player_data.get("display_name"), - "avatar_id": player_data.get("avatar") - }) + player, _ = DSTPlayer.objects.update_or_create( + sleeper_id=player_data.get("user_id"), + defaults={ + "display_name": player_data.get("display_name"), + "avatar_id": player_data.get("avatar"), + }, + ) league = League.objects.get(sleeper_id=league_id) player.leagues.add(league) @@ -121,28 +144,30 @@ def update_or_create_roster(league_id, roster_data, dst_player_data): owner_id = roster_data.get("owner_id") roster_settings = roster_data.get("settings", {}) - roster, _ = Roster.objects.update_or_create(roster_id=roster_data.get("roster_id"), - league=League.objects.get(sleeper_id=league_id), - defaults={ - "name": dst_player_data.get(owner_id, {}).get("metadata", {}).get( - "team_name"), - "starters": roster_data.get("starters"), - "wins": roster_settings.get("wins", 0), - "waiver_position": roster_settings.get("waiver_position", 1), - "waiver_budget_used": roster_settings.get("waiver_budget_used", 0), - "total_moves": roster_settings.get("total_moves", 0), - "ties": roster_settings.get("ties", 0), - "losses": roster_settings.get("losses", 0), - "fpts_decimal": roster_settings.get("fpts_decimal", 0), - "fpts_against_decimal": roster_settings.get("fpts_against_decimal", - 0), - "fpts_against": roster_settings.get("fpts_against", 0), - "fpts": roster_settings.get("fpts", 0), - "settings": roster_settings, - "reserve": roster_data.get("reserve"), - "players": roster_data.get("players"), - "owner": DSTPlayer.objects.filter(sleeper_id=owner_id).first() - }) + roster, _ = Roster.objects.update_or_create( + roster_id=roster_data.get("roster_id"), + league=League.objects.get(sleeper_id=league_id), + defaults={ + "name": dst_player_data.get(owner_id, {}) + .get("metadata", {}) + .get("team_name"), + "starters": roster_data.get("starters"), + "wins": roster_settings.get("wins", 0), + "waiver_position": roster_settings.get("waiver_position", 1), + "waiver_budget_used": roster_settings.get("waiver_budget_used", 0), + "total_moves": roster_settings.get("total_moves", 0), + "ties": roster_settings.get("ties", 0), + "losses": roster_settings.get("losses", 0), + "fpts_decimal": roster_settings.get("fpts_decimal", 0), + "fpts_against_decimal": roster_settings.get("fpts_against_decimal", 0), + "fpts_against": roster_settings.get("fpts_against", 0), + "fpts": roster_settings.get("fpts", 0), + "settings": roster_settings, + "reserve": roster_data.get("reserve"), + "players": roster_data.get("players"), + "owner": DSTPlayer.objects.filter(sleeper_id=owner_id).first(), + }, + ) roster.save() return roster @@ -154,11 +179,11 @@ def get_roster_data(league_id): def update_rosters_for_league(league_id, roster_data, dst_player_data): rosters = [] - dst_player_data_by_id = { - pd.get("user_id"): pd for pd in dst_player_data - } + dst_player_data_by_id = {pd.get("user_id"): pd for pd in dst_player_data} for roster in roster_data: - rosters.append(update_or_create_roster(league_id, roster, dst_player_data_by_id)) + rosters.append( + update_or_create_roster(league_id, roster, dst_player_data_by_id) + ) return rosters @@ -196,39 +221,47 @@ def guess_level(name): return 4 elif "RL" in name or "Regionalliga" in name: return 5 + elif "KL" in name or "Kreisliga" in name: + return 6 else: return 6 def update_or_create_draft(league_id, draft_data): - start_time = draft_data.get('start_time') + start_time = draft_data.get("start_time") if start_time: - start_time = datetime.fromtimestamp(start_time / 1000, tz=timezone('Europe/Berlin')) + start_time = datetime.fromtimestamp( + start_time / 1000, tz=timezone("Europe/Berlin") + ) - last_picked = draft_data.get('last_picked') + last_picked = draft_data.get("last_picked") if last_picked: - last_picked = datetime.fromtimestamp(last_picked / 1000, tz=timezone('Europe/Berlin')) + last_picked = datetime.fromtimestamp( + last_picked / 1000, tz=timezone("Europe/Berlin") + ) - last_message_time = draft_data.get('last_message_time') + last_message_time = draft_data.get("last_message_time") if last_message_time: - last_message_time = datetime.fromtimestamp(last_message_time / 1000, tz=timezone('Europe/Berlin')) + last_message_time = datetime.fromtimestamp( + last_message_time / 1000, tz=timezone("Europe/Berlin") + ) draft, _ = Draft.objects.update_or_create( - draft_id=draft_data.get('draft_id'), + draft_id=draft_data.get("draft_id"), league=League.objects.get(sleeper_id=league_id), defaults={ - "draft_type": draft_data.get('draft_id', ''), - "status": draft_data.get('status', ''), + "draft_type": draft_data.get("draft_id", ""), + "status": draft_data.get("status", ""), "start_time": start_time, - "settings": draft_data.get('settings', {}), - "season_type": draft_data.get('season_type', ''), - "season": draft_data.get('season', 0), - "metadata": draft_data.get('metadata', {}), + "settings": draft_data.get("settings", {}), + "season_type": draft_data.get("season_type", ""), + "season": draft_data.get("season", 0), + "metadata": draft_data.get("metadata", {}), "last_picked": last_picked, "last_message_time": last_message_time, - "last_message_id": draft_data.get('last_message_id'), - "draft_order": draft_data.get('draft_order') - } + "last_message_id": draft_data.get("last_message_id"), + "draft_order": draft_data.get("draft_order"), + }, ) draft.save() @@ -245,11 +278,10 @@ def get_draft_data(league_id): return response - def update_drafts_for_league(league_id): drafts_data = get_draft_data(league_id) - latest_draft_data = max(drafts_data, key=lambda d: d.get('start_time')) + latest_draft_data = max(drafts_data, key=lambda d: d.get("start_time")) draft = update_or_create_draft(league_id, latest_draft_data) delete_old_drafts(league_id, draft.draft_id) @@ -261,26 +293,42 @@ def update_or_create_pick(draft_id, pick_data): draft = Draft.objects.get(draft_id=draft_id) pick, _ = Pick.objects.update_or_create( draft=draft, - pick_no=pick_data.get('pick_no'), + pick_no=pick_data.get("pick_no"), defaults={ - "player": Player.objects.get(sleeper_id=pick_data.get('player_id')), - "owner": DSTPlayer.objects.get(sleeper_id=pick_data.get('picked_by')), - "roster": Roster.objects.get(roster_id=pick_data.get('roster_id'), - owner__sleeper_id=pick_data.get('picked_by'), - league=draft.league), - "round": pick_data.get('round', 1), - "draft_slot": pick_data.get('draft_slot', 1), - "metadata": pick_data.get('metadata', {}) - } + "player": Player.objects.get(sleeper_id=pick_data.get("player_id")), + "owner": DSTPlayer.objects.get(sleeper_id=pick_data.get("picked_by")), + "roster": Roster.objects.get( + roster_id=pick_data.get("roster_id"), + owner__sleeper_id=pick_data.get("picked_by"), + league=draft.league, + ), + "round": pick_data.get("round", 1), + "draft_slot": pick_data.get("draft_slot", 1), + "metadata": pick_data.get("metadata", {}), + }, ) pick.save() return pick except Roster.DoesNotExist as e: - print("Draft: ", draft_id, "Roster: ", pick_data.get('roster_id'), "Picked by: ", pick_data.get('picked_by')) + print( + "Draft: ", + draft_id, + "Roster: ", + pick_data.get("roster_id"), + "Picked by: ", + pick_data.get("picked_by"), + ) except DSTPlayer.DoesNotExist as e: - print("Draft: ", draft_id, "Roster: ", pick_data.get('roster_id'), "Picked by: ", pick_data.get('picked_by')) + print( + "Draft: ", + draft_id, + "Roster: ", + pick_data.get("roster_id"), + "Picked by: ", + pick_data.get("picked_by"), + ) def get_pick_data(draft_id): @@ -301,10 +349,15 @@ def update_picks_for_draft(draft_id, picks_data): def update_draft_stats(): # Alle Picks mit mindestens 5 Picks je Spieler, sortiert nach Differenz zwischen adp und pick_no # Relevante Spieler: - relevant_players = Pick.objects.all().values('player__id').annotate(pick_count=Count('player__id')).filter( - pick_count__gte=5).values_list('player_id', flat=True) + relevant_players = ( + Pick.objects.all() + .values("player__id") + .annotate(pick_count=Count("player__id")) + .filter(pick_count__gte=5) + .values_list("player_id", flat=True) + ) relevant_picks = Pick.objects.filter(player__id__in=relevant_players) - for pick in relevant_picks.annotate(adp=Avg('pick_no')): + for pick in relevant_picks.annotate(adp=Avg("pick_no")): pass @@ -350,22 +403,25 @@ def update_or_create_player(player_id, player_data): except ValueError: type = Player.TEAM - player, _ = Player.objects.update_or_create(sleeper_id=player_id, defaults={ - "type": type, - "hashtag": player_data.get("hashtag", ''), - "depth_chart_position": player_data.get("depth_chart_position"), - "status": player_data.get("status", ''), - "fantasy_positions": ','.join(fantasy_positions), - "number": number, - "last_name": player_data.get("last_name", ''), - "first_name": player_data.get("first_name", ''), - "weight": int(weight), - "position": player_data.get("position"), - "height": player_data.get("height"), - "age": age, - "espn_id": player_data.get("espn_id"), - "yahoo_id": player_data.get("yahoo_id"), - }) + player, _ = Player.objects.update_or_create( + sleeper_id=player_id, + defaults={ + "type": type, + "hashtag": player_data.get("hashtag", ""), + "depth_chart_position": player_data.get("depth_chart_position"), + "status": player_data.get("status", ""), + "fantasy_positions": ",".join(fantasy_positions), + "number": number, + "last_name": player_data.get("last_name", ""), + "first_name": player_data.get("first_name", ""), + "weight": int(weight), + "position": player_data.get("position"), + "height": player_data.get("height"), + "age": age, + "espn_id": player_data.get("espn_id"), + "yahoo_id": player_data.get("yahoo_id"), + }, + ) team_abbr = player_data.get("team") if team_abbr: @@ -389,14 +445,18 @@ def update_players(): def update_listener_league(): - listener_league_id = League.objects.get_active().get(type=League.LISTENER).sleeper_id + listener_league_id = ( + League.objects.get_active().get(type=League.LISTENER).sleeper_id + ) league_data = get_league_data(listener_league_id) try: - ls = LeagueSetting(id=listener_league_id, - name="DST Hörerliga", - level=99, - conference=None, - region=None) + ls = LeagueSetting( + id=listener_league_id, + name="DST Hörerliga", + level=99, + conference=None, + region=None, + ) update_or_create_league(ls, league_data) dst_player_data = get_dst_player_data(listener_league_id) update_dst_players_for_league(listener_league_id, dst_player_data) @@ -411,7 +471,9 @@ def update_listener_league(): def update_listener_draft(): - listener_league_id = League.objects.get_active().get(type=League.LISTENER).sleeper_id + listener_league_id = ( + League.objects.get_active().get(type=League.LISTENER).sleeper_id + ) draft = update_drafts_for_league(listener_league_id) picks_data = get_pick_data(draft.draft_id) @@ -434,13 +496,9 @@ def update_matchup_for_league(league_id, week): matchup_id = matchup_data.get("matchup_id") matchup = matchups.get(matchup_id) if not matchup: - matchups[matchup_id] = { - 'one': matchup_data - } + matchups[matchup_id] = {"one": matchup_data} else: - matchups[matchup_id].update({ - 'two': matchup_data - }) + matchups[matchup_id].update({"two": matchup_data}) for id, data in matchups.items(): Matchup.objects.update_or_create( league_id=league_id, @@ -454,8 +512,9 @@ def update_matchup_for_league(league_id, week): "roster_id_two": data.get("two").get("roster_id"), "starters_two": ",".join(data.get("two").get("starters") or []), "players_two": ",".join(data.get("two").get("players") or []), - "points_two": data.get("two").get("points") or 0 - }) + "points_two": data.get("two").get("points") or 0, + }, + ) def update_playoffs(): @@ -488,8 +547,8 @@ def create_playoff_matchup(league_id, matchup, bracket): "roster_id_two": matchup.get("t2"), "winner": matchup.get("w"), "loser": matchup.get("l"), - "rank": matchup.get("p") - } + "rank": matchup.get("p"), + }, ) @@ -498,7 +557,11 @@ def get_current_week(): def update_stats_for_position(position, week): - print("Updating Stats for Position {position} in week {week}".format(position=position, week=week)) + print( + "Updating Stats for Position {position} in week {week}".format( + position=position, week=week + ) + ) season_type = "regular" season = StateService().get_season() @@ -517,10 +580,7 @@ def update_stats_for_position(position, week): season_type=season_type, season=season_object, player=player, - defaults={ - "points": points, - "stats": player_stats - } + defaults={"points": points, "stats": player_stats}, ) if not created: stats.points = points @@ -528,18 +588,28 @@ def update_stats_for_position(position, week): stats.save() except Player.DoesNotExist: - print("Could not update Stats for unknown Player {player_id}".format(player_id=player_id)) + print( + "Could not update Stats for unknown Player {player_id}".format( + player_id=player_id + ) + ) print("All done!") def update_projections_for_position(position, week): - print("Updating Projections for Position {position} in week {week}".format(position=position, week=week)) + print( + "Updating Projections for Position {position} in week {week}".format( + position=position, week=week + ) + ) season_type = "regular" season = StateService().get_season() stats_service = StatsService() - position_stats = stats_service.get_week_projections(season_type, season, position, week) + position_stats = stats_service.get_week_projections( + season_type, season, position, week + ) for stats in position_stats: player_id = stats.get("player_id") @@ -555,8 +625,8 @@ def update_projections_for_position(position, week): player=player, defaults={ "projected_points": projected_points, - "projected_stats": player_projected_stats - } + "projected_stats": player_projected_stats, + }, ) if not created: stats.projected_points = projected_points @@ -564,7 +634,11 @@ def update_projections_for_position(position, week): stats.save() except Player.DoesNotExist: - print("Could not update Projections for unknown Player {player_id}".format(player_id=player_id)) + print( + "Could not update Projections for unknown Player {player_id}".format( + player_id=player_id + ) + ) print("All done!") @@ -589,22 +663,29 @@ def update_player_draft_stats_from_picks(season: Season): player_map = {} for pick in Pick.objects.filter(roster__league__season=season): player_stats = player_map.get(pick.player.sleeper_id, {}) - player_stats['name'] = f"{pick.player.first_name} {pick.player.last_name}" - player_stats['team'] = pick.player.team.abbr if pick.player.team else '-' - player_stats['position'] = pick.player.position - player_stats['picked_positions'] = player_stats.get('picked_positions', []) + [pick.pick_no] + player_stats["name"] = f"{pick.player.first_name} {pick.player.last_name}" + player_stats["team"] = pick.player.team.abbr if pick.player.team else "-" + player_stats["position"] = pick.player.position + player_stats["picked_positions"] = player_stats.get("picked_positions", []) + [ + pick.pick_no + ] player_map[pick.player.sleeper_id] = player_stats for player_id, player_stats in player_map.items(): - PlayerDraftStats.objects.update_or_create(season=season, player_id=player_id, defaults={ - 'player_name': player_stats['name'], - 'player_team': player_stats['team'], - 'player_position': player_stats['position'], - 'pick_count': len(player_stats['picked_positions']), - 'adp': sum(player_stats['picked_positions']) / len(player_stats['picked_positions']), - 'highest_pick': min(player_stats['picked_positions']), - 'lowest_pick': max(player_stats['picked_positions']) - }) + PlayerDraftStats.objects.update_or_create( + season=season, + player_id=player_id, + defaults={ + "player_name": player_stats["name"], + "player_team": player_stats["team"], + "player_position": player_stats["position"], + "pick_count": len(player_stats["picked_positions"]), + "adp": sum(player_stats["picked_positions"]) + / len(player_stats["picked_positions"]), + "highest_pick": min(player_stats["picked_positions"]), + "lowest_pick": max(player_stats["picked_positions"]), + }, + ) def update_trades(week=None): @@ -620,43 +701,70 @@ def update_trades_for_league(league_id, week=None): league_service = sleeper_wrapper.League(league_id) trades = league_service.get_transactions(week) for trade in trades: - if trade.get('type') == 'waiver': - roster = Roster.objects.get(league__sleeper_id=league_id, roster_id=trade.get('roster_ids')[0]) - status = trade.get('status') - bid = trade.get('settings', {}).get('waiver_bid', 0) - player = Player.objects.get(sleeper_id=next(iter(trade.get('adds')))) - changed_ts = datetime.fromtimestamp(trade.get('status_updated') / 1000, tz=timezone('Europe/Berlin')) - WaiverPickup.objects.update_or_create(season=Season.get_active(), week=week, roster=roster, player=player, defaults={ - 'status': status, - 'bid': bid, - 'changed_ts': changed_ts - }) + if trade.get("type") == "waiver": + roster = Roster.objects.get( + league__sleeper_id=league_id, roster_id=trade.get("roster_ids")[0] + ) + status = trade.get("status") + bid = trade.get("settings", {}).get("waiver_bid", 0) + player = Player.objects.get(sleeper_id=next(iter(trade.get("adds")))) + changed_ts = datetime.fromtimestamp( + trade.get("status_updated") / 1000, tz=timezone("Europe/Berlin") + ) + WaiverPickup.objects.update_or_create( + season=Season.get_active(), + week=week, + roster=roster, + player=player, + defaults={"status": status, "bid": bid, "changed_ts": changed_ts}, + ) class StatsService(BaseApi): def __init__(self): self._base_stats_url = "https://api.sleeper.app/stats/{}".format("nfl") - self._base_projections_url = "https://api.sleeper.app/projections/{}".format("nfl") + self._base_projections_url = "https://api.sleeper.app/projections/{}".format( + "nfl" + ) def get_all_stats(self, season_type, season, position): return self._call( "{base_url}/{season}?season_type={season_type}&position[]={positionorder_by=pts_half_ppr".format( - base_url=self._base_stats_url, season=season, season_type=season_type, position=position)) + base_url=self._base_stats_url, + season=season, + season_type=season_type, + position=position, + ) + ) def get_week_stats(self, season_type, season, position, week): return self._call( "{base_url}/{season}/{week}?season_type={season_type}&position[]={position}&order_by=pts_half_ppr".format( - base_url=self._base_stats_url, season=season, season_type=season_type, position=position, week=week)) + base_url=self._base_stats_url, + season=season, + season_type=season_type, + position=position, + week=week, + ) + ) def get_all_projections(self, season_type, season, position): return self._call( "{base_url}/{season}?season_type={season_type}&position[]={positionorder_by=pts_half_ppr".format( - base_url=self._base_projections_url, season=season, season_type=season_type, position=position)) + base_url=self._base_projections_url, + season=season, + season_type=season_type, + position=position, + ) + ) def get_week_projections(self, season_type, season, position, week): return self._call( "{base_url}/{season}/{week}?season_type={season_type}&position[]={position}&order_by=pts_half_ppr".format( - base_url=self._base_projections_url, season=season, season_type=season_type, position=position, - week=week)) - - + base_url=self._base_projections_url, + season=season, + season_type=season_type, + position=position, + week=week, + ) + ) diff --git a/DSTBundesliga/apps/services/patreon_service.py b/DSTBundesliga/apps/services/patreon_service.py index 02a7578..b2c8dc1 100644 --- a/DSTBundesliga/apps/services/patreon_service.py +++ b/DSTBundesliga/apps/services/patreon_service.py @@ -6,7 +6,7 @@ def read_patreon_file(filepath=None): with open(filepath) as csv_file: dialect = csv.Sniffer().sniff(csv_file.readline()) csv_file.seek(0) - patreon_reader = csv.DictReader(csv_file, dialect=dialect) + patreon_reader = csv.DictReader(csv_file, dialect=dialect) return [row for row in patreon_reader] @@ -28,7 +28,11 @@ def get_emails(patreon_data): def get_discord(patreon_data): - return [row.get("Discord").split("#")[0].strip().upper() for row in patreon_data if '#' in row.get("Discord")] + return [ + row.get("Discord").split("#")[0].strip().upper() + for row in patreon_data + if "#" in row.get("Discord") + ] def find_missing_users(patreon_filepath, ffbl_filepath): @@ -53,10 +57,10 @@ def find_missing_users(patreon_filepath, ffbl_filepath): no_second_run_hit = [] for name in no_direct_hit: - stripped_name = re.sub(r'\([^)]*\)', '', name).replace(" ", "").strip() + stripped_name = re.sub(r"\([^)]*\)", "", name).replace(" ", "").strip() stripped_email = stripped_name if "(" in name and ")" in name: - stripped_email = name[name.find("(")+1:name.find(")")] + stripped_email = name[name.find("(") + 1 : name.find(")")] if stripped_name in second_run_names: second_run_names.remove(stripped_name) @@ -88,9 +92,9 @@ def find_missing_users(patreon_filepath, ffbl_filepath): print("name:", name, "pat_mail:", patreon_email) no_last_run_hit.remove(name) - found = set(names_to_find)-set(no_direct_hit) - likely_found = set(no_direct_hit)-set(no_second_run_hit) - maybe_found = set(no_second_run_hit)-set(no_last_run_hit) + found = set(names_to_find) - set(no_direct_hit) + likely_found = set(no_direct_hit) - set(no_second_run_hit) + maybe_found = set(no_second_run_hit) - set(no_last_run_hit) not_found = no_last_run_hit with open("local/maybe_found.txt", "w") as file: @@ -102,6 +106,3 @@ def find_missing_users(patreon_filepath, ffbl_filepath): file.write(name + "\n") return list(found), list(likely_found), list(maybe_found), not_found - - - diff --git a/DSTBundesliga/apps/services/rss_service.py b/DSTBundesliga/apps/services/rss_service.py index 7e90076..5210f34 100644 --- a/DSTBundesliga/apps/services/rss_service.py +++ b/DSTBundesliga/apps/services/rss_service.py @@ -23,15 +23,13 @@ def update(): def create_news(entry): News.objects.create( - title=entry.title, - content=get_content(entry), - image=settings.PODCAST_NEWS_LOGO + title=entry.title, content=get_content(entry), image=settings.PODCAST_NEWS_LOGO ) def get_last_update_ts(): try: - with open(settings.RSS_TIMESTAMP_FILE, 'r') as ts_file: + with open(settings.RSS_TIMESTAMP_FILE, "r") as ts_file: ts = ts_file.readline().strip() dt = parse(ts) except Exception as e: @@ -42,9 +40,11 @@ def get_last_update_ts(): def set_last_update_ts(dt): - with open(settings.RSS_TIMESTAMP_FILE, 'w') as ts_file: + with open(settings.RSS_TIMESTAMP_FILE, "w") as ts_file: ts_file.write(str(dt)) def get_content(entry): - return entry.summary + "

Hier geht's zur neuen Folge".format(link=entry.link) + return entry.summary + "

Hier geht's zur neuen Folge".format( + link=entry.link + ) diff --git a/DSTBundesliga/apps/services/season_service.py b/DSTBundesliga/apps/services/season_service.py index 0fb309e..2b44941 100644 --- a/DSTBundesliga/apps/services/season_service.py +++ b/DSTBundesliga/apps/services/season_service.py @@ -2,23 +2,31 @@ from django.conf import settings -from DSTBundesliga.apps.leagues.models import PlayoffMatchup, Season, League, FinalSeasonStanding, Roster +from DSTBundesliga.apps.leagues.models import ( + PlayoffMatchup, + Season, + League, + FinalSeasonStanding, + Roster, +) def is_registration_open(): - return datetime.date.fromisoformat(settings.REGISTRATION_STARTS) \ - <= datetime.date.today() \ - <= datetime.date.fromisoformat(settings.REGISTRATION_STOPS) + return ( + datetime.date.fromisoformat(settings.REGISTRATION_STARTS) + <= datetime.date.today() + <= datetime.date.fromisoformat(settings.REGISTRATION_STOPS) + ) def calc_final_standings(season: Season): # Add per league points - for league in League.objects.filter(season = season, type=League.BUNDESLIGA): - for rank, roster in enumerate(league.rosters.order_by('-fpts', '-fpts_decimal'), 1): + for league in League.objects.filter(season=season, type=League.BUNDESLIGA): + for rank, roster in enumerate( + league.rosters.order_by("-fpts", "-fpts_decimal"), 1 + ): season_ranking, created = FinalSeasonStanding.objects.get_or_create( - season=season, - roster=roster, - league=league + season=season, roster=roster, league=league ) season_ranking.points_ranking_in_league = rank season_ranking.points = roster.fpts @@ -27,64 +35,84 @@ def calc_final_standings(season: Season): season_ranking.save() # Add per level points - for level in sorted(list(set(League.objects.filter(type=League.BUNDESLIGA).values_list('level', flat=True)))): - for rank, roster in enumerate(Roster.objects.filter(league__level=level, league__season=season).order_by('-fpts', '-fpts_decimal'), 1): + for level in sorted( + list( + set( + League.objects.filter(type=League.BUNDESLIGA).values_list( + "level", flat=True + ) + ) + ) + ): + for rank, roster in enumerate( + Roster.objects.filter(league__level=level, league__season=season).order_by( + "-fpts", "-fpts_decimal" + ), + 1, + ): season_ranking = FinalSeasonStanding.objects.get( - season=season, - roster=roster + season=season, roster=roster ) season_ranking.points_ranking_on_level = rank season_ranking.save() # Add overall points - for rank, roster in enumerate(Roster.objects.filter(league__type=League.BUNDESLIGA, league__season=season).order_by('-fpts', '-fpts_decimal'), 1): - season_ranking = FinalSeasonStanding.objects.get( - season=season, - roster=roster - ) + for rank, roster in enumerate( + Roster.objects.filter( + league__type=League.BUNDESLIGA, league__season=season + ).order_by("-fpts", "-fpts_decimal"), + 1, + ): + season_ranking = FinalSeasonStanding.objects.get(season=season, roster=roster) season_ranking.points_ranking_overall = rank season_ranking.save() - # Add ranks per league - all_bundesliga_league_ids = League.objects.filter(type=League.BUNDESLIGA, season=season).values_list("sleeper_id", flat=True) - all_mus = PlayoffMatchup.objects.filter(season=season, league_id__in=all_bundesliga_league_ids) + all_bundesliga_league_ids = League.objects.filter( + type=League.BUNDESLIGA, season=season + ).values_list("sleeper_id", flat=True) + all_mus = PlayoffMatchup.objects.filter( + season=season, league_id__in=all_bundesliga_league_ids + ) for rank in [1, 3, 5]: for mu in all_mus.filter(bracket="Playoffs", rank=rank): - winner = Roster.objects.get(league__sleeper_id=mu.league_id, roster_id=mu.winner) + winner = Roster.objects.get( + league__sleeper_id=mu.league_id, roster_id=mu.winner + ) season_ranking_winner = FinalSeasonStanding.objects.get( - season=season, - roster=winner + season=season, roster=winner ) season_ranking_winner.rank_in_league = rank season_ranking_winner.save() - loser = Roster.objects.get(league__sleeper_id=mu.league_id, roster_id=mu.loser) + loser = Roster.objects.get( + league__sleeper_id=mu.league_id, roster_id=mu.loser + ) season_ranking_loser = FinalSeasonStanding.objects.get( - season=season, - roster=loser + season=season, roster=loser ) season_ranking_loser.rank_in_league = rank + 1 season_ranking_loser.save() for rank in [1, 3, 5]: for mu in all_mus.filter(bracket="Toilet Bowl", rank=rank): - winner = Roster.objects.get(league__sleeper_id=mu.league_id, roster_id=mu.winner) + winner = Roster.objects.get( + league__sleeper_id=mu.league_id, roster_id=mu.winner + ) season_ranking_winner = FinalSeasonStanding.objects.get( - season=season, - roster=winner + season=season, roster=winner ) season_ranking_winner.rank_in_league = 13 - rank season_ranking_winner.save() - loser = Roster.objects.get(league__sleeper_id=mu.league_id, roster_id=mu.loser) + loser = Roster.objects.get( + league__sleeper_id=mu.league_id, roster_id=mu.loser + ) season_ranking_loser = FinalSeasonStanding.objects.get( - season=season, - roster=loser + season=season, roster=loser ) - season_ranking_loser.rank_in_league = 13 - 1 -rank + season_ranking_loser.rank_in_league = 13 - 1 - rank season_ranking_loser.save() - diff --git a/DSTBundesliga/apps/services/state_service.py b/DSTBundesliga/apps/services/state_service.py index 010c841..163a8e6 100644 --- a/DSTBundesliga/apps/services/state_service.py +++ b/DSTBundesliga/apps/services/state_service.py @@ -39,7 +39,7 @@ def get_state(self): leg=state_data.get("leg"), league_season=state_data.get("league_season"), league_create_season=state_data.get("league_create_season"), - display_week=state_data.get("display_week") + display_week=state_data.get("display_week"), ) def get_season(self): diff --git a/DSTBundesliga/asgi.py b/DSTBundesliga/asgi.py index b049a8a..cac8373 100644 --- a/DSTBundesliga/asgi.py +++ b/DSTBundesliga/asgi.py @@ -11,6 +11,6 @@ from django.core.asgi import get_asgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'DSTBundesliga.settings') +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "DSTBundesliga.settings") application = get_asgi_application() diff --git a/DSTBundesliga/settings.py b/DSTBundesliga/settings.py index 5ce086a..f0d6700 100644 --- a/DSTBundesliga/settings.py +++ b/DSTBundesliga/settings.py @@ -24,12 +24,12 @@ # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = os.getenv('SECRET_KEY') +SECRET_KEY = os.getenv("SECRET_KEY") # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False -ALLOWED_HOSTS = ['dstffbl.uber.space', '.downsettalk.de', '.fantasybundesliga.de'] +ALLOWED_HOSTS = ["dstffbl.uber.space", ".downsettalk.de", ".fantasybundesliga.de"] SITE_ID = 1 @@ -37,134 +37,133 @@ AUTHENTICATION_BACKENDS = [ # Needed to login by username in Django admin, regardless of `allauth` - 'django.contrib.auth.backends.ModelBackend', - + "django.contrib.auth.backends.ModelBackend", # `allauth` specific authentication methods, such as login by e-mail - 'allauth.account.auth_backends.AuthenticationBackend', + "allauth.account.auth_backends.AuthenticationBackend", ] SOCIALACCOUNT_PROVIDERS = { - 'patreon': { - 'VERSION': 'v2', - 'SCOPE': ['identity', 'identity[email]', 'identity.memberships'] + "patreon": { + "VERSION": "v2", + "SCOPE": ["identity", "identity[email]", "identity.memberships"], } } -ACCOUNT_AUTHENTICATION_METHOD = 'email' +ACCOUNT_AUTHENTICATION_METHOD = "email" ACCOUNT_EMAIL_REQUIRED = True -ACCOUNT_USER_MODEL_USERNAME_FIELD = 'username' +ACCOUNT_USER_MODEL_USERNAME_FIELD = "username" SOCIALACCOUNT_ADAPTER = "DSTBundesliga.apps.dstffbl.models.CustomSocialAccountAdapter" SOCIALACCOUNT_AUTO_SIGNUP = True -SOCIALACCOUNT_EMAIL_VERIFICATION ='none' -SESSION_COOKIE_SAMESITE = 'Lax' -CSRF_COOKIE_SAMESITE = 'Lax' -SESSION_COOKIE_NAME = 'dstffbl_session_id' +SOCIALACCOUNT_EMAIL_VERIFICATION = "none" +SESSION_COOKIE_SAMESITE = "Lax" +CSRF_COOKIE_SAMESITE = "Lax" +SESSION_COOKIE_NAME = "dstffbl_session_id" CSRF_USE_SESSIONS = True INSTALLED_APPS = [ - 'djangocms_admin_style', - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.messages', - 'django.contrib.staticfiles', - 'django.contrib.sites', - 'cms', - 'menus', - 'treebeard', - 'sekizai', - 'filer', - 'easy_thumbnails', - 'mptt', - 'djangocms_text_ckeditor', - 'djangocms_link', - 'djangocms_file', - 'djangocms_picture', - 'djangocms_video', - 'djangocms_googlemap', - 'djangocms_snippet', - 'djangocms_style', - 'django_tables2', - 'cookielaw', - 'tinymce', - 'DSTBundesliga.apps.leagues', - 'DSTBundesliga.apps.dstffbl', - 'allauth', - 'allauth.account', - 'allauth.socialaccount', - 'allauth.socialaccount.providers.patreon', + "djangocms_admin_style", + "django.contrib.admin", + "django.contrib.auth", + "django.contrib.contenttypes", + "django.contrib.sessions", + "django.contrib.messages", + "django.contrib.staticfiles", + "django.contrib.sites", + "cms", + "menus", + "treebeard", + "sekizai", + "filer", + "easy_thumbnails", + "mptt", + "djangocms_text_ckeditor", + "djangocms_link", + "djangocms_file", + "djangocms_picture", + "djangocms_video", + "djangocms_googlemap", + "djangocms_snippet", + "djangocms_style", + "django_tables2", + "cookielaw", + "tinymce", + "DSTBundesliga.apps.leagues", + "DSTBundesliga.apps.dstffbl", + "allauth", + "allauth.account", + "allauth.socialaccount", + "allauth.socialaccount.providers.patreon", ] MIDDLEWARE = [ - 'django.middleware.security.SecurityMiddleware', - 'django.contrib.sessions.middleware.SessionMiddleware', - 'django.middleware.common.CommonMiddleware', - 'django.middleware.csrf.CsrfViewMiddleware', - 'django.contrib.auth.middleware.AuthenticationMiddleware', - 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware', - 'django.middleware.locale.LocaleMiddleware', - 'cms.middleware.user.CurrentUserMiddleware', - 'cms.middleware.page.CurrentPageMiddleware', - 'cms.middleware.toolbar.ToolbarMiddleware', - 'cms.middleware.language.LanguageCookieMiddleware', + "django.middleware.security.SecurityMiddleware", + "django.contrib.sessions.middleware.SessionMiddleware", + "django.middleware.common.CommonMiddleware", + "django.middleware.csrf.CsrfViewMiddleware", + "django.contrib.auth.middleware.AuthenticationMiddleware", + "django.contrib.messages.middleware.MessageMiddleware", + "django.middleware.clickjacking.XFrameOptionsMiddleware", + "django.middleware.locale.LocaleMiddleware", + "cms.middleware.user.CurrentUserMiddleware", + "cms.middleware.page.CurrentPageMiddleware", + "cms.middleware.toolbar.ToolbarMiddleware", + "cms.middleware.language.LanguageCookieMiddleware", ] -ROOT_URLCONF = 'DSTBundesliga.urls' +ROOT_URLCONF = "DSTBundesliga.urls" TEMPLATES = [ { - 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': ['templates'], - 'APP_DIRS': True, - 'OPTIONS': { - 'context_processors': [ - 'django.template.context_processors.debug', - 'django.template.context_processors.request', - 'django.contrib.auth.context_processors.auth', - 'django.contrib.messages.context_processors.messages', - 'sekizai.context_processors.sekizai', - 'cms.context_processors.cms_settings', - 'django.template.context_processors.i18n', - 'cookielaw.context_processors.cookielaw' + "BACKEND": "django.template.backends.django.DjangoTemplates", + "DIRS": ["templates"], + "APP_DIRS": True, + "OPTIONS": { + "context_processors": [ + "django.template.context_processors.debug", + "django.template.context_processors.request", + "django.contrib.auth.context_processors.auth", + "django.contrib.messages.context_processors.messages", + "sekizai.context_processors.sekizai", + "cms.context_processors.cms_settings", + "django.template.context_processors.i18n", + "cookielaw.context_processors.cookielaw", ], }, }, ] -WSGI_APPLICATION = 'DSTBundesliga.wsgi.application' +WSGI_APPLICATION = "DSTBundesliga.wsgi.application" # Password validation # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { - 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', + "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', + "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', + "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", }, { - 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', + "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", }, ] LANGUAGES = [ - ('en', 'English'), - ('de', 'German'), + ("en", "English"), + ("de", "German"), ] # Internationalization # https://docs.djangoproject.com/en/3.0/topics/i18n/ -LANGUAGE_CODE = 'de' +LANGUAGE_CODE = "de" -TIME_ZONE = 'Europe/Berlin' +TIME_ZONE = "Europe/Berlin" USE_I18N = True @@ -173,7 +172,7 @@ USE_TZ = True CMS_TEMPLATES = [ - ('home.html', 'Home page template'), + ("home.html", "Home page template"), ] CMS_PERMISSION = True @@ -181,48 +180,48 @@ MEDIA_URL = "/media/" MEDIA_ROOT = os.path.expanduser("~/html/media/") -FILER_CANONICAL_URL = 'files/' +FILER_CANONICAL_URL = "files/" THUMBNAIL_HIGH_RESOLUTION = True THUMBNAIL_PROCESSORS = ( - 'easy_thumbnails.processors.colorspace', - 'easy_thumbnails.processors.autocrop', - 'filer.thumbnail_processors.scale_and_crop_with_subject_location', - 'easy_thumbnails.processors.filters' + "easy_thumbnails.processors.colorspace", + "easy_thumbnails.processors.autocrop", + "filer.thumbnail_processors.scale_and_crop_with_subject_location", + "easy_thumbnails.processors.filters", ) # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.0/howto/static-files/ -STATIC_URL = '/static/' +STATIC_URL = "/static/" STATIC_ROOT = os.path.expanduser("~/html/static/") -STATICFILES_DIRS = [os.path.join(BASE_DIR, 'staticfiles')] +STATICFILES_DIRS = [os.path.join(BASE_DIR, "staticfiles")] ADMIN_MEDIA_PREFIX = "/static/admin/" -LOGIN_REDIRECT_URL = '/' -LOGOUT_REDIRECT_URL = '/' +LOGIN_REDIRECT_URL = "/" +LOGOUT_REDIRECT_URL = "/" REGISTRATION_STARTS = "2023-07-31" REGISTRATION_STOPS = "2023-08-11" -if os.getenv('DEV', 0) == '1': +if os.getenv("DEV", 0) == "1": from local_settings import * STATIC_ROOT = os.path.join(BASE_DIR, "static/") MEDIA_ROOT = os.path.join(BASE_DIR, "media") DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': 'mydatabase', + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": "mydatabase", } } CACHES = { - 'default': { - 'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', - 'LOCATION': 'unique-snowflake', + "default": { + "BACKEND": "django.core.cache.backends.locmem.LocMemCache", + "LOCATION": "unique-snowflake", } } else: @@ -230,10 +229,10 @@ # https://docs.djangoproject.com/en/3.0/ref/settings/#databases DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.mysql', - 'OPTIONS': { - 'read_default_file': os.getenv('DB_OPTIONS_FILE'), + "default": { + "ENGINE": "django.db.backends.mysql", + "OPTIONS": { + "read_default_file": os.getenv("DB_OPTIONS_FILE"), }, } } @@ -244,12 +243,14 @@ "LOCATION": "unix:///home/dstffbl/.redis/sock?db=0", "OPTIONS": { "CLIENT_CLASS": "django_redis.client.DefaultClient", - } + }, } } import hashlib + + def md5(fname): hash_md5 = hashlib.md5() with open(fname, "rb") as f: @@ -260,10 +261,6 @@ def md5(fname): CSS_VERSION_HASH = md5(os.path.join(BASE_DIR, "staticfiles/css/base.css")) -MAX_PLAYERS = 1404 - -DEFAULT_LEAGUE_SETTINGS_PATH = os.path.join(BASE_DIR, "Ligaübersicht.csv") - DEFAULT_NEWS_LOGO = "dst_logo_96.png" RSS_FEED = "https://anchor.fm/s/1ce78cc4/podcast/rss" @@ -272,26 +269,24 @@ def md5(fname): LOGGING = { - 'version': 1, - 'disable_existing_loggers': False, - 'handlers': { - 'console': { - 'class': 'logging.StreamHandler', + "version": 1, + "disable_existing_loggers": False, + "handlers": { + "console": { + "class": "logging.StreamHandler", }, }, - 'root': { - 'handlers': ['console'], - 'level': 'WARNING', + "root": { + "handlers": ["console"], + "level": "WARNING", }, } -DEFAULT_FROM_EMAIL = 'DSTFanFooBL - Down Set Talk! Fantasy Football Bundesliga ' -EMAIL_HOST = os.getenv('EMAIL_HOST', 'localhost') -EMAIL_PORT = int(os.getenv('EMAIL_PORT', 25)) -EMAIL_HOST_USER = os.getenv('EMAIL_HOST_USER', '') -EMAIL_HOST_PASSWORD = os.getenv('EMAIL_HOST_PASSWORD', '') +DEFAULT_FROM_EMAIL = "DSTFanFooBL - Down Set Talk! Fantasy Football Bundesliga " +EMAIL_HOST = os.getenv("EMAIL_HOST", "localhost") +EMAIL_PORT = int(os.getenv("EMAIL_PORT", 25)) +EMAIL_HOST_USER = os.getenv("EMAIL_HOST_USER", "") +EMAIL_HOST_PASSWORD = os.getenv("EMAIL_HOST_PASSWORD", "") EMAIL_USE_SSL = True -DST_PATREON_CAMPAIGN_ID = '2708731' - - +DST_PATREON_CAMPAIGN_ID = "2708731" diff --git a/DSTBundesliga/urls.py b/DSTBundesliga/urls.py index fcbd22a..dd2e0e7 100644 --- a/DSTBundesliga/urls.py +++ b/DSTBundesliga/urls.py @@ -9,15 +9,17 @@ admin.autodiscover() urlpatterns = [ - path('', include(('DSTBundesliga.apps.dstffbl.urls', 'dstffbl'), namespace='dstffbl')), - path('auth/', include('django.contrib.auth.urls')), - path('accounts/', include('allauth.urls')), - path('leagues/', include('DSTBundesliga.apps.leagues.urls')), - path('tinymce/', include('tinymce.urls')), - path('admin/', admin.site.urls), - url(r'^shared/', include('filer.urls')), - path('regelwerk/', views.regelwerk), - re_path(r'^', include('cms.urls')), + path( + "", include(("DSTBundesliga.apps.dstffbl.urls", "dstffbl"), namespace="dstffbl") + ), + path("auth/", include("django.contrib.auth.urls")), + path("accounts/", include("allauth.urls")), + path("leagues/", include("DSTBundesliga.apps.leagues.urls")), + path("tinymce/", include("tinymce.urls")), + path("admin/", admin.site.urls), + url(r"^shared/", include("filer.urls")), + path("regelwerk/", views.regelwerk), + re_path(r"^", include("cms.urls")), ] if settings.DEBUG: diff --git a/DSTBundesliga/wsgi.py b/DSTBundesliga/wsgi.py index c29a95e..67441df 100644 --- a/DSTBundesliga/wsgi.py +++ b/DSTBundesliga/wsgi.py @@ -11,6 +11,6 @@ from django.core.wsgi import get_wsgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'DSTBundesliga.settings') +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "DSTBundesliga.settings") application = get_wsgi_application() diff --git a/local_settings_example.py b/local_settings_example.py index 652ff5b..7da9612 100644 --- a/local_settings_example.py +++ b/local_settings_example.py @@ -1,11 +1,11 @@ DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': 'mydatabase', + "default": { + "ENGINE": "django.db.backends.sqlite3", + "NAME": "mydatabase", } } -ALLOWED_HOSTS = ['localhost', '127.0.0.1'] +ALLOWED_HOSTS = ["localhost", "127.0.0.1"] X_FRAME_OPTIONS = "ALLOWALL" XS_SHARING_ALLOWED_METHODS = ["POST", "GET", "OPTIONS", "PUT", "DELETE"] diff --git a/manage.py b/manage.py index 6ff8b43..b4629fc 100755 --- a/manage.py +++ b/manage.py @@ -5,7 +5,7 @@ def main(): - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'DSTBundesliga.settings') + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "DSTBundesliga.settings") try: from django.core.management import execute_from_command_line except ImportError as exc: @@ -17,5 +17,5 @@ def main(): execute_from_command_line(sys.argv) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/poetry.lock b/poetry.lock index 7513ad9..e1da4b2 100644 --- a/poetry.lock +++ b/poetry.lock @@ -73,6 +73,29 @@ category = "main" optional = false python-versions = "*" +[[package]] +name = "black" +version = "23.7.0" +description = "The uncompromising code formatter." +category = "main" +optional = false +python-versions = ">=3.8" + +[package.dependencies] +click = ">=8.0.0" +mypy-extensions = ">=0.4.3" +packaging = ">=22.0" +pathspec = ">=0.9.0" +platformdirs = ">=2" +tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +typing-extensions = {version = ">=3.10.0.0", markers = "python_version < \"3.10\""} + +[package.extras] +colorama = ["colorama (>=0.4.3)"] +d = ["aiohttp (>=3.7.4)"] +jupyter = ["ipython (>=7.8.0)", "tokenize-rt (>=3.2.0)"] +uvloop = ["uvloop (>=0.15.2)"] + [[package]] name = "certifi" version = "2023.7.22" @@ -100,6 +123,17 @@ category = "main" optional = false python-versions = "*" +[[package]] +name = "click" +version = "8.1.6" +description = "Composable command line interface toolkit" +category = "main" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +colorama = {version = "*", markers = "platform_system == \"Windows\""} + [[package]] name = "colorama" version = "0.4.6" @@ -523,6 +557,35 @@ python-versions = ">=3.6" [package.dependencies] sgmllib3k = "*" +[[package]] +name = "flake8" +version = "6.1.0" +description = "the modular source code checker: pep8 pyflakes and co" +category = "main" +optional = false +python-versions = ">=3.8.1" + +[package.dependencies] +mccabe = ">=0.7.0,<0.8.0" +pycodestyle = ">=2.11.0,<2.12.0" +pyflakes = ">=3.1.0,<3.2.0" + +[[package]] +name = "flake8-black" +version = "0.3.6" +description = "flake8 plugin to call black as a code style validator" +category = "dev" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +black = ">=22.1.0" +flake8 = ">=3" +tomli = {version = "*", markers = "python_version < \"3.11\""} + +[package.extras] +develop = ["build", "twine"] + [[package]] name = "html5lib" version = "1.1" @@ -668,6 +731,14 @@ python-versions = ">=3.5" [package.dependencies] traitlets = "*" +[[package]] +name = "mccabe" +version = "0.7.0" +description = "McCabe checker, plugin for flake8" +category = "main" +optional = false +python-versions = ">=3.6" + [[package]] name = "more-itertools" version = "9.1.0" @@ -676,6 +747,14 @@ category = "main" optional = false python-versions = ">=3.7" +[[package]] +name = "mypy-extensions" +version = "1.0.0" +description = "Type system extensions for programs checked with the mypy type checker." +category = "main" +optional = false +python-versions = ">=3.5" + [[package]] name = "oauthlib" version = "3.2.2" @@ -709,6 +788,14 @@ python-versions = ">=3.6" qa = ["flake8 (==3.8.3)", "mypy (==0.782)"] testing = ["docopt", "pytest (<6.0.0)"] +[[package]] +name = "pathspec" +version = "0.11.2" +description = "Utility library for gitignore style pattern matching of file paths." +category = "main" +optional = false +python-versions = ">=3.7" + [[package]] name = "patreon" version = "0.5.0" @@ -751,6 +838,18 @@ python-versions = ">=3.8" docs = ["furo", "olefile", "sphinx (>=2.4)", "sphinx-copybutton", "sphinx-inline-tabs", "sphinx-removed-in", "sphinxext-opengraph"] tests = ["check-manifest", "coverage", "defusedxml", "markdown2", "olefile", "packaging", "pyroma", "pytest", "pytest-cov", "pytest-timeout"] +[[package]] +name = "platformdirs" +version = "3.10.0" +description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." +category = "main" +optional = false +python-versions = ">=3.7" + +[package.extras] +docs = ["furo (>=2023.7.26)", "proselint (>=0.13)", "sphinx-autodoc-typehints (>=1.24)", "sphinx (>=7.1.1)"] +test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest-cov (>=4.1)", "pytest-mock (>=3.11.1)", "pytest (>=7.4)"] + [[package]] name = "pluggy" version = "0.13.1" @@ -800,6 +899,14 @@ category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" +[[package]] +name = "pycodestyle" +version = "2.11.0" +description = "Python style guide checker" +category = "main" +optional = false +python-versions = ">=3.8" + [[package]] name = "pycparser" version = "2.21" @@ -808,6 +915,14 @@ category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +[[package]] +name = "pyflakes" +version = "3.1.0" +description = "passive checker of Python programs" +category = "main" +optional = false +python-versions = ">=3.8" + [[package]] name = "pygments" version = "2.15.1" @@ -1054,6 +1169,14 @@ webencodings = ">=0.4" doc = ["sphinx", "sphinx-rtd-theme"] test = ["pytest", "isort", "flake8"] +[[package]] +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" +category = "main" +optional = false +python-versions = ">=3.7" + [[package]] name = "traitlets" version = "5.9.0" @@ -1137,7 +1260,7 @@ testing = ["pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-ena [metadata] lock-version = "1.1" python-versions = "^3.9" -content-hash = "12d6e19a097b0cfa480e7d601793f513a6ddd29cc0547b266a0db9da7068cf59" +content-hash = "459f6c0a61b1119b9172f7540bda1c253ed83e3a2f1cf22627f32caa39e4c8cd" [metadata.files] appnope = [ @@ -1156,12 +1279,14 @@ backcall = [ {file = "backcall-0.2.0-py2.py3-none-any.whl", hash = "sha256:fbbce6a29f263178a1f7915c1940bde0ec2b2a967566fe1c65c1dfb7422bd255"}, {file = "backcall-0.2.0.tar.gz", hash = "sha256:5cbdbf27be5e7cfadb448baf0aa95508f91f2bbc6c6437cd9cd06e2a4c215e1e"}, ] +black = [] certifi = [] cffi = [] chardet = [ {file = "chardet-3.0.4-py2.py3-none-any.whl", hash = "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691"}, {file = "chardet-3.0.4.tar.gz", hash = "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae"}, ] +click = [] colorama = [] cryptography = [] cssselect2 = [] @@ -1242,6 +1367,8 @@ feedparser = [ {file = "feedparser-6.0.10-py3-none-any.whl", hash = "sha256:79c257d526d13b944e965f6095700587f27388e50ea16fd245babe4dfae7024f"}, {file = "feedparser-6.0.10.tar.gz", hash = "sha256:27da485f4637ce7163cdeab13a80312b93b7d0c1b775bef4a47629a3110bca51"}, ] +flake8 = [] +flake8-black = [] html5lib = [ {file = "html5lib-1.1-py2.py3-none-any.whl", hash = "sha256:0d78f8fde1c230e99fe37986a60526d7049ed4bf8a9fadbad5f00e22e58e041d"}, {file = "html5lib-1.1.tar.gz", hash = "sha256:b2e5b40261e20f354d198eae92afc10d750afb487ed5e50f9c4eaf07c184146f"}, @@ -1263,13 +1390,16 @@ loguru = [ ] lxml = [] matplotlib-inline = [] +mccabe = [] more-itertools = [] +mypy-extensions = [] oauthlib = [] packaging = [] parso = [ {file = "parso-0.8.3-py2.py3-none-any.whl", hash = "sha256:c001d4636cd3aecdaf33cbb40aebb59b094be2a74c556778ef5576c175e19e75"}, {file = "parso-0.8.3.tar.gz", hash = "sha256:8c07be290bb59f03588915921e29e8a50002acaf2cdc5fa0e0114f91709fafa0"}, ] +pathspec = [] patreon = [ {file = "patreon-0.5.0.tar.gz", hash = "sha256:04ad0360e7acc38a85beafa8d44eeeafd3c31d136488aa4de707526163682ca4"}, ] @@ -1282,6 +1412,7 @@ pickleshare = [ {file = "pickleshare-0.7.5.tar.gz", hash = "sha256:87683d47965c1da65cdacaf31c8441d12b8044cdec9aca500cd78fc2c683afca"}, ] pillow = [] +platformdirs = [] pluggy = [ {file = "pluggy-0.13.1-py2.py3-none-any.whl", hash = "sha256:966c145cd83c96502c3c3868f50408687b38434af77734af1e9ca461a4081d2d"}, {file = "pluggy-0.13.1.tar.gz", hash = "sha256:15b2acde666561e1298d71b523007ed7364de07029219b604cf808bfa1c765b0"}, @@ -1299,10 +1430,12 @@ py = [ {file = "py-1.11.0-py2.py3-none-any.whl", hash = "sha256:607c53218732647dff4acdfcd50cb62615cedf612e72d1724fb1a0cc6405b378"}, {file = "py-1.11.0.tar.gz", hash = "sha256:51c75c4126074b472f746a24399ad32f6053d1b34b68d2fa41e558e6f4a98719"}, ] +pycodestyle = [] pycparser = [ {file = "pycparser-2.21-py2.py3-none-any.whl", hash = "sha256:8ee45429555515e1f6b185e78100aea234072576aa43ab53aefcae078162fca9"}, {file = "pycparser-2.21.tar.gz", hash = "sha256:e644fdec12f7872f86c58ff790da456218b10f863970249516d60a5eaca77206"}, ] +pyflakes = [] pygments = [] pyjwt = [] pytest = [ @@ -1347,6 +1480,10 @@ sqlparse = [] stack-data = [] svglib = [] tinycss2 = [] +tomli = [ + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, +] traitlets = [] typing-extensions = [] unidecode = [ diff --git a/pyproject.toml b/pyproject.toml index c935ab9..b9daa39 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,8 +32,12 @@ patreon = "^0.5.0" loguru = "^0.6.0" ipython = "^8.3.0" django-redis = "^5.2.0" +black = "^23.7.0" +flake8 = "^6.1.0" [tool.poetry.dev-dependencies] +flake8 = "^6.1.0" +flake8-black = "^0.3.6" [build-system] requires = ["poetry-core>=1.0.0"]