From b0d56002f336bc2bd0f3a8a3fa214ea1ae5781b4 Mon Sep 17 00:00:00 2001 From: Logan Davidson Date: Sun, 21 Jul 2024 22:14:46 +0100 Subject: [PATCH] Format code files (#520) --- backend/README.md | 2 +- backend/docker-compose.dev.yml | 2 +- backend/docker-compose.test.yml | 6 +- backend/docker-compose.yml | 2 +- backend/manage.py | 5 +- backend/rorapp/admin/concession.py | 1 + backend/rorapp/admin/enemy_leader.py | 11 +- backend/rorapp/admin/player.py | 2 +- backend/rorapp/admin/senator.py | 2 +- backend/rorapp/admin/senator_action_log.py | 2 +- backend/rorapp/admin/step.py | 2 +- backend/rorapp/admin/title.py | 9 +- backend/rorapp/admin/turn.py | 2 +- backend/rorapp/admin/waitlist_entry.py | 2 +- backend/rorapp/apps.py | 4 +- backend/rorapp/functions/concession_helper.py | 3 +- backend/rorapp/functions/game_deleter.py | 2 +- .../functions/mortality_phase_helper.py | 4 +- backend/rorapp/management/__init__.py | 2 +- .../rorapp/management/commands/__init__.py | 2 +- .../rorapp/management/commands/createsu.py | 11 +- backend/rorapp/migrations/0001_initial.py | 18 +- ...n_date_game_description_game_start_date.py | 15 +- backend/rorapp/migrations/0003_game_owner.py | 13 +- ...on_date_alter_game_description_and_more.py | 26 +- .../0005_alter_game_creation_date.py | 7 +- .../migrations/0006_alter_game_start_date.py | 7 +- .../migrations/0007_alter_game_description.py | 11 +- .../0008_alter_game_creation_date.py | 7 +- .../migrations/0009_alter_game_owner.py | 17 +- .../rorapp/migrations/0010_gameparticipant.py | 40 ++- .../migrations/0011_rename_owner_game_host.py | 9 +- .../rorapp/migrations/0012_waitlistentry.py | 19 +- .../0013_alter_waitlistentry_options.py | 7 +- ...tep_familysenator_faction_game_and_more.py | 69 +++-- backend/rorapp/migrations/0015_office.py | 29 ++- ...step_turn_step_potentialaction_and_more.py | 127 ++++++--- backend/rorapp/migrations/0017_phase_index.py | 7 +- ...018_alter_completedaction_type_and_more.py | 11 +- ...ction_completedaction_required_and_more.py | 31 ++- ...ter_completedaction_parameters_and_more.py | 11 +- .../0021_rename_gameparticipant_player.py | 7 +- .../0022_rename_familysenator_senator.py | 7 +- .../migrations/0023_migration_data.json | 240 +++++++++--------- ...enator_knights_senator_loyalty_and_more.py | 46 ++-- .../migrations/0024_rename_office_title.py | 7 +- .../migrations/0025_title_major_office.py | 10 +- ...r_title_end_step_alter_title_start_step.py | 50 ++-- .../rorapp/migrations/0027_notification.py | 38 ++- ...028_senator_alive_alter_senator_faction.py | 18 +- .../migrations/0029_migration_data.json | 40 +-- .../rorapp/migrations/0029_senator_code.py | 15 +- ...0_senator_generation_alter_senator_code.py | 11 +- .../0031_senator_rank_and_faction_rank.py | 102 ++++---- .../0032_change_senator_notification_data.py | 16 +- .../migrations/0033_senatornotification.py | 54 ++-- ...faction_game_alter_player_game_and_more.py | 33 ++- ...senator_death_step_remove_senator_alive.py | 36 +-- .../migrations/0037_dead_senators_faction.py | 24 +- .../0038_potentialaction_completed.py | 8 +- ...ialaction_action_delete_completedaction.py | 9 +- .../0040_temp_rome_consul_influence.py | 2 +- .../0042_assign_prior_consul_titles.py | 13 +- .../migrations/0043_situation_secret.py | 3 +- .../migrations/0044_shuffle_situations.py | 2 +- backend/rorapp/migrations/0045_war.py | 2 +- .../migrations/0046_rename_war_situations.py | 2 +- .../migrations/0047_syrian_war_index.py | 2 +- .../migrations/0048_war_matching_wars.py | 9 +- ...name_naval_defeated_war_undefeated_navy.py | 19 +- backend/rorapp/migrations/0050_enemyleader.py | 41 ++- .../0051_remove_war_matching_wars.py | 7 +- .../0052_alter_enemyleader_current_war.py | 14 +- .../rorapp/migrations/0053_senator_dead.py | 15 +- ...er_enemyleader_dead_alter_senator_alive.py | 11 +- .../migrations/0055_rename_tax_farmer.py | 3 +- ...56_alter_phase_name_alter_game_end_date.py | 11 +- .../0057_actionlog_creation_date.py | 7 +- .../rorapp/migrations/0058_rename_actions.py | 2 +- backend/rorapp/migrations/0059_concession.py | 34 ++- .../migrations/0060_faction_custom_name.py | 7 +- .../0061_remove_new_turn_actionlogs.py | 2 +- backend/rorapp/models/enemy_leader.py | 4 +- backend/rorapp/models/turn.py | 4 +- backend/rorapp/serializers/action.py | 11 +- backend/rorapp/serializers/enemy_leader.py | 13 +- backend/rorapp/serializers/phase.py | 3 +- backend/rorapp/serializers/player.py | 12 +- backend/rorapp/serializers/senator.py | 33 ++- .../rorapp/serializers/senator_action_log.py | 3 +- backend/rorapp/serializers/step.py | 3 +- backend/rorapp/serializers/title.py | 3 +- backend/rorapp/serializers/token.py | 4 +- backend/rorapp/serializers/turn.py | 3 +- backend/rorapp/serializers/user.py | 7 +- backend/rorapp/serializers/waitlist_entry.py | 7 +- backend/rorapp/tests/mortality_chit_tests.py | 2 +- backend/rorapp/views/action_log.py | 28 +- backend/rorapp/views/phase.py | 16 +- backend/rorapp/views/senator.py | 8 +- backend/rorapp/views/senator_action_log.py | 6 +- backend/rorapp/views/step.py | 12 +- backend/rorapp/views/title.py | 16 +- backend/rorapp/views/token.py | 24 +- backend/rorapp/views/turn.py | 10 +- backend/rorapp/views/user.py | 2 +- backend/rorapp/views/waitlist_entry.py | 27 +- backend/rorsite/asgi.py | 9 +- backend/rorsite/wsgi.py | 2 +- backend/server/s3_download.py | 22 +- frontend/classes/Faction.ts | 13 +- frontend/components/AttributeGrid.tsx | 6 +- frontend/components/FactionIcon.tsx | 1 - frontend/components/FactionListItem.tsx | 2 +- frontend/components/Footer.tsx | 4 +- frontend/components/MetaSection.tsx | 7 +- frontend/components/NotificationList.tsx | 7 +- frontend/components/PageError.tsx | 2 +- frontend/components/SenatorSelector.tsx | 6 +- frontend/components/SenatorSelectorItem.tsx | 6 +- frontend/components/ThemeWrapper.tsx | 6 +- .../actionDialogs/FaceMortalityDialog.tsx | 7 +- .../SelectFactionLeaderDialog.tsx | 8 +- .../actionLogs/MatchedWarActionLog.tsx | 17 +- .../actionLogs/NewEnemyLeaderActionLog.tsx | 4 +- .../actionLogs/NewFactionLeaderActionLog.tsx | 3 +- .../actionLogs/PersonalRevenueActionLog.tsx | 10 +- frontend/components/terms/ActiveWarTerm.tsx | 3 +- frontend/components/terms/EnemyLeaderTerm.tsx | 8 +- .../components/terms/FactionPhaseTerm.tsx | 4 +- frontend/components/terms/FamilyTerm.tsx | 4 +- frontend/components/terms/ForumPhaseTerm.tsx | 14 +- frontend/components/terms/ImminentWarTerm.tsx | 5 +- frontend/components/terms/InactiveWarTerm.tsx | 12 +- frontend/components/terms/LoyaltyTerm.tsx | 8 +- frontend/components/terms/MilitaryTerm.tsx | 6 +- .../components/terms/MortalityPhaseTerm.tsx | 10 +- frontend/components/terms/PersonalRevenue.tsx | 9 +- .../components/terms/PopulationPhaseTerm.tsx | 3 +- frontend/components/terms/PriorConsulTerm.tsx | 11 +- .../components/terms/RevenuePhaseTerm.tsx | 7 +- .../components/terms/RevolutionPhaseTerm.tsx | 3 +- frontend/components/terms/TaxFarmerTerm.tsx | 11 +- frontend/components/terms/TurnTerm.tsx | 4 +- .../components/terms/UnalignedSenatorTerm.tsx | 4 +- frontend/contexts/CookieContext.tsx | 11 +- frontend/pages/games/[id]/index.module.css | 4 +- frontend/pages/games/new.tsx | 4 +- frontend/styles/master.css | 2 +- 149 files changed, 1217 insertions(+), 871 deletions(-) diff --git a/backend/README.md b/backend/README.md index 11ed67c3..2413b38b 100644 --- a/backend/README.md +++ b/backend/README.md @@ -1,3 +1,3 @@ ## Backend -Contains the codebase for the Django app, as well as configurations for deploying it to an AWS Elastic Beanstalk Docker container. +Contains the codebase for the Django app, as well as configurations for deploying it to an AWS Elastic Beanstalk Docker container. diff --git a/backend/docker-compose.dev.yml b/backend/docker-compose.dev.yml index 3f958548..265d2cdc 100644 --- a/backend/docker-compose.dev.yml +++ b/backend/docker-compose.dev.yml @@ -8,7 +8,7 @@ services: web: build: . - command: ["/app/server/start.sh"] + command: [ "/app/server/start.sh" ] volumes: - .:/app - static_volume:/app/staticfiles diff --git a/backend/docker-compose.test.yml b/backend/docker-compose.test.yml index 933bd71a..b5e12c88 100644 --- a/backend/docker-compose.test.yml +++ b/backend/docker-compose.test.yml @@ -9,15 +9,15 @@ services: POSTGRES_PASSWORD: postgres ports: - 5432:5432 - + redis: image: redis:5 ports: - 6379:6379 - + web: build: . - command: ["/app/server/start.sh"] + command: [ "/app/server/start.sh" ] volumes: - .:/code - static_volume:/app/staticfiles diff --git a/backend/docker-compose.yml b/backend/docker-compose.yml index d3369765..283642aa 100644 --- a/backend/docker-compose.yml +++ b/backend/docker-compose.yml @@ -8,7 +8,7 @@ services: app: build: . - command: ["/app/server/start_secure.sh"] + command: [ "/app/server/start_secure.sh" ] image: iamlogand/republic-of-rome-online-backend:rorsite-build-${TAG} ports: - "80:80" diff --git a/backend/manage.py b/backend/manage.py index a12fe4a0..915bb2d0 100644 --- a/backend/manage.py +++ b/backend/manage.py @@ -1,12 +1,13 @@ #!/usr/bin/env python """Django's command-line utility for administrative tasks.""" + import os import sys def main(): """Run administrative tasks.""" - os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'rorsite.settings') + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rorsite.settings") try: from django.core.management import execute_from_command_line except ImportError as exc: @@ -18,5 +19,5 @@ def main(): execute_from_command_line(sys.argv) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/backend/rorapp/admin/concession.py b/backend/rorapp/admin/concession.py index d0d62353..eae6a7b9 100644 --- a/backend/rorapp/admin/concession.py +++ b/backend/rorapp/admin/concession.py @@ -1,6 +1,7 @@ from django.contrib import admin from rorapp.models import Concession + # Admin configuration for concessions @admin.register(Concession) class ConcessionAdmin(admin.ModelAdmin): diff --git a/backend/rorapp/admin/enemy_leader.py b/backend/rorapp/admin/enemy_leader.py index 47293290..00f7f8ba 100644 --- a/backend/rorapp/admin/enemy_leader.py +++ b/backend/rorapp/admin/enemy_leader.py @@ -1,7 +1,16 @@ from django.contrib import admin from rorapp.models import EnemyLeader + # Admin configuration for enemy leaders @admin.register(EnemyLeader) class EnemyLeaderAdmin(admin.ModelAdmin): - list_display = ("__str__", "name", "game", "strength", "war_name", "current_war", "dead") + list_display = ( + "__str__", + "name", + "game", + "strength", + "war_name", + "current_war", + "dead", + ) diff --git a/backend/rorapp/admin/player.py b/backend/rorapp/admin/player.py index 1851c2fc..93e5f208 100644 --- a/backend/rorapp/admin/player.py +++ b/backend/rorapp/admin/player.py @@ -5,4 +5,4 @@ # Admin configuration for game players @admin.register(Player) class PlayerAdmin(admin.ModelAdmin): - list_display = ("__str__", 'user', "game", "join_date") + list_display = ("__str__", "user", "game", "join_date") diff --git a/backend/rorapp/admin/senator.py b/backend/rorapp/admin/senator.py index e2e65310..c8d25dd2 100644 --- a/backend/rorapp/admin/senator.py +++ b/backend/rorapp/admin/senator.py @@ -36,4 +36,4 @@ class SenatorAdmin(admin.ModelAdmin): inlines = [TitleInline] def title_count(self, obj): - return obj.titles.annotate(num_titles=Count('id')).count() + return obj.titles.annotate(num_titles=Count("id")).count() diff --git a/backend/rorapp/admin/senator_action_log.py b/backend/rorapp/admin/senator_action_log.py index 82c7b7a6..35e381ca 100644 --- a/backend/rorapp/admin/senator_action_log.py +++ b/backend/rorapp/admin/senator_action_log.py @@ -5,4 +5,4 @@ # Admin configuration for action_logs @admin.register(SenatorActionLog) class SenatorActionLogAdmin(admin.ModelAdmin): - list_display = ("__str__", 'senator', 'action_log') + list_display = ("__str__", "senator", "action_log") diff --git a/backend/rorapp/admin/step.py b/backend/rorapp/admin/step.py index e7557de8..0b291ef2 100644 --- a/backend/rorapp/admin/step.py +++ b/backend/rorapp/admin/step.py @@ -5,4 +5,4 @@ # Admin configuration for steps @admin.register(Step) class StepAdmin(admin.ModelAdmin): - list_display = ("__str__", 'index', 'phase') + list_display = ("__str__", "index", "phase") diff --git a/backend/rorapp/admin/title.py b/backend/rorapp/admin/title.py index 7c399f63..87dfd68f 100644 --- a/backend/rorapp/admin/title.py +++ b/backend/rorapp/admin/title.py @@ -5,4 +5,11 @@ # Admin configuration for titles @admin.register(Title) class TitleAdmin(admin.ModelAdmin): - list_display = ("__str__", 'name', "senator", "start_step", "end_step", 'major_office') + list_display = ( + "__str__", + "name", + "senator", + "start_step", + "end_step", + "major_office", + ) diff --git a/backend/rorapp/admin/turn.py b/backend/rorapp/admin/turn.py index f7f8a727..37be6a63 100644 --- a/backend/rorapp/admin/turn.py +++ b/backend/rorapp/admin/turn.py @@ -5,4 +5,4 @@ # Admin configuration for turns @admin.register(Turn) class TurnAdmin(admin.ModelAdmin): - list_display = ("__str__", 'index', 'game') + list_display = ("__str__", "index", "game") diff --git a/backend/rorapp/admin/waitlist_entry.py b/backend/rorapp/admin/waitlist_entry.py index 9d81362b..2a3472dd 100644 --- a/backend/rorapp/admin/waitlist_entry.py +++ b/backend/rorapp/admin/waitlist_entry.py @@ -5,4 +5,4 @@ # Admin configuration for waitlist entries @admin.register(WaitlistEntry) class WaitlistEntryAdmin(admin.ModelAdmin): - list_display = ("__str__", "email", "entry_date") + list_display = ("__str__", "email", "entry_date") diff --git a/backend/rorapp/apps.py b/backend/rorapp/apps.py index 31e6f93b..5baff4ca 100644 --- a/backend/rorapp/apps.py +++ b/backend/rorapp/apps.py @@ -2,5 +2,5 @@ class RorappConfig(AppConfig): - default_auto_field = 'django.db.models.BigAutoField' - name = 'rorapp' + default_auto_field = "django.db.models.BigAutoField" + name = "rorapp" diff --git a/backend/rorapp/functions/concession_helper.py b/backend/rorapp/functions/concession_helper.py index 187414c4..541398cd 100644 --- a/backend/rorapp/functions/concession_helper.py +++ b/backend/rorapp/functions/concession_helper.py @@ -38,7 +38,7 @@ def generate_assign_concessions_action( if faction is None: faction = Faction.objects.filter(game__id=game_id).order_by("rank").first() - + if not isinstance(faction, Faction): raise ValueError("Couldn't find a faction") @@ -102,7 +102,6 @@ def assign_concessions(action_id: int, data: dict) -> tuple[Response, List[dict] """ messages_to_send = [] - # The action and faction IDs are known to be valid action = Action.objects.get(id=action_id) diff --git a/backend/rorapp/functions/game_deleter.py b/backend/rorapp/functions/game_deleter.py index 670a546b..4321513f 100644 --- a/backend/rorapp/functions/game_deleter.py +++ b/backend/rorapp/functions/game_deleter.py @@ -8,7 +8,7 @@ def delete_all_games() -> int: Returns: int: The number of games that were deleted. """ - + games = Game.objects.all() count = games.count() games.delete() diff --git a/backend/rorapp/functions/mortality_phase_helper.py b/backend/rorapp/functions/mortality_phase_helper.py index ac9200ca..317f6fdd 100644 --- a/backend/rorapp/functions/mortality_phase_helper.py +++ b/backend/rorapp/functions/mortality_phase_helper.py @@ -204,9 +204,7 @@ def resolve_mortality(game_id: int, chit_codes: List[int] | None = None) -> List .index + 1 ) - action_log = ActionLog( - index=new_action_log_index, step=step, type="mortality" - ) + action_log = ActionLog(index=new_action_log_index, step=step, type="mortality") action_log.save() messages_to_send.append( create_websocket_message("action_log", ActionLogSerializer(action_log).data) diff --git a/backend/rorapp/management/__init__.py b/backend/rorapp/management/__init__.py index ee02175d..5faa8340 100644 --- a/backend/rorapp/management/__init__.py +++ b/backend/rorapp/management/__init__.py @@ -1 +1 @@ -from .commands import Command # noqa: F401 \ No newline at end of file +from .commands import Command # noqa: F401 diff --git a/backend/rorapp/management/commands/__init__.py b/backend/rorapp/management/commands/__init__.py index a67b3e13..240b2ed6 100644 --- a/backend/rorapp/management/commands/__init__.py +++ b/backend/rorapp/management/commands/__init__.py @@ -1 +1 @@ -from .createsu import Command \ No newline at end of file +from .createsu import Command diff --git a/backend/rorapp/management/commands/createsu.py b/backend/rorapp/management/commands/createsu.py index 7b88b240..4edfb1e6 100644 --- a/backend/rorapp/management/commands/createsu.py +++ b/backend/rorapp/management/commands/createsu.py @@ -3,12 +3,9 @@ class Command(BaseCommand): - help = 'Creates a superuser.' + help = "Creates a superuser." def handle(self, *args, **options): - if not User.objects.filter(username='tempsuperuser').exists(): - User.objects.create_superuser( - username='tempsuperuser', - password='password' - ) - print('Superuser has been created.') \ No newline at end of file + if not User.objects.filter(username="tempsuperuser").exists(): + User.objects.create_superuser(username="tempsuperuser", password="password") + print("Superuser has been created.") diff --git a/backend/rorapp/migrations/0001_initial.py b/backend/rorapp/migrations/0001_initial.py index 44b93788..7959c1b0 100644 --- a/backend/rorapp/migrations/0001_initial.py +++ b/backend/rorapp/migrations/0001_initial.py @@ -4,18 +4,24 @@ class Migration(migrations.Migration): - initial = True - dependencies = [ - ] + dependencies = [] operations = [ migrations.CreateModel( - name='Game', + name="Game", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=50, unique=True)), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("name", models.CharField(max_length=50, unique=True)), ], ), ] diff --git a/backend/rorapp/migrations/0002_game_creation_date_game_description_game_start_date.py b/backend/rorapp/migrations/0002_game_creation_date_game_description_game_start_date.py index 10a8499e..a29d5f7b 100644 --- a/backend/rorapp/migrations/0002_game_creation_date_game_description_game_start_date.py +++ b/backend/rorapp/migrations/0002_game_creation_date_game_description_game_start_date.py @@ -4,25 +4,24 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0001_initial'), + ("rorapp", "0001_initial"), ] operations = [ migrations.AddField( - model_name='game', - name='creation_date', + model_name="game", + name="creation_date", field=models.DateField(null=True), ), migrations.AddField( - model_name='game', - name='description', + model_name="game", + name="description", field=models.TextField(null=True), ), migrations.AddField( - model_name='game', - name='start_date', + model_name="game", + name="start_date", field=models.DateField(null=True), ), ] diff --git a/backend/rorapp/migrations/0003_game_owner.py b/backend/rorapp/migrations/0003_game_owner.py index 2ec90a83..fa8248f1 100644 --- a/backend/rorapp/migrations/0003_game_owner.py +++ b/backend/rorapp/migrations/0003_game_owner.py @@ -6,16 +6,19 @@ class Migration(migrations.Migration): - dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('rorapp', '0002_game_creation_date_game_description_game_start_date'), + ("rorapp", "0002_game_creation_date_game_description_game_start_date"), ] operations = [ migrations.AddField( - model_name='game', - name='owner', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL), + model_name="game", + name="owner", + field=models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.DO_NOTHING, + to=settings.AUTH_USER_MODEL, + ), ), ] diff --git a/backend/rorapp/migrations/0004_alter_game_creation_date_alter_game_description_and_more.py b/backend/rorapp/migrations/0004_alter_game_creation_date_alter_game_description_and_more.py index be91efe5..30d36c9a 100644 --- a/backend/rorapp/migrations/0004_alter_game_creation_date_alter_game_description_and_more.py +++ b/backend/rorapp/migrations/0004_alter_game_creation_date_alter_game_description_and_more.py @@ -6,31 +6,35 @@ class Migration(migrations.Migration): - dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('rorapp', '0003_game_owner'), + ("rorapp", "0003_game_owner"), ] operations = [ migrations.AlterField( - model_name='game', - name='creation_date', + model_name="game", + name="creation_date", field=models.DateField(blank=True, null=True), ), migrations.AlterField( - model_name='game', - name='description', + model_name="game", + name="description", field=models.TextField(blank=True, null=True), ), migrations.AlterField( - model_name='game', - name='owner', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL), + model_name="game", + name="owner", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.DO_NOTHING, + to=settings.AUTH_USER_MODEL, + ), ), migrations.AlterField( - model_name='game', - name='start_date', + model_name="game", + name="start_date", field=models.DateField(blank=True, null=True), ), ] diff --git a/backend/rorapp/migrations/0005_alter_game_creation_date.py b/backend/rorapp/migrations/0005_alter_game_creation_date.py index f864a694..fe69aadc 100644 --- a/backend/rorapp/migrations/0005_alter_game_creation_date.py +++ b/backend/rorapp/migrations/0005_alter_game_creation_date.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0004_alter_game_creation_date_alter_game_description_and_more'), + ("rorapp", "0004_alter_game_creation_date_alter_game_description_and_more"), ] operations = [ migrations.AlterField( - model_name='game', - name='creation_date', + model_name="game", + name="creation_date", field=models.DateTimeField(blank=True, null=True), ), ] diff --git a/backend/rorapp/migrations/0006_alter_game_start_date.py b/backend/rorapp/migrations/0006_alter_game_start_date.py index 935e40ea..4e0a3f1b 100644 --- a/backend/rorapp/migrations/0006_alter_game_start_date.py +++ b/backend/rorapp/migrations/0006_alter_game_start_date.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0005_alter_game_creation_date'), + ("rorapp", "0005_alter_game_creation_date"), ] operations = [ migrations.AlterField( - model_name='game', - name='start_date', + model_name="game", + name="start_date", field=models.DateTimeField(blank=True, null=True), ), ] diff --git a/backend/rorapp/migrations/0007_alter_game_description.py b/backend/rorapp/migrations/0007_alter_game_description.py index a3d02d90..dbe6d162 100644 --- a/backend/rorapp/migrations/0007_alter_game_description.py +++ b/backend/rorapp/migrations/0007_alter_game_description.py @@ -4,23 +4,24 @@ from django.db import migrations, models from django.db.migrations.operations import RunPython + def shorten_description(apps, schema_editor): - Game = apps.get_model('rorapp', 'game') + Game = apps.get_model("rorapp", "game") for game in Game.objects.all(): game.description = game.description[:1000] game.save() -class Migration(migrations.Migration): +class Migration(migrations.Migration): dependencies = [ - ('rorapp', '0006_alter_game_start_date'), + ("rorapp", "0006_alter_game_start_date"), ] operations = [ RunPython(shorten_description), migrations.AlterField( - model_name='game', - name='description', + model_name="game", + name="description", field=models.CharField(blank=True, max_length=1000, null=True), ), ] diff --git a/backend/rorapp/migrations/0008_alter_game_creation_date.py b/backend/rorapp/migrations/0008_alter_game_creation_date.py index 3f68364c..af9ed57e 100644 --- a/backend/rorapp/migrations/0008_alter_game_creation_date.py +++ b/backend/rorapp/migrations/0008_alter_game_creation_date.py @@ -5,15 +5,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0007_alter_game_description'), + ("rorapp", "0007_alter_game_description"), ] operations = [ migrations.AlterField( - model_name='game', - name='creation_date', + model_name="game", + name="creation_date", field=models.DateTimeField(default=django.utils.timezone.now), ), ] diff --git a/backend/rorapp/migrations/0009_alter_game_owner.py b/backend/rorapp/migrations/0009_alter_game_owner.py index d3bc82a5..36dda460 100644 --- a/backend/rorapp/migrations/0009_alter_game_owner.py +++ b/backend/rorapp/migrations/0009_alter_game_owner.py @@ -7,22 +7,23 @@ def delete_games_without_owner(apps, schema_editor): - Game = apps.get_model('rorapp', 'Game') + Game = apps.get_model("rorapp", "Game") Game.objects.filter(owner=None).delete() - - -class Migration(migrations.Migration): + +class Migration(migrations.Migration): dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('rorapp', '0008_alter_game_creation_date'), + ("rorapp", "0008_alter_game_creation_date"), ] operations = [ migrations.RunPython(delete_games_without_owner), migrations.AlterField( - model_name='game', - name='owner', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + model_name="game", + name="owner", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL + ), ), ] diff --git a/backend/rorapp/migrations/0010_gameparticipant.py b/backend/rorapp/migrations/0010_gameparticipant.py index fe3226b9..ccc829f8 100644 --- a/backend/rorapp/migrations/0010_gameparticipant.py +++ b/backend/rorapp/migrations/0010_gameparticipant.py @@ -7,29 +7,49 @@ def create_game_participants_for_owners(apps, schema_editor): - Game = apps.get_model('rorapp', 'Game') - GameParticipant = apps.get_model('rorapp', 'GameParticipant') + Game = apps.get_model("rorapp", "Game") + GameParticipant = apps.get_model("rorapp", "GameParticipant") for game in Game.objects.all(): - game_participant = GameParticipant(user=game.owner, game=game, join_date=game.creation_date) + game_participant = GameParticipant( + user=game.owner, game=game, join_date=game.creation_date + ) game_participant.save() class Migration(migrations.Migration): - dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('rorapp', '0009_alter_game_owner'), + ("rorapp", "0009_alter_game_owner"), ] operations = [ migrations.CreateModel( - name='GameParticipant', + name="GameParticipant", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('join_date', models.DateTimeField(default=django.utils.timezone.now)), - ('game', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rorapp.game')), - ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("join_date", models.DateTimeField(default=django.utils.timezone.now)), + ( + "game", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="rorapp.game" + ), + ), + ( + "user", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to=settings.AUTH_USER_MODEL, + ), + ), ], ), migrations.RunPython(create_game_participants_for_owners), diff --git a/backend/rorapp/migrations/0011_rename_owner_game_host.py b/backend/rorapp/migrations/0011_rename_owner_game_host.py index f6eb9cb5..771ef494 100644 --- a/backend/rorapp/migrations/0011_rename_owner_game_host.py +++ b/backend/rorapp/migrations/0011_rename_owner_game_host.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0010_gameparticipant'), + ("rorapp", "0010_gameparticipant"), ] operations = [ migrations.RenameField( - model_name='game', - old_name='owner', - new_name='host', + model_name="game", + old_name="owner", + new_name="host", ), ] diff --git a/backend/rorapp/migrations/0012_waitlistentry.py b/backend/rorapp/migrations/0012_waitlistentry.py index b226e601..e74f64ca 100644 --- a/backend/rorapp/migrations/0012_waitlistentry.py +++ b/backend/rorapp/migrations/0012_waitlistentry.py @@ -5,18 +5,25 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0011_rename_owner_game_host'), + ("rorapp", "0011_rename_owner_game_host"), ] operations = [ migrations.CreateModel( - name='WaitlistEntry', + name="WaitlistEntry", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('email', models.EmailField(max_length=254, unique=True)), - ('entry_date', models.DateTimeField(default=django.utils.timezone.now)), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("email", models.EmailField(max_length=254, unique=True)), + ("entry_date", models.DateTimeField(default=django.utils.timezone.now)), ], ), ] diff --git a/backend/rorapp/migrations/0013_alter_waitlistentry_options.py b/backend/rorapp/migrations/0013_alter_waitlistentry_options.py index 3db1d113..767ef168 100644 --- a/backend/rorapp/migrations/0013_alter_waitlistentry_options.py +++ b/backend/rorapp/migrations/0013_alter_waitlistentry_options.py @@ -4,14 +4,13 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0012_waitlistentry'), + ("rorapp", "0012_waitlistentry"), ] operations = [ migrations.AlterModelOptions( - name='waitlistentry', - options={'verbose_name_plural': 'waitlist entries'}, + name="waitlistentry", + options={"verbose_name_plural": "waitlist entries"}, ), ] diff --git a/backend/rorapp/migrations/0014_faction_game_step_familysenator_faction_game_and_more.py b/backend/rorapp/migrations/0014_faction_game_step_familysenator_faction_game_and_more.py index 25422fae..43f0fedc 100644 --- a/backend/rorapp/migrations/0014_faction_game_step_familysenator_faction_game_and_more.py +++ b/backend/rorapp/migrations/0014_faction_game_step_familysenator_faction_game_and_more.py @@ -5,41 +5,74 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0013_alter_waitlistentry_options'), + ("rorapp", "0013_alter_waitlistentry_options"), ] operations = [ migrations.CreateModel( - name='Faction', + name="Faction", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('position', models.IntegerField()), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("position", models.IntegerField()), ], ), migrations.AddField( - model_name='game', - name='step', + model_name="game", + name="step", field=models.PositiveIntegerField(default=0), ), migrations.CreateModel( - name='FamilySenator', + name="FamilySenator", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=10)), - ('faction', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='rorapp.faction')), - ('game', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rorapp.game')), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("name", models.CharField(max_length=10)), + ( + "faction", + models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.SET_NULL, + to="rorapp.faction", + ), + ), + ( + "game", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="rorapp.game" + ), + ), ], ), migrations.AddField( - model_name='faction', - name='game', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rorapp.game'), + model_name="faction", + name="game", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="rorapp.game" + ), ), migrations.AddField( - model_name='faction', - name='player', - field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='rorapp.gameparticipant'), + model_name="faction", + name="player", + field=models.ForeignKey( + null=True, + on_delete=django.db.models.deletion.SET_NULL, + to="rorapp.gameparticipant", + ), ), ] diff --git a/backend/rorapp/migrations/0015_office.py b/backend/rorapp/migrations/0015_office.py index a7fcebb9..d648ca90 100644 --- a/backend/rorapp/migrations/0015_office.py +++ b/backend/rorapp/migrations/0015_office.py @@ -5,20 +5,33 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0014_faction_game_step_familysenator_faction_game_and_more'), + ("rorapp", "0014_faction_game_step_familysenator_faction_game_and_more"), ] operations = [ migrations.CreateModel( - name='Office', + name="Office", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=21)), - ('start_step', models.IntegerField()), - ('end_step', models.IntegerField(blank=True, null=True)), - ('senator', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rorapp.familysenator')), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("name", models.CharField(max_length=21)), + ("start_step", models.IntegerField()), + ("end_step", models.IntegerField(blank=True, null=True)), + ( + "senator", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="rorapp.familysenator", + ), + ), ], ), ] diff --git a/backend/rorapp/migrations/0016_phase_remove_game_step_turn_step_potentialaction_and_more.py b/backend/rorapp/migrations/0016_phase_remove_game_step_turn_step_potentialaction_and_more.py index 074af1ac..0903fd63 100644 --- a/backend/rorapp/migrations/0016_phase_remove_game_step_turn_step_potentialaction_and_more.py +++ b/backend/rorapp/migrations/0016_phase_remove_game_step_turn_step_potentialaction_and_more.py @@ -9,10 +9,10 @@ # The simplest way to manage this without deleting all games is to revert all existing games # to a not yet started state. def delete_instances_and_set_null(apps, schema_editor): - Faction = apps.get_model('rorapp', 'Faction') - FamilySenator = apps.get_model('rorapp', 'FamilySenator') - Office = apps.get_model('rorapp', 'Office') - Game = apps.get_model('rorapp', 'Game') + Faction = apps.get_model("rorapp", "Faction") + FamilySenator = apps.get_model("rorapp", "FamilySenator") + Office = apps.get_model("rorapp", "Office") + Game = apps.get_model("rorapp", "Game") Faction.objects.all().delete() FamilySenator.objects.all().delete() @@ -21,61 +21,122 @@ def delete_instances_and_set_null(apps, schema_editor): class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0015_office'), + ("rorapp", "0015_office"), ] operations = [ migrations.CreateModel( - name='Phase', + name="Phase", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=10)), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("name", models.CharField(max_length=10)), ], ), migrations.RemoveField( - model_name='game', - name='step', + model_name="game", + name="step", ), migrations.CreateModel( - name='Turn', + name="Turn", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('index', models.PositiveIntegerField()), - ('game', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rorapp.game')), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("index", models.PositiveIntegerField()), + ( + "game", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="rorapp.game" + ), + ), ], ), migrations.CreateModel( - name='Step', + name="Step", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('index', models.PositiveIntegerField()), - ('phase', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rorapp.phase')), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("index", models.PositiveIntegerField()), + ( + "phase", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="rorapp.phase" + ), + ), ], ), migrations.CreateModel( - name='PotentialAction', + name="PotentialAction", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('type', models.PositiveIntegerField()), - ('parameters', models.JSONField()), - ('step', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rorapp.step')), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("type", models.PositiveIntegerField()), + ("parameters", models.JSONField()), + ( + "step", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="rorapp.step" + ), + ), ], ), migrations.AddField( - model_name='phase', - name='turn', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rorapp.turn'), + model_name="phase", + name="turn", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="rorapp.turn" + ), ), migrations.CreateModel( - name='CompletedAction', + name="CompletedAction", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('type', models.PositiveIntegerField()), - ('parameters', models.JSONField()), - ('step', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rorapp.step')), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("type", models.PositiveIntegerField()), + ("parameters", models.JSONField()), + ( + "step", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="rorapp.step" + ), + ), ], ), - migrations.RunPython(delete_instances_and_set_null, migrations.RunPython.noop) + migrations.RunPython(delete_instances_and_set_null, migrations.RunPython.noop), ] diff --git a/backend/rorapp/migrations/0017_phase_index.py b/backend/rorapp/migrations/0017_phase_index.py index e10b6ac9..d542202e 100644 --- a/backend/rorapp/migrations/0017_phase_index.py +++ b/backend/rorapp/migrations/0017_phase_index.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0016_phase_remove_game_step_turn_step_potentialaction_and_more'), + ("rorapp", "0016_phase_remove_game_step_turn_step_potentialaction_and_more"), ] operations = [ migrations.AddField( - model_name='phase', - name='index', + model_name="phase", + name="index", field=models.PositiveIntegerField(default=0), preserve_default=False, ), diff --git a/backend/rorapp/migrations/0018_alter_completedaction_type_and_more.py b/backend/rorapp/migrations/0018_alter_completedaction_type_and_more.py index 07668af1..445fbd86 100644 --- a/backend/rorapp/migrations/0018_alter_completedaction_type_and_more.py +++ b/backend/rorapp/migrations/0018_alter_completedaction_type_and_more.py @@ -4,20 +4,19 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0017_phase_index'), + ("rorapp", "0017_phase_index"), ] operations = [ migrations.AlterField( - model_name='completedaction', - name='type', + model_name="completedaction", + name="type", field=models.CharField(max_length=50), ), migrations.AlterField( - model_name='potentialaction', - name='type', + model_name="potentialaction", + name="type", field=models.CharField(max_length=50), ), ] diff --git a/backend/rorapp/migrations/0019_completedaction_faction_completedaction_required_and_more.py b/backend/rorapp/migrations/0019_completedaction_faction_completedaction_required_and_more.py index f8e1cd1a..fa3a451c 100644 --- a/backend/rorapp/migrations/0019_completedaction_faction_completedaction_required_and_more.py +++ b/backend/rorapp/migrations/0019_completedaction_faction_completedaction_required_and_more.py @@ -5,33 +5,40 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0018_alter_completedaction_type_and_more'), + ("rorapp", "0018_alter_completedaction_type_and_more"), ] operations = [ migrations.AddField( - model_name='completedaction', - name='faction', - field=models.ForeignKey(default=0, on_delete=django.db.models.deletion.CASCADE, to='rorapp.faction'), + model_name="completedaction", + name="faction", + field=models.ForeignKey( + default=0, + on_delete=django.db.models.deletion.CASCADE, + to="rorapp.faction", + ), preserve_default=False, ), migrations.AddField( - model_name='completedaction', - name='required', + model_name="completedaction", + name="required", field=models.BooleanField(default=True), preserve_default=False, ), migrations.AddField( - model_name='potentialaction', - name='faction', - field=models.ForeignKey(default=0, on_delete=django.db.models.deletion.CASCADE, to='rorapp.faction'), + model_name="potentialaction", + name="faction", + field=models.ForeignKey( + default=0, + on_delete=django.db.models.deletion.CASCADE, + to="rorapp.faction", + ), preserve_default=False, ), migrations.AddField( - model_name='potentialaction', - name='required', + model_name="potentialaction", + name="required", field=models.BooleanField(default=True), preserve_default=False, ), diff --git a/backend/rorapp/migrations/0020_alter_completedaction_parameters_and_more.py b/backend/rorapp/migrations/0020_alter_completedaction_parameters_and_more.py index 5e47f586..a1b7a376 100644 --- a/backend/rorapp/migrations/0020_alter_completedaction_parameters_and_more.py +++ b/backend/rorapp/migrations/0020_alter_completedaction_parameters_and_more.py @@ -4,20 +4,19 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0019_completedaction_faction_completedaction_required_and_more'), + ("rorapp", "0019_completedaction_faction_completedaction_required_and_more"), ] operations = [ migrations.AlterField( - model_name='completedaction', - name='parameters', + model_name="completedaction", + name="parameters", field=models.JSONField(blank=True, null=True), ), migrations.AlterField( - model_name='potentialaction', - name='parameters', + model_name="potentialaction", + name="parameters", field=models.JSONField(blank=True, null=True), ), ] diff --git a/backend/rorapp/migrations/0021_rename_gameparticipant_player.py b/backend/rorapp/migrations/0021_rename_gameparticipant_player.py index f0b61950..dad0d776 100644 --- a/backend/rorapp/migrations/0021_rename_gameparticipant_player.py +++ b/backend/rorapp/migrations/0021_rename_gameparticipant_player.py @@ -5,15 +5,14 @@ class Migration(migrations.Migration): - dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), - ('rorapp', '0020_alter_completedaction_parameters_and_more'), + ("rorapp", "0020_alter_completedaction_parameters_and_more"), ] operations = [ migrations.RenameModel( - old_name='GameParticipant', - new_name='Player', + old_name="GameParticipant", + new_name="Player", ), ] diff --git a/backend/rorapp/migrations/0022_rename_familysenator_senator.py b/backend/rorapp/migrations/0022_rename_familysenator_senator.py index b094bcb5..b3470af8 100644 --- a/backend/rorapp/migrations/0022_rename_familysenator_senator.py +++ b/backend/rorapp/migrations/0022_rename_familysenator_senator.py @@ -4,14 +4,13 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0021_rename_gameparticipant_player'), + ("rorapp", "0021_rename_gameparticipant_player"), ] operations = [ migrations.RenameModel( - old_name='FamilySenator', - new_name='Senator', + old_name="FamilySenator", + new_name="Senator", ), ] diff --git a/backend/rorapp/migrations/0023_migration_data.json b/backend/rorapp/migrations/0023_migration_data.json index 92c3b243..00b03f4e 100644 --- a/backend/rorapp/migrations/0023_migration_data.json +++ b/backend/rorapp/migrations/0023_migration_data.json @@ -1,122 +1,122 @@ { - "Cornelius" : { - "military": 4, - "oratory": 3, - "loyalty": 9, - "influence": 5 - }, - "Fabius" : { - "military": 4, - "oratory": 2, - "loyalty": 9, - "influence": 5 - }, - "Valerius" : { - "military": 1, - "oratory": 2, - "loyalty": 10, - "influence": 5 - }, - "Julius" : { - "military": 4, - "oratory": 3, - "loyalty": 9, - "influence": 4 - }, - "Claudius" : { - "military": 2, - "oratory": 3, - "loyalty": 7, - "influence": 4 - }, - "Manlius" : { - "military": 3, - "oratory": 2, - "loyalty": 7, - "influence": 4 - }, - "Fulvius" : { - "military": 2, - "oratory": 2, - "loyalty": 8, - "influence": 4 - }, - "Furius" : { - "military": 3, - "oratory": 3, - "loyalty": 8, - "influence": 3 - }, - "Aurelius" : { - "military": 2, - "oratory": 3, - "loyalty": 7, - "influence": 3 - }, - "Junius" : { - "military": 1, - "oratory": 2, - "loyalty": 8, - "influence": 3 - }, - "Papirius" : { - "military": 1, - "oratory": 2, - "loyalty": 6, - "influence": 3 - }, - "Acilius" : { - "military": 2, - "oratory": 2, - "loyalty": 7, - "influence": 3 - }, - "Flaminius" : { - "military": 4, - "oratory": 2, - "loyalty": 6, - "influence": 3 - }, - "Aelius" : { - "military": 3, - "oratory": 4, - "loyalty": 7, - "influence": 2 - }, - "Sulpicius" : { - "military": 3, - "oratory": 2, - "loyalty": 8, - "influence": 2 - }, - "Calpurnius" : { - "military": 1, - "oratory": 2, - "loyalty": 9, - "influence": 2 - }, - "Plautius" : { - "military": 2, - "oratory": 1, - "loyalty": 6, - "influence": 2 - }, - "Quinctius" : { - "military": 3, - "oratory": 2, - "loyalty": 6, - "influence": 1 - }, - "Aemilius" : { - "military": 4, - "oratory": 2, - "loyalty": 8, - "influence": 1 - }, - "Terentius" : { - "military": 2, - "oratory": 1, - "loyalty": 6, - "influence": 1 - } + "Cornelius": { + "military": 4, + "oratory": 3, + "loyalty": 9, + "influence": 5 + }, + "Fabius": { + "military": 4, + "oratory": 2, + "loyalty": 9, + "influence": 5 + }, + "Valerius": { + "military": 1, + "oratory": 2, + "loyalty": 10, + "influence": 5 + }, + "Julius": { + "military": 4, + "oratory": 3, + "loyalty": 9, + "influence": 4 + }, + "Claudius": { + "military": 2, + "oratory": 3, + "loyalty": 7, + "influence": 4 + }, + "Manlius": { + "military": 3, + "oratory": 2, + "loyalty": 7, + "influence": 4 + }, + "Fulvius": { + "military": 2, + "oratory": 2, + "loyalty": 8, + "influence": 4 + }, + "Furius": { + "military": 3, + "oratory": 3, + "loyalty": 8, + "influence": 3 + }, + "Aurelius": { + "military": 2, + "oratory": 3, + "loyalty": 7, + "influence": 3 + }, + "Junius": { + "military": 1, + "oratory": 2, + "loyalty": 8, + "influence": 3 + }, + "Papirius": { + "military": 1, + "oratory": 2, + "loyalty": 6, + "influence": 3 + }, + "Acilius": { + "military": 2, + "oratory": 2, + "loyalty": 7, + "influence": 3 + }, + "Flaminius": { + "military": 4, + "oratory": 2, + "loyalty": 6, + "influence": 3 + }, + "Aelius": { + "military": 3, + "oratory": 4, + "loyalty": 7, + "influence": 2 + }, + "Sulpicius": { + "military": 3, + "oratory": 2, + "loyalty": 8, + "influence": 2 + }, + "Calpurnius": { + "military": 1, + "oratory": 2, + "loyalty": 9, + "influence": 2 + }, + "Plautius": { + "military": 2, + "oratory": 1, + "loyalty": 6, + "influence": 2 + }, + "Quinctius": { + "military": 3, + "oratory": 2, + "loyalty": 6, + "influence": 1 + }, + "Aemilius": { + "military": 4, + "oratory": 2, + "loyalty": 8, + "influence": 1 + }, + "Terentius": { + "military": 2, + "oratory": 1, + "loyalty": 6, + "influence": 1 + } } diff --git a/backend/rorapp/migrations/0023_senator_influence_senator_knights_senator_loyalty_and_more.py b/backend/rorapp/migrations/0023_senator_influence_senator_knights_senator_loyalty_and_more.py index 01b2897f..aacd0a0e 100644 --- a/backend/rorapp/migrations/0023_senator_influence_senator_knights_senator_loyalty_and_more.py +++ b/backend/rorapp/migrations/0023_senator_influence_senator_knights_senator_loyalty_and_more.py @@ -6,68 +6,68 @@ import json from pathlib import Path + # This migration adds senator attributes. # The temporary default values for these attributes are loaded from a JSON file. def load_data(apps, schema_editor): - Senator = apps.get_model('rorapp', 'Senator') - - with open(Path(__file__).resolve().parent / '0023_migration_data.json') as f: + Senator = apps.get_model("rorapp", "Senator") + + with open(Path(__file__).resolve().parent / "0023_migration_data.json") as f: data = json.load(f) for name, attributes in data.items(): senators = Senator.objects.filter(name=name) for senator in senators: - senator.military = attributes['military'] - senator.oratory = attributes['oratory'] - senator.loyalty = attributes['loyalty'] - senator.influence = attributes['influence'] + senator.military = attributes["military"] + senator.oratory = attributes["oratory"] + senator.loyalty = attributes["loyalty"] + senator.influence = attributes["influence"] senator.save() class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0022_rename_familysenator_senator'), + ("rorapp", "0022_rename_familysenator_senator"), ] operations = [ migrations.AddField( - model_name='senator', - name='influence', + model_name="senator", + name="influence", field=models.IntegerField(default=1), preserve_default=False, ), migrations.AddField( - model_name='senator', - name='knights', + model_name="senator", + name="knights", field=models.IntegerField(default=0), ), migrations.AddField( - model_name='senator', - name='loyalty', + model_name="senator", + name="loyalty", field=models.IntegerField(default=1), preserve_default=False, ), migrations.AddField( - model_name='senator', - name='military', + model_name="senator", + name="military", field=models.IntegerField(default=1), preserve_default=False, ), migrations.AddField( - model_name='senator', - name='oratory', + model_name="senator", + name="oratory", field=models.IntegerField(default=1), preserve_default=False, ), migrations.AddField( - model_name='senator', - name='popularity', + model_name="senator", + name="popularity", field=models.IntegerField(default=0), ), migrations.AddField( - model_name='senator', - name='talents', + model_name="senator", + name="talents", field=models.IntegerField(default=0), ), migrations.RunPython(load_data, migrations.RunPython.noop), diff --git a/backend/rorapp/migrations/0024_rename_office_title.py b/backend/rorapp/migrations/0024_rename_office_title.py index d12bc0b1..c3e56d53 100644 --- a/backend/rorapp/migrations/0024_rename_office_title.py +++ b/backend/rorapp/migrations/0024_rename_office_title.py @@ -4,14 +4,13 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0023_senator_influence_senator_knights_senator_loyalty_and_more'), + ("rorapp", "0023_senator_influence_senator_knights_senator_loyalty_and_more"), ] operations = [ migrations.RenameModel( - old_name='Office', - new_name='Title', + old_name="Office", + new_name="Title", ), ] diff --git a/backend/rorapp/migrations/0025_title_major_office.py b/backend/rorapp/migrations/0025_title_major_office.py index 914f6fff..720b2fa7 100644 --- a/backend/rorapp/migrations/0025_title_major_office.py +++ b/backend/rorapp/migrations/0025_title_major_office.py @@ -6,8 +6,7 @@ # Set all existing titles to be major offices def update_titles(apps, schema_editor): - - Title = apps.get_model('rorapp', 'Title') + Title = apps.get_model("rorapp", "Title") for title in Title.objects.all(): title.major_office = True @@ -15,15 +14,14 @@ def update_titles(apps, schema_editor): class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0024_rename_office_title'), + ("rorapp", "0024_rename_office_title"), ] operations = [ migrations.AddField( - model_name='title', - name='major_office', + model_name="title", + name="major_office", field=models.BooleanField(default=False), ), migrations.RunPython(update_titles, migrations.RunPython.noop), diff --git a/backend/rorapp/migrations/0026_alter_title_end_step_alter_title_start_step.py b/backend/rorapp/migrations/0026_alter_title_end_step_alter_title_start_step.py index bd527603..1ee79adc 100644 --- a/backend/rorapp/migrations/0026_alter_title_end_step_alter_title_start_step.py +++ b/backend/rorapp/migrations/0026_alter_title_end_step_alter_title_start_step.py @@ -8,44 +8,56 @@ # Update titles to use the IDs of the corresponding Steps for start_step and end_step # instead of the indexes of the corresponding Steps, which didn't even match up anyway def update_title_steps(apps, schema_editor): - Title = apps.get_model('rorapp', 'Title') - Step = apps.get_model('rorapp', 'Step') - + Title = apps.get_model("rorapp", "Title") + Step = apps.get_model("rorapp", "Step") + # Loop over all titles for title in Title.objects.all(): - # Get the game game = title.senator.game - - print('game:', game) - print('title.start_step:', title.start_step) - print('step objects:', Step.objects.filter(phase__turn__game=game)) + + print("game:", game) + print("title.start_step:", title.start_step) + print("step objects:", Step.objects.filter(phase__turn__game=game)) # Update the start_step and end_step fields with the IDs of the corresponding Steps - title.start_step = Step.objects.get(phase__turn__game=game, index=title.start_step - 1).id - if (title.end_step is not None): - title.end_step = Step.objects.get(phase__turn__game=game, index=title.end_step - 1).id + title.start_step = Step.objects.get( + phase__turn__game=game, index=title.start_step - 1 + ).id + if title.end_step is not None: + title.end_step = Step.objects.get( + phase__turn__game=game, index=title.end_step - 1 + ).id # Save the changes title.save() class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0025_title_major_office'), + ("rorapp", "0025_title_major_office"), ] operations = [ migrations.RunPython(update_title_steps, migrations.RunPython.noop), migrations.AlterField( - model_name='title', - name='end_step', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='ending_title_set', to='rorapp.step'), + model_name="title", + name="end_step", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name="ending_title_set", + to="rorapp.step", + ), ), migrations.AlterField( - model_name='title', - name='start_step', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='starting_title_set', to='rorapp.step'), + model_name="title", + name="start_step", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="starting_title_set", + to="rorapp.step", + ), ), ] diff --git a/backend/rorapp/migrations/0027_notification.py b/backend/rorapp/migrations/0027_notification.py index 27b56a81..2879f744 100644 --- a/backend/rorapp/migrations/0027_notification.py +++ b/backend/rorapp/migrations/0027_notification.py @@ -5,21 +5,41 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0026_alter_title_end_step_alter_title_start_step'), + ("rorapp", "0026_alter_title_end_step_alter_title_start_step"), ] operations = [ migrations.CreateModel( - name='Notification', + name="Notification", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('index', models.PositiveIntegerField()), - ('type', models.CharField(max_length=50)), - ('data', models.JSONField(blank=True, null=True)), - ('faction', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='rorapp.faction')), - ('step', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rorapp.step')), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("index", models.PositiveIntegerField()), + ("type", models.CharField(max_length=50)), + ("data", models.JSONField(blank=True, null=True)), + ( + "faction", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + to="rorapp.faction", + ), + ), + ( + "step", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="rorapp.step" + ), + ), ], ), ] diff --git a/backend/rorapp/migrations/0028_senator_alive_alter_senator_faction.py b/backend/rorapp/migrations/0028_senator_alive_alter_senator_faction.py index 06fcd002..1fc3924c 100644 --- a/backend/rorapp/migrations/0028_senator_alive_alter_senator_faction.py +++ b/backend/rorapp/migrations/0028_senator_alive_alter_senator_faction.py @@ -5,20 +5,24 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0027_notification'), + ("rorapp", "0027_notification"), ] operations = [ migrations.AddField( - model_name='senator', - name='alive', + model_name="senator", + name="alive", field=models.BooleanField(default=True), ), migrations.AlterField( - model_name='senator', - name='faction', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='rorapp.faction'), + model_name="senator", + name="faction", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.SET_NULL, + to="rorapp.faction", + ), ), ] diff --git a/backend/rorapp/migrations/0029_migration_data.json b/backend/rorapp/migrations/0029_migration_data.json index d62205a5..7cad3f14 100644 --- a/backend/rorapp/migrations/0029_migration_data.json +++ b/backend/rorapp/migrations/0029_migration_data.json @@ -1,22 +1,22 @@ { - "Cornelius" : 1, - "Fabius" : 2, - "Valerius" : 3, - "Julius" : 4, - "Claudius" : 5, - "Manlius" : 6, - "Fulvius" : 7, - "Furius" : 8, - "Aurelius" : 9, - "Junius" : 10, - "Papirius" : 11, - "Acilius" : 12, - "Flaminius" : 13, - "Aelius" : 14, - "Sulpicius" : 15, - "Calpurnius" : 16, - "Plautius" : 17, - "Quinctius" : 18, - "Aemilius" : 19, - "Terentius" : 20 + "Cornelius": 1, + "Fabius": 2, + "Valerius": 3, + "Julius": 4, + "Claudius": 5, + "Manlius": 6, + "Fulvius": 7, + "Furius": 8, + "Aurelius": 9, + "Junius": 10, + "Papirius": 11, + "Acilius": 12, + "Flaminius": 13, + "Aelius": 14, + "Sulpicius": 15, + "Calpurnius": 16, + "Plautius": 17, + "Quinctius": 18, + "Aemilius": 19, + "Terentius": 20 } diff --git a/backend/rorapp/migrations/0029_senator_code.py b/backend/rorapp/migrations/0029_senator_code.py index 795c6f8a..9e9d0a35 100644 --- a/backend/rorapp/migrations/0029_senator_code.py +++ b/backend/rorapp/migrations/0029_senator_code.py @@ -6,11 +6,12 @@ import json from pathlib import Path + # This migration adds senator codes, which are loaded from a JSON file. def load_data(apps, schema_editor): - Senator = apps.get_model('rorapp', 'Senator') - - with open(Path(__file__).resolve().parent / '0029_migration_data.json') as f: + Senator = apps.get_model("rorapp", "Senator") + + with open(Path(__file__).resolve().parent / "0029_migration_data.json") as f: data = json.load(f) for name, code in data.items(): @@ -19,16 +20,16 @@ def load_data(apps, schema_editor): senator.code = code senator.save() -class Migration(migrations.Migration): +class Migration(migrations.Migration): dependencies = [ - ('rorapp', '0028_senator_alive_alter_senator_faction'), + ("rorapp", "0028_senator_alive_alter_senator_faction"), ] operations = [ migrations.AddField( - model_name='senator', - name='code', + model_name="senator", + name="code", field=models.IntegerField(default=0), ), migrations.RunPython(load_data, migrations.RunPython.noop), diff --git a/backend/rorapp/migrations/0030_senator_generation_alter_senator_code.py b/backend/rorapp/migrations/0030_senator_generation_alter_senator_code.py index 3f18feda..c15afaf1 100644 --- a/backend/rorapp/migrations/0030_senator_generation_alter_senator_code.py +++ b/backend/rorapp/migrations/0030_senator_generation_alter_senator_code.py @@ -4,20 +4,19 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0029_senator_code'), + ("rorapp", "0029_senator_code"), ] operations = [ migrations.AddField( - model_name='senator', - name='generation', + model_name="senator", + name="generation", field=models.IntegerField(default=1), ), migrations.AlterField( - model_name='senator', - name='code', + model_name="senator", + name="code", field=models.IntegerField(), ), ] diff --git a/backend/rorapp/migrations/0031_senator_rank_and_faction_rank.py b/backend/rorapp/migrations/0031_senator_rank_and_faction_rank.py index 0d69eb14..2f96f004 100644 --- a/backend/rorapp/migrations/0031_senator_rank_and_faction_rank.py +++ b/backend/rorapp/migrations/0031_senator_rank_and_faction_rank.py @@ -7,76 +7,79 @@ # Migration-suitable copy of a function found elsewhere in the codebase. # Copied here because the other function may change in the future. def rank_senators_and_factions(apps, game_id): - # Import models - Faction = apps.get_model('rorapp', 'Faction') - Senator = apps.get_model('rorapp', 'Senator') - Title = apps.get_model('rorapp', 'Title') - + Faction = apps.get_model("rorapp", "Faction") + Senator = apps.get_model("rorapp", "Senator") + Title = apps.get_model("rorapp", "Title") + # Get aligned alive senators senators = Senator.objects.filter(game=game_id, alive=True, faction__isnull=False) - + # Sort by descending influence, descending oratory and ascending code (ID) - senators = senators.order_by('-influence', '-oratory', 'code') - + senators = senators.order_by("-influence", "-oratory", "code") + # Get major offices - major_offices = Title.objects.filter(senator__game=game_id, major_office=True, end_step=None) - + major_offices = Title.objects.filter( + senator__game=game_id, major_office=True, end_step=None + ) + # Order the major offices ordered_major_offices = [ - major_offices.filter(name='Dictator').first(), - major_offices.filter(name__contains='Rome Consul').first(), - major_offices.filter(name='Field Consul').first(), - major_offices.filter(name='Censor').first(), - major_offices.filter(name='Master of Horse').first() + major_offices.filter(name="Dictator").first(), + major_offices.filter(name__contains="Rome Consul").first(), + major_offices.filter(name="Field Consul").first(), + major_offices.filter(name="Censor").first(), + major_offices.filter(name="Master of Horse").first(), + ] + + # Remove None major offices + ordered_major_offices = [ + office for office in ordered_major_offices if office is not None ] - - # Remove None major offices - ordered_major_offices = [office for office in ordered_major_offices if office is not None] - + # Assign rank values rank = 0 while True: - selected_senator = None - + # Assign the rank to a major office holder if rank <= len(ordered_major_offices) - 1: selected_senator = ordered_major_offices[rank].senator - + # Assign the rank to the first remaining senator else: selected_senator = senators.first() if selected_senator is None: break - + # Update senator's rank only if it's changed if selected_senator.rank != rank: selected_senator.rank = rank selected_senator.save() senators = senators.exclude(id=selected_senator.id) - + rank += 1 - + # Get unaligned and dead senators - unaligned_senators = Senator.objects.filter(game=game_id, alive=True, faction__isnull=True) + unaligned_senators = Senator.objects.filter( + game=game_id, alive=True, faction__isnull=True + ) dead_senators = Senator.objects.filter(game=game_id, alive=False) unaligned_and_dead_senators = unaligned_senators.union(dead_senators) - + # Set rank to None for unaligned and dead senators for senator in unaligned_and_dead_senators: - # Update senator's rank only if it's changed if senator.rank is not None: senator.rank = None senator.save() - + # Get the HRAO hrao = Senator.objects.filter(game=game_id, alive=True, rank=0).first() - + # Get factions in order of position - factions = Faction.objects.filter(game=game_id).order_by('position') - + factions = Faction.objects.filter(game=game_id).order_by("position") + # Sort the factions into positional order factions_before_hrao_faction = [] for i in range(len(factions)): @@ -85,50 +88,53 @@ def rank_senators_and_factions(apps, game_id): break else: factions_before_hrao_faction.append(factions[i]) - + # Set faction ranks for rank in range(0, len(sorted_factions)): faction = sorted_factions[rank] - + # Update faction's rank only if it's changed if faction.rank != rank: faction.rank = rank faction.save() - # This migration adds senator and faction ranks. # Immediately set ranks on all existing senators and factions. def set_ranks(apps, schema_editor): - Game = apps.get_model('rorapp', 'Game') - + Game = apps.get_model("rorapp", "Game") + games = Game.objects.filter(start_date__isnull=False) - + for game in games: rank_senators_and_factions(apps, game.id) - -class Migration(migrations.Migration): +class Migration(migrations.Migration): dependencies = [ - ('rorapp', '0030_senator_generation_alter_senator_code'), + ("rorapp", "0030_senator_generation_alter_senator_code"), ] operations = [ migrations.AddField( - model_name='senator', - name='rank', + model_name="senator", + name="rank", field=models.IntegerField(blank=True, null=True), ), migrations.AddField( - model_name='faction', - name='rank', + model_name="faction", + name="rank", field=models.IntegerField(blank=True, null=True), ), migrations.AlterField( - model_name='faction', - name='player', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='rorapp.player'), + model_name="faction", + name="player", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.SET_NULL, + to="rorapp.player", + ), ), migrations.RunPython(set_ranks, migrations.RunPython.noop), ] diff --git a/backend/rorapp/migrations/0032_change_senator_notification_data.py b/backend/rorapp/migrations/0032_change_senator_notification_data.py index 0ed0ab64..ce127fac 100644 --- a/backend/rorapp/migrations/0032_change_senator_notification_data.py +++ b/backend/rorapp/migrations/0032_change_senator_notification_data.py @@ -7,21 +7,19 @@ # In a future version, notifications might be used as a log of events, so it's better to keep the data consistent. # Any data key that contains a senator ID should be suffixed with "senator". def update_notification_data(apps, schema_editor): - Notification = apps.get_model('rorapp', 'Notification') - - face_mortality_notifications = Notification.objects.filter(type='face_mortality') - + Notification = apps.get_model("rorapp", "Notification") + + face_mortality_notifications = Notification.objects.filter(type="face_mortality") + for notification in face_mortality_notifications: - - notification.data['heir_senator'] = notification.data['heir'] - del notification.data['heir'] + notification.data["heir_senator"] = notification.data["heir"] + del notification.data["heir"] notification.save() class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0031_senator_rank_and_faction_rank'), + ("rorapp", "0031_senator_rank_and_faction_rank"), ] operations = [ diff --git a/backend/rorapp/migrations/0033_senatornotification.py b/backend/rorapp/migrations/0033_senatornotification.py index 1a035195..655e04c0 100644 --- a/backend/rorapp/migrations/0033_senatornotification.py +++ b/backend/rorapp/migrations/0033_senatornotification.py @@ -6,41 +6,61 @@ # Create relationships between senators and notifications def create_senator_notifications(apps, schema_editor): - Notification = apps.get_model('rorapp', 'Notification') - Senator = apps.get_model('rorapp', 'Senator') - SenatorNotification = apps.get_model('rorapp', 'SenatorNotification') - + Notification = apps.get_model("rorapp", "Notification") + Senator = apps.get_model("rorapp", "Senator") + SenatorNotification = apps.get_model("rorapp", "SenatorNotification") + notifications = Notification.objects.all() - + # For each notification create some relations for notification in notifications: - # Look at notification data and create a list of keys that end in "senator" - senator_keys = [key for key in notification.data.keys() if key.endswith('senator')] - + senator_keys = [ + key for key in notification.data.keys() if key.endswith("senator") + ] + for senator_key in senator_keys: - # Create a SenatorNotification for each senator ID in the notification data senator_id = notification.data[senator_key] - + if senator_id: senator = Senator.objects.get(id=senator_id) - SenatorNotification.objects.create(senator=senator, notification=notification) + SenatorNotification.objects.create( + senator=senator, notification=notification + ) class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0032_change_senator_notification_data'), + ("rorapp", "0032_change_senator_notification_data"), ] operations = [ migrations.CreateModel( - name='SenatorNotification', + name="SenatorNotification", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('notification', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rorapp.notification')), - ('senator', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rorapp.senator')), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "notification", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + to="rorapp.notification", + ), + ), + ( + "senator", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="rorapp.senator" + ), + ), ], ), migrations.RunPython(create_senator_notifications, migrations.RunPython.noop), diff --git a/backend/rorapp/migrations/0035_alter_faction_game_alter_player_game_and_more.py b/backend/rorapp/migrations/0035_alter_faction_game_alter_player_game_and_more.py index 2820707c..f2cc6eb5 100644 --- a/backend/rorapp/migrations/0035_alter_faction_game_alter_player_game_and_more.py +++ b/backend/rorapp/migrations/0035_alter_faction_game_alter_player_game_and_more.py @@ -5,25 +5,36 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0034_senatoractionlog_rename_notification_actionlog_and_more'), + ("rorapp", "0034_senatoractionlog_rename_notification_actionlog_and_more"), ] operations = [ migrations.AlterField( - model_name='faction', - name='game', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='factions', to='rorapp.game'), + model_name="faction", + name="game", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="factions", + to="rorapp.game", + ), ), migrations.AlterField( - model_name='player', - name='game', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='players', to='rorapp.game'), + model_name="player", + name="game", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="players", + to="rorapp.game", + ), ), migrations.AlterField( - model_name='senator', - name='game', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='senators', to='rorapp.game'), + model_name="senator", + name="game", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="senators", + to="rorapp.game", + ), ), ] diff --git a/backend/rorapp/migrations/0036_add_senator_death_step_remove_senator_alive.py b/backend/rorapp/migrations/0036_add_senator_death_step_remove_senator_alive.py index f12865f8..4fbe9597 100644 --- a/backend/rorapp/migrations/0036_add_senator_death_step_remove_senator_alive.py +++ b/backend/rorapp/migrations/0036_add_senator_death_step_remove_senator_alive.py @@ -5,17 +5,17 @@ def convert_alive_to_senator_death(apps, schema_editor): - Senator = apps.get_model('rorapp', 'Senator') + Senator = apps.get_model("rorapp", "Senator") dead_senators = Senator.objects.filter(alive=False) - ActionLog = apps.get_model('rorapp', 'ActionLog') - death_action_logs = ActionLog.objects.filter(type='face_mortality') + ActionLog = apps.get_model("rorapp", "ActionLog") + death_action_logs = ActionLog.objects.filter(type="face_mortality") for dead_action_log in death_action_logs: - if (dead_action_log.data is None): + if dead_action_log.data is None: continue - dead_senator_id = dead_action_log.data.get('senator') - if (dead_senator_id is None): + dead_senator_id = dead_action_log.data.get("senator") + if dead_senator_id is None: continue dead_senator = dead_senators.get(id=dead_senator_id) dead_senator.death_step = dead_action_log.step @@ -23,26 +23,32 @@ def convert_alive_to_senator_death(apps, schema_editor): def convert_senator_death_to_alive(apps, schema_editor): - Senator = apps.get_model('rorapp', 'Senator') + Senator = apps.get_model("rorapp", "Senator") dead_senators = Senator.objects.filter(death_step__isnull=False) dead_senators.update(alive=False) class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0035_alter_faction_game_alter_player_game_and_more'), + ("rorapp", "0035_alter_faction_game_alter_player_game_and_more"), ] operations = [ migrations.AddField( - model_name='senator', - name='death_step', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='rorapp.step'), + model_name="senator", + name="death_step", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + to="rorapp.step", + ), + ), + migrations.RunPython( + convert_alive_to_senator_death, convert_senator_death_to_alive ), - migrations.RunPython(convert_alive_to_senator_death, convert_senator_death_to_alive), migrations.RemoveField( - model_name='senator', - name='alive', + model_name="senator", + name="alive", ), ] diff --git a/backend/rorapp/migrations/0037_dead_senators_faction.py b/backend/rorapp/migrations/0037_dead_senators_faction.py index 0d1c52e3..a17750a5 100644 --- a/backend/rorapp/migrations/0037_dead_senators_faction.py +++ b/backend/rorapp/migrations/0037_dead_senators_faction.py @@ -4,17 +4,17 @@ def set_dead_senators_faction(apps, schema_editor): - Senator = apps.get_model('rorapp', 'Senator') + Senator = apps.get_model("rorapp", "Senator") dead_senators = Senator.objects.filter(death_step__isnull=False) - - ActionLog = apps.get_model('rorapp', 'ActionLog') - death_action_logs = ActionLog.objects.filter(type='face_mortality') - + + ActionLog = apps.get_model("rorapp", "ActionLog") + death_action_logs = ActionLog.objects.filter(type="face_mortality") + for dead_action_log in death_action_logs: - if (dead_action_log.data is None): + if dead_action_log.data is None: continue - dead_senator_id = dead_action_log.data.get('senator') - if (dead_senator_id is None): + dead_senator_id = dead_action_log.data.get("senator") + if dead_senator_id is None: continue dead_senator = dead_senators.get(id=dead_senator_id) dead_senator.faction = dead_action_log.faction @@ -22,18 +22,16 @@ def set_dead_senators_faction(apps, schema_editor): def unset_dead_senators_faction(apps, schema_editor): - Senator = apps.get_model('rorapp', 'Senator') + Senator = apps.get_model("rorapp", "Senator") dead_senators = Senator.objects.filter(death_step__isnull=False) dead_senators.update(faction=None) - class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0036_add_senator_death_step_remove_senator_alive'), + ("rorapp", "0036_add_senator_death_step_remove_senator_alive"), ] operations = [ migrations.RunPython(set_dead_senators_faction, unset_dead_senators_faction), - ] \ No newline at end of file + ] diff --git a/backend/rorapp/migrations/0038_potentialaction_completed.py b/backend/rorapp/migrations/0038_potentialaction_completed.py index ee491150..b66a9218 100644 --- a/backend/rorapp/migrations/0038_potentialaction_completed.py +++ b/backend/rorapp/migrations/0038_potentialaction_completed.py @@ -20,8 +20,8 @@ def move_completed_to_potential(apps, schema_editor): def move_potential_back_to_completed(apps, schema_editor): - PotentialAction = apps.get_model('rorapp', 'PotentialAction') - CompletedAction = apps.get_model('rorapp', 'CompletedAction') + PotentialAction = apps.get_model("rorapp", "PotentialAction") + CompletedAction = apps.get_model("rorapp", "CompletedAction") for potentialAction in PotentialAction.objects.filter(completed=True): new_completed_action = CompletedAction( step=potentialAction.step, @@ -45,5 +45,7 @@ class Migration(migrations.Migration): name="completed", field=models.BooleanField(default=False), ), - migrations.RunPython(move_completed_to_potential, move_potential_back_to_completed), + migrations.RunPython( + move_completed_to_potential, move_potential_back_to_completed + ), ] diff --git a/backend/rorapp/migrations/0039_rename_potentialaction_action_delete_completedaction.py b/backend/rorapp/migrations/0039_rename_potentialaction_action_delete_completedaction.py index a38f5617..3582fb4c 100644 --- a/backend/rorapp/migrations/0039_rename_potentialaction_action_delete_completedaction.py +++ b/backend/rorapp/migrations/0039_rename_potentialaction_action_delete_completedaction.py @@ -4,17 +4,16 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0038_potentialaction_completed'), + ("rorapp", "0038_potentialaction_completed"), ] operations = [ migrations.RenameModel( - old_name='PotentialAction', - new_name='Action', + old_name="PotentialAction", + new_name="Action", ), migrations.DeleteModel( - name='CompletedAction', + name="CompletedAction", ), ] diff --git a/backend/rorapp/migrations/0040_temp_rome_consul_influence.py b/backend/rorapp/migrations/0040_temp_rome_consul_influence.py index ef319ea1..8a7e31b4 100644 --- a/backend/rorapp/migrations/0040_temp_rome_consul_influence.py +++ b/backend/rorapp/migrations/0040_temp_rome_consul_influence.py @@ -1,6 +1,6 @@ from django.db import migrations - + def increase_influence(apps, schema_editor): Title = apps.get_model("rorapp", "Title") Senator = apps.get_model("rorapp", "Senator") diff --git a/backend/rorapp/migrations/0042_assign_prior_consul_titles.py b/backend/rorapp/migrations/0042_assign_prior_consul_titles.py index e985fa93..1ce41f22 100644 --- a/backend/rorapp/migrations/0042_assign_prior_consul_titles.py +++ b/backend/rorapp/migrations/0042_assign_prior_consul_titles.py @@ -4,9 +4,7 @@ def add_prior_consul_titles(apps, schema_editor): Senator = apps.get_model("rorapp", "Senator") Title = apps.get_model("rorapp", "Title") - temporary_rome_consul_titles = Title.objects.filter( - name="Temporary Rome Consul" - ) + temporary_rome_consul_titles = Title.objects.filter(name="Temporary Rome Consul") for title in temporary_rome_consul_titles: senator = Senator.objects.get(id=title.senator.id) prior_consul_title_exists = Title.objects.filter( @@ -14,7 +12,10 @@ def add_prior_consul_titles(apps, schema_editor): ).exists() if not prior_consul_title_exists: prior_consul_title = Title.objects.create( - name="Prior Consul", senator=senator, start_step=title.start_step, end_step=title.end_step + name="Prior Consul", + senator=senator, + start_step=title.start_step, + end_step=title.end_step, ) prior_consul_title.save() @@ -31,7 +32,5 @@ class Migration(migrations.Migration): ] operations = [ - migrations.RunPython( - add_prior_consul_titles, remove_prior_consul_titles - ), + migrations.RunPython(add_prior_consul_titles, remove_prior_consul_titles), ] diff --git a/backend/rorapp/migrations/0043_situation_secret.py b/backend/rorapp/migrations/0043_situation_secret.py index 05054667..e9accdd7 100644 --- a/backend/rorapp/migrations/0043_situation_secret.py +++ b/backend/rorapp/migrations/0043_situation_secret.py @@ -164,6 +164,7 @@ def destroy_situations_and_secrets(apps, schema_editor): ], ), migrations.RunPython( - create_situations_and_secrets, destroy_situations_and_secrets # type: ignore + create_situations_and_secrets, # type: ignore + destroy_situations_and_secrets, # type: ignore ), ] diff --git a/backend/rorapp/migrations/0044_shuffle_situations.py b/backend/rorapp/migrations/0044_shuffle_situations.py index 1a6ae74c..17b6dd3e 100644 --- a/backend/rorapp/migrations/0044_shuffle_situations.py +++ b/backend/rorapp/migrations/0044_shuffle_situations.py @@ -25,5 +25,5 @@ def shuffle_situations(apps, schema_editor): ] operations = [ - migrations.RunPython(shuffle_situations, migrations.RunPython.noop), # type: ignore + migrations.RunPython(shuffle_situations, migrations.RunPython.noop), # type: ignore ] diff --git a/backend/rorapp/migrations/0045_war.py b/backend/rorapp/migrations/0045_war.py index 34d9cb3a..dea0128d 100644 --- a/backend/rorapp/migrations/0045_war.py +++ b/backend/rorapp/migrations/0045_war.py @@ -76,5 +76,5 @@ def create_first_punic_war(apps, schema_editor): ("naval_defeated", models.BooleanField()), ], ), - migrations.RunPython(create_first_punic_war, migrations.RunPython.noop), # type: ignore + migrations.RunPython(create_first_punic_war, migrations.RunPython.noop), # type: ignore ] diff --git a/backend/rorapp/migrations/0046_rename_war_situations.py b/backend/rorapp/migrations/0046_rename_war_situations.py index b74f2b3d..6d6dc07d 100644 --- a/backend/rorapp/migrations/0046_rename_war_situations.py +++ b/backend/rorapp/migrations/0046_rename_war_situations.py @@ -22,5 +22,5 @@ def rename_war_situations(apps, schema_editor): ] operations = [ - migrations.RunPython(rename_war_situations, migrations.RunPython.noop), # type: ignore + migrations.RunPython(rename_war_situations, migrations.RunPython.noop), # type: ignore ] diff --git a/backend/rorapp/migrations/0047_syrian_war_index.py b/backend/rorapp/migrations/0047_syrian_war_index.py index 8a395257..b45dd36c 100644 --- a/backend/rorapp/migrations/0047_syrian_war_index.py +++ b/backend/rorapp/migrations/0047_syrian_war_index.py @@ -24,5 +24,5 @@ def change_syrian_war_index(apps, schema_editor): ] operations = [ - migrations.RunPython(change_syrian_war_index, migrations.RunPython.noop), # type: ignore + migrations.RunPython(change_syrian_war_index, migrations.RunPython.noop), # type: ignore ] diff --git a/backend/rorapp/migrations/0048_war_matching_wars.py b/backend/rorapp/migrations/0048_war_matching_wars.py index 930f5b15..cd1fc7ef 100644 --- a/backend/rorapp/migrations/0048_war_matching_wars.py +++ b/backend/rorapp/migrations/0048_war_matching_wars.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0047_syrian_war_index'), + ("rorapp", "0047_syrian_war_index"), ] operations = [ migrations.AddField( - model_name='war', - name='matching_wars', - field=models.ManyToManyField(to='rorapp.war'), + model_name="war", + name="matching_wars", + field=models.ManyToManyField(to="rorapp.war"), ), ] diff --git a/backend/rorapp/migrations/0049_rename_naval_defeated_war_undefeated_navy.py b/backend/rorapp/migrations/0049_rename_naval_defeated_war_undefeated_navy.py index 05999fa5..782c8c90 100644 --- a/backend/rorapp/migrations/0049_rename_naval_defeated_war_undefeated_navy.py +++ b/backend/rorapp/migrations/0049_rename_naval_defeated_war_undefeated_navy.py @@ -4,27 +4,26 @@ class Migration(migrations.Migration): - def invert_undefeated_navy(apps, schema_editor): - War = apps.get_model('rorapp', 'War') + War = apps.get_model("rorapp", "War") for war in War.objects.all(): war.undefeated_navy = not war.undefeated_navy war.save() dependencies = [ - ('rorapp', '0048_war_matching_wars'), + ("rorapp", "0048_war_matching_wars"), ] operations = [ migrations.RenameField( - model_name='war', - old_name='naval_defeated', - new_name='undefeated_navy', + model_name="war", + old_name="naval_defeated", + new_name="undefeated_navy", ), migrations.AlterField( - model_name='war', - name='matching_wars', - field=models.ManyToManyField(blank=True, to='rorapp.war'), + model_name="war", + name="matching_wars", + field=models.ManyToManyField(blank=True, to="rorapp.war"), ), - migrations.RunPython(invert_undefeated_navy, invert_undefeated_navy), # type: ignore + migrations.RunPython(invert_undefeated_navy, invert_undefeated_navy), # type: ignore ] diff --git a/backend/rorapp/migrations/0050_enemyleader.py b/backend/rorapp/migrations/0050_enemyleader.py index 70f22025..7a0fe730 100644 --- a/backend/rorapp/migrations/0050_enemyleader.py +++ b/backend/rorapp/migrations/0050_enemyleader.py @@ -5,24 +5,41 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0049_rename_naval_defeated_war_undefeated_navy'), + ("rorapp", "0049_rename_naval_defeated_war_undefeated_navy"), ] operations = [ migrations.CreateModel( - name='EnemyLeader', + name="EnemyLeader", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=13)), - ('strength', models.IntegerField()), - ('disaster_number', models.IntegerField()), - ('standoff_number', models.IntegerField()), - ('war_name', models.CharField(max_length=10)), - ('dead', models.BooleanField()), - ('current_war', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rorapp.war')), - ('game', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rorapp.game')), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("name", models.CharField(max_length=13)), + ("strength", models.IntegerField()), + ("disaster_number", models.IntegerField()), + ("standoff_number", models.IntegerField()), + ("war_name", models.CharField(max_length=10)), + ("dead", models.BooleanField()), + ( + "current_war", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="rorapp.war" + ), + ), + ( + "game", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="rorapp.game" + ), + ), ], ), ] diff --git a/backend/rorapp/migrations/0051_remove_war_matching_wars.py b/backend/rorapp/migrations/0051_remove_war_matching_wars.py index 04ac700d..757fccf5 100644 --- a/backend/rorapp/migrations/0051_remove_war_matching_wars.py +++ b/backend/rorapp/migrations/0051_remove_war_matching_wars.py @@ -4,14 +4,13 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0050_enemyleader'), + ("rorapp", "0050_enemyleader"), ] operations = [ migrations.RemoveField( - model_name='war', - name='matching_wars', + model_name="war", + name="matching_wars", ), ] diff --git a/backend/rorapp/migrations/0052_alter_enemyleader_current_war.py b/backend/rorapp/migrations/0052_alter_enemyleader_current_war.py index eeb4f74b..12f3fa6f 100644 --- a/backend/rorapp/migrations/0052_alter_enemyleader_current_war.py +++ b/backend/rorapp/migrations/0052_alter_enemyleader_current_war.py @@ -5,15 +5,19 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0051_remove_war_matching_wars'), + ("rorapp", "0051_remove_war_matching_wars"), ] operations = [ migrations.AlterField( - model_name='enemyleader', - name='current_war', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='rorapp.war'), + model_name="enemyleader", + name="current_war", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + to="rorapp.war", + ), ), ] diff --git a/backend/rorapp/migrations/0053_senator_dead.py b/backend/rorapp/migrations/0053_senator_dead.py index 4552ea2e..da2d9ace 100644 --- a/backend/rorapp/migrations/0053_senator_dead.py +++ b/backend/rorapp/migrations/0053_senator_dead.py @@ -4,27 +4,26 @@ class Migration(migrations.Migration): - def populate_dead_field(apps, schema_editor): - Senator = apps.get_model('rorapp', 'Senator') + Senator = apps.get_model("rorapp", "Senator") for senator in Senator.objects.all(): senator.alive = senator.death_step is None senator.save() dependencies = [ - ('rorapp', '0052_alter_enemyleader_current_war'), + ("rorapp", "0052_alter_enemyleader_current_war"), ] operations = [ migrations.AddField( - model_name='senator', - name='alive', + model_name="senator", + name="alive", field=models.BooleanField(default=True), preserve_default=False, ), - migrations.RunPython(populate_dead_field, migrations.RunPython.noop), # type: ignore + migrations.RunPython(populate_dead_field, migrations.RunPython.noop), # type: ignore migrations.RemoveField( - model_name='senator', - name='death_step', + model_name="senator", + name="death_step", ), ] diff --git a/backend/rorapp/migrations/0054_alter_enemyleader_dead_alter_senator_alive.py b/backend/rorapp/migrations/0054_alter_enemyleader_dead_alter_senator_alive.py index 1fff7c79..6e9d1216 100644 --- a/backend/rorapp/migrations/0054_alter_enemyleader_dead_alter_senator_alive.py +++ b/backend/rorapp/migrations/0054_alter_enemyleader_dead_alter_senator_alive.py @@ -4,20 +4,19 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0053_senator_dead'), + ("rorapp", "0053_senator_dead"), ] operations = [ migrations.AlterField( - model_name='enemyleader', - name='dead', + model_name="enemyleader", + name="dead", field=models.BooleanField(default=False), ), migrations.AlterField( - model_name='senator', - name='alive', + model_name="senator", + name="alive", field=models.BooleanField(default=True), ), ] diff --git a/backend/rorapp/migrations/0055_rename_tax_farmer.py b/backend/rorapp/migrations/0055_rename_tax_farmer.py index 60179f67..c4e90167 100644 --- a/backend/rorapp/migrations/0055_rename_tax_farmer.py +++ b/backend/rorapp/migrations/0055_rename_tax_farmer.py @@ -40,6 +40,7 @@ def rename_tax_farmer_situations_and_secrets(apps, schema_editor): operations = [ migrations.RunPython( - rename_tax_farmer_situations_and_secrets, migrations.RunPython.noop # type: ignore + rename_tax_farmer_situations_and_secrets, # type: ignore + migrations.RunPython.noop, ), ] diff --git a/backend/rorapp/migrations/0056_alter_phase_name_alter_game_end_date.py b/backend/rorapp/migrations/0056_alter_phase_name_alter_game_end_date.py index 076da675..d77286c1 100644 --- a/backend/rorapp/migrations/0056_alter_phase_name_alter_game_end_date.py +++ b/backend/rorapp/migrations/0056_alter_phase_name_alter_game_end_date.py @@ -4,20 +4,19 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0055_rename_tax_farmer'), + ("rorapp", "0055_rename_tax_farmer"), ] operations = [ migrations.AlterField( - model_name='phase', - name='name', + model_name="phase", + name="name", field=models.CharField(max_length=11), ), migrations.AddField( - model_name='game', - name='end_date', + model_name="game", + name="end_date", field=models.DateTimeField(blank=True, null=True), ), ] diff --git a/backend/rorapp/migrations/0057_actionlog_creation_date.py b/backend/rorapp/migrations/0057_actionlog_creation_date.py index dbbc5e9e..ea9df85a 100644 --- a/backend/rorapp/migrations/0057_actionlog_creation_date.py +++ b/backend/rorapp/migrations/0057_actionlog_creation_date.py @@ -5,15 +5,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0056_alter_phase_name_alter_game_end_date'), + ("rorapp", "0056_alter_phase_name_alter_game_end_date"), ] operations = [ migrations.AddField( - model_name='actionlog', - name='creation_date', + model_name="actionlog", + name="creation_date", field=models.DateTimeField(default=django.utils.timezone.now), ), ] diff --git a/backend/rorapp/migrations/0058_rename_actions.py b/backend/rorapp/migrations/0058_rename_actions.py index 1aa77941..aa952f80 100644 --- a/backend/rorapp/migrations/0058_rename_actions.py +++ b/backend/rorapp/migrations/0058_rename_actions.py @@ -20,5 +20,5 @@ def rename_actions(apps, schema_editor): ] operations = [ - migrations.RunPython(rename_actions, migrations.RunPython.noop), # type: ignore + migrations.RunPython(rename_actions, migrations.RunPython.noop), # type: ignore ] diff --git a/backend/rorapp/migrations/0059_concession.py b/backend/rorapp/migrations/0059_concession.py index 6be3b41c..70c35147 100644 --- a/backend/rorapp/migrations/0059_concession.py +++ b/backend/rorapp/migrations/0059_concession.py @@ -5,19 +5,39 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0058_rename_actions'), + ("rorapp", "0058_rename_actions"), ] operations = [ migrations.CreateModel( - name='Concession', + name="Concession", fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=19)), - ('game', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='rorapp.game')), - ('senator', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='rorapp.senator')), + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("name", models.CharField(max_length=19)), + ( + "game", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, to="rorapp.game" + ), + ), + ( + "senator", + models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + to="rorapp.senator", + ), + ), ], ), ] diff --git a/backend/rorapp/migrations/0060_faction_custom_name.py b/backend/rorapp/migrations/0060_faction_custom_name.py index 352ea236..ef98b353 100644 --- a/backend/rorapp/migrations/0060_faction_custom_name.py +++ b/backend/rorapp/migrations/0060_faction_custom_name.py @@ -4,15 +4,14 @@ class Migration(migrations.Migration): - dependencies = [ - ('rorapp', '0059_concession'), + ("rorapp", "0059_concession"), ] operations = [ migrations.AddField( - model_name='faction', - name='custom_name', + model_name="faction", + name="custom_name", field=models.CharField(blank=True, max_length=30, null=True), ), ] diff --git a/backend/rorapp/migrations/0061_remove_new_turn_actionlogs.py b/backend/rorapp/migrations/0061_remove_new_turn_actionlogs.py index a0178fea..b5e3d6a0 100644 --- a/backend/rorapp/migrations/0061_remove_new_turn_actionlogs.py +++ b/backend/rorapp/migrations/0061_remove_new_turn_actionlogs.py @@ -11,5 +11,5 @@ def remove_new_turn_action_logs(apps, schema_editor): ] operations = [ - migrations.RunPython(remove_new_turn_action_logs, migrations.RunPython.noop), # type: ignore + migrations.RunPython(remove_new_turn_action_logs, migrations.RunPython.noop), # type: ignore ] diff --git a/backend/rorapp/models/enemy_leader.py b/backend/rorapp/models/enemy_leader.py index 7d559469..0511c6f5 100644 --- a/backend/rorapp/models/enemy_leader.py +++ b/backend/rorapp/models/enemy_leader.py @@ -11,5 +11,7 @@ class EnemyLeader(models.Model): disaster_number = models.IntegerField() standoff_number = models.IntegerField() war_name = models.CharField(max_length=10) - current_war = models.ForeignKey(War, blank=True, null=True, on_delete=models.CASCADE) + current_war = models.ForeignKey( + War, blank=True, null=True, on_delete=models.CASCADE + ) dead = models.BooleanField(default=False) diff --git a/backend/rorapp/models/turn.py b/backend/rorapp/models/turn.py index 087716cd..a6068123 100644 --- a/backend/rorapp/models/turn.py +++ b/backend/rorapp/models/turn.py @@ -4,5 +4,7 @@ # Model for representing turns class Turn(models.Model): - index = models.PositiveIntegerField() # 1-based index because it's a user-facing value + index = ( + models.PositiveIntegerField() + ) # 1-based index because it's a user-facing value game = models.ForeignKey(Game, on_delete=models.CASCADE) diff --git a/backend/rorapp/serializers/action.py b/backend/rorapp/serializers/action.py index ac3490b0..8bc1afcf 100644 --- a/backend/rorapp/serializers/action.py +++ b/backend/rorapp/serializers/action.py @@ -4,7 +4,14 @@ # Serializer used to read actions class ActionSerializer(serializers.ModelSerializer): - class Meta: model = Action - fields = ('id', 'step', 'faction', 'type', 'required', 'parameters', 'completed') + fields = ( + "id", + "step", + "faction", + "type", + "required", + "parameters", + "completed", + ) diff --git a/backend/rorapp/serializers/enemy_leader.py b/backend/rorapp/serializers/enemy_leader.py index 76e5406a..4424d5d1 100644 --- a/backend/rorapp/serializers/enemy_leader.py +++ b/backend/rorapp/serializers/enemy_leader.py @@ -4,7 +4,16 @@ # Serializer used to read enemy leaders class EnemyLeaderSerializer(serializers.ModelSerializer): - class Meta: model = EnemyLeader - fields = ('id', 'name', 'game', 'strength', 'disaster_number', 'standoff_number', 'war_name', 'current_war', 'dead') + fields = ( + "id", + "name", + "game", + "strength", + "disaster_number", + "standoff_number", + "war_name", + "current_war", + "dead", + ) diff --git a/backend/rorapp/serializers/phase.py b/backend/rorapp/serializers/phase.py index 40a4cc97..a4c7556a 100644 --- a/backend/rorapp/serializers/phase.py +++ b/backend/rorapp/serializers/phase.py @@ -4,7 +4,6 @@ # Serializer used to read phases class PhaseSerializer(serializers.ModelSerializer): - class Meta: model = Phase - fields = ('id', 'name', 'index', 'turn') + fields = ("id", "name", "index", "turn") diff --git a/backend/rorapp/serializers/player.py b/backend/rorapp/serializers/player.py index b347a091..8f892b2e 100644 --- a/backend/rorapp/serializers/player.py +++ b/backend/rorapp/serializers/player.py @@ -4,23 +4,23 @@ # Serializer used to read and delete game players -class PlayerSerializer(serializers.ModelSerializer): +class PlayerSerializer(serializers.ModelSerializer): class Meta: model = Player - fields = ('id', 'user', 'game', 'join_date') - + fields = ("id", "user", "game", "join_date") + # Serializer used to read game players in detail and prefetch users class PlayerDetailSerializer(serializers.ModelSerializer): user = UserSerializer(read_only=True) - + class Meta: model = Player - fields = ('id', 'user', 'game', 'join_date') + fields = ("id", "user", "game", "join_date") # Serializer used to create game players class PlayerCreateSerializer(serializers.ModelSerializer): class Meta: model = Player - fields = ('game',) + fields = ("game",) diff --git a/backend/rorapp/serializers/senator.py b/backend/rorapp/serializers/senator.py index eec6f5ca..15008dd1 100644 --- a/backend/rorapp/serializers/senator.py +++ b/backend/rorapp/serializers/senator.py @@ -4,24 +4,23 @@ # Serializer used to read senators class SenatorSerializer(serializers.ModelSerializer): - class Meta: model = Senator fields = ( - 'id', - 'name', - 'game', - 'faction', - 'alive', - 'code', - 'generation', - 'rank', - 'military', - 'oratory', - 'loyalty', - 'influence', - 'popularity', - 'knights', - 'talents', - 'votes' + "id", + "name", + "game", + "faction", + "alive", + "code", + "generation", + "rank", + "military", + "oratory", + "loyalty", + "influence", + "popularity", + "knights", + "talents", + "votes", ) diff --git a/backend/rorapp/serializers/senator_action_log.py b/backend/rorapp/serializers/senator_action_log.py index e27b79ca..432b52e2 100644 --- a/backend/rorapp/serializers/senator_action_log.py +++ b/backend/rorapp/serializers/senator_action_log.py @@ -4,7 +4,6 @@ # Serializer used to read senator action logs class SenatorActionLogSerializer(serializers.ModelSerializer): - class Meta: model = SenatorActionLog - fields = ('id', 'senator', 'action_log') + fields = ("id", "senator", "action_log") diff --git a/backend/rorapp/serializers/step.py b/backend/rorapp/serializers/step.py index 05082210..6e64939c 100644 --- a/backend/rorapp/serializers/step.py +++ b/backend/rorapp/serializers/step.py @@ -4,7 +4,6 @@ # Serializer used to read steps class StepSerializer(serializers.ModelSerializer): - class Meta: model = Step - fields = ('id', 'index', 'phase') + fields = ("id", "index", "phase") diff --git a/backend/rorapp/serializers/title.py b/backend/rorapp/serializers/title.py index 2795eae4..4cf3d510 100644 --- a/backend/rorapp/serializers/title.py +++ b/backend/rorapp/serializers/title.py @@ -4,7 +4,6 @@ # Serializer used to read titles class TitleSerializer(serializers.ModelSerializer): - class Meta: model = Title - fields = ('id', 'name', 'senator', 'start_step', 'end_step', 'major_office') + fields = ("id", "name", "senator", "start_step", "end_step", "major_office") diff --git a/backend/rorapp/serializers/token.py b/backend/rorapp/serializers/token.py index 5edc240a..a43c09fd 100644 --- a/backend/rorapp/serializers/token.py +++ b/backend/rorapp/serializers/token.py @@ -8,11 +8,11 @@ def validate(self, attrs): data = super().validate(attrs) # Add user id to the response - data['user_id'] = self.user.id + data["user_id"] = self.user.id return data # Serializer used to obtain token pair via email class TokenObtainPairByEmailSerializer(serializers.Serializer): email = serializers.EmailField() - password = serializers.CharField(style={'input_type': 'password'}) + password = serializers.CharField(style={"input_type": "password"}) diff --git a/backend/rorapp/serializers/turn.py b/backend/rorapp/serializers/turn.py index 013d7dd1..fb45b132 100644 --- a/backend/rorapp/serializers/turn.py +++ b/backend/rorapp/serializers/turn.py @@ -4,7 +4,6 @@ # Serializer used to read turns class TurnSerializer(serializers.ModelSerializer): - class Meta: model = Turn - fields = ('id', 'index', 'game') + fields = ("id", "index", "game") diff --git a/backend/rorapp/serializers/user.py b/backend/rorapp/serializers/user.py index 873375da..3143fa2f 100644 --- a/backend/rorapp/serializers/user.py +++ b/backend/rorapp/serializers/user.py @@ -6,11 +6,14 @@ class UserSerializer(serializers.ModelSerializer): class Meta: model = User - fields = ('id', 'username',) + fields = ( + "id", + "username", + ) # Serializer used to read users in detail class UserDetailSerializer(serializers.ModelSerializer): class Meta: model = User - fields = ('id', 'username', 'email') + fields = ("id", "username", "email") diff --git a/backend/rorapp/serializers/waitlist_entry.py b/backend/rorapp/serializers/waitlist_entry.py index b302751d..2ce14fc4 100644 --- a/backend/rorapp/serializers/waitlist_entry.py +++ b/backend/rorapp/serializers/waitlist_entry.py @@ -1,7 +1,8 @@ from rest_framework import serializers from rorapp.models import WaitlistEntry + class WaitlistEntryCreateSerializer(serializers.ModelSerializer): - class Meta: - model = WaitlistEntry - fields = ('email', 'entry_date') \ No newline at end of file + class Meta: + model = WaitlistEntry + fields = ("email", "entry_date") diff --git a/backend/rorapp/tests/mortality_chit_tests.py b/backend/rorapp/tests/mortality_chit_tests.py index 356f8eec..f58642a0 100644 --- a/backend/rorapp/tests/mortality_chit_tests.py +++ b/backend/rorapp/tests/mortality_chit_tests.py @@ -11,7 +11,7 @@ def test_draw_mortality_chits(self): for draw_count in range(1, 11): self.do_draw_mortality_chits_test(draw_count) - def do_draw_mortality_chits_test(self, draw_count): + def do_draw_mortality_chits_test(self, draw_count) -> None: all_possible_chit_values = list(range(1, 31)) all_drawn_chits: list = [] for i in range(5000): diff --git a/backend/rorapp/views/action_log.py b/backend/rorapp/views/action_log.py index 7c22e25a..89667dd7 100644 --- a/backend/rorapp/views/action_log.py +++ b/backend/rorapp/views/action_log.py @@ -6,20 +6,19 @@ def normalize_index(index, queryset): - # Convert index to integer try: index = int(index) except ValueError: return index - + # If index is negative then it's a reverse index, # so we convert it to the respective regular index if index < 0: - last_index = queryset.aggregate(Max('index'))['index__max'] + last_index = queryset.aggregate(Max("index"))["index__max"] if last_index is not None: index = last_index + index + 1 - + return index @@ -30,37 +29,36 @@ class ActionLogViewSet(viewsets.ReadOnlyModelViewSet): permission_classes = [IsAuthenticated] serializer_class = ActionLogSerializer - + def get_queryset(self): queryset = ActionLog.objects.all() - + # Filter against a `game` query parameter in the URL - game_id = self.request.query_params.get('game', None) + game_id = self.request.query_params.get("game", None) if game_id is not None: queryset = queryset.filter(step__phase__turn__game__id=game_id) - + # Filter against a `senator` query parameter in the URL - senator_id = self.request.query_params.get('senator', None) + senator_id = self.request.query_params.get("senator", None) if senator_id is not None: # Use an annotation to check for the existence of a related SenatorActionLog queryset = queryset.annotate( has_senator_log=Exists( SenatorActionLog.objects.filter( - senator_id=senator_id, - action_log=OuterRef('id') + senator_id=senator_id, action_log=OuterRef("id") ) ) ) # Filter only where the SenatorActionLog exists queryset = queryset.filter(has_senator_log=True) - + # Filter against a `min_index` query parameter in the URL - min_index = self.request.query_params.get('min_index', None) + min_index = self.request.query_params.get("min_index", None) if min_index is not None: queryset = queryset.filter(index__gte=normalize_index(min_index, queryset)) - + # Filter against a `max_index` query parameter in the URL - max_index = self.request.query_params.get('max_index', None) + max_index = self.request.query_params.get("max_index", None) if max_index is not None: queryset = queryset.filter(index__lte=normalize_index(max_index, queryset)) diff --git a/backend/rorapp/views/phase.py b/backend/rorapp/views/phase.py index e79b02f0..fc3e62ea 100644 --- a/backend/rorapp/views/phase.py +++ b/backend/rorapp/views/phase.py @@ -11,26 +11,26 @@ class PhaseViewSet(viewsets.ReadOnlyModelViewSet): permission_classes = [IsAuthenticated] serializer_class = PhaseSerializer - + def get_queryset(self): queryset = Phase.objects.all() - + # Filter against a `game` query parameter in the URL - game_id = self.request.query_params.get('game', None) + game_id = self.request.query_params.get("game", None) if game_id is not None: queryset = queryset.filter(turn__game__id=game_id) # Ordering - ordering = self.request.query_params.get('ordering', None) + ordering = self.request.query_params.get("ordering", None) if ordering is not None: - if ordering == 'latest': - queryset = queryset.order_by('-turn__index', '-index') + if ordering == "latest": + queryset = queryset.order_by("-turn__index", "-index") else: queryset = queryset.order_by(ordering) # Limit - limit = self.request.query_params.get('limit', None) + limit = self.request.query_params.get("limit", None) if limit is not None: - queryset = queryset[:int(limit)] + queryset = queryset[: int(limit)] return queryset diff --git a/backend/rorapp/views/senator.py b/backend/rorapp/views/senator.py index 2a2a2eee..7efd4a67 100644 --- a/backend/rorapp/views/senator.py +++ b/backend/rorapp/views/senator.py @@ -11,13 +11,13 @@ class SenatorViewSet(viewsets.ReadOnlyModelViewSet): permission_classes = [IsAuthenticated] serializer_class = SenatorSerializer - + def get_queryset(self): queryset = Senator.objects.all() - + # Filter against a `game` query parameter in the URL - game_id = self.request.query_params.get('game', None) + game_id = self.request.query_params.get("game", None) if game_id is not None: queryset = queryset.filter(game__id=game_id) - + return queryset diff --git a/backend/rorapp/views/senator_action_log.py b/backend/rorapp/views/senator_action_log.py index 5b89dd2a..bdf1b1be 100644 --- a/backend/rorapp/views/senator_action_log.py +++ b/backend/rorapp/views/senator_action_log.py @@ -11,12 +11,12 @@ class SenatorActionLogViewSet(viewsets.ReadOnlyModelViewSet): permission_classes = [IsAuthenticated] serializer_class = SenatorActionLogSerializer - + def get_queryset(self): queryset = SenatorActionLog.objects.all() - + # Filter against a `senator` query parameter in the URL - senator_id = self.request.query_params.get('senator', None) + senator_id = self.request.query_params.get("senator", None) if senator_id is not None: queryset = queryset.filter(senator__id=senator_id) diff --git a/backend/rorapp/views/step.py b/backend/rorapp/views/step.py index d5577d41..051be8e6 100644 --- a/backend/rorapp/views/step.py +++ b/backend/rorapp/views/step.py @@ -11,23 +11,23 @@ class StepViewSet(viewsets.ReadOnlyModelViewSet): permission_classes = [IsAuthenticated] serializer_class = StepSerializer - + def get_queryset(self): queryset = Step.objects.all() - + # Filter against a `game` query parameter in the URL - game_id = self.request.query_params.get('game', None) + game_id = self.request.query_params.get("game", None) if game_id is not None: queryset = queryset.filter(phase__turn__game__id=game_id) # Ordering - ordering = self.request.query_params.get('ordering', None) + ordering = self.request.query_params.get("ordering", None) if ordering is not None: queryset = queryset.order_by(ordering) # Limit - limit = self.request.query_params.get('limit', None) + limit = self.request.query_params.get("limit", None) if limit is not None: - queryset = queryset[:int(limit)] + queryset = queryset[: int(limit)] return queryset diff --git a/backend/rorapp/views/title.py b/backend/rorapp/views/title.py index 2fc8761d..b461197b 100644 --- a/backend/rorapp/views/title.py +++ b/backend/rorapp/views/title.py @@ -12,19 +12,21 @@ class TitleViewSet(viewsets.ReadOnlyModelViewSet): permission_classes = [IsAuthenticated] serializer_class = TitleSerializer - + def get_queryset(self): queryset = Title.objects.all() - + # Filter against a `game` query parameter in the URL - game_id = self.request.query_params.get('game', None) + game_id = self.request.query_params.get("game", None) if game_id is not None: queryset = queryset.filter(senator__game__id=game_id) - + # Filter against an `relevant` query parameter in the URL # Active means that the title's end step is null or the senator is dead - active = self.request.query_params.get('relevant', None) + active = self.request.query_params.get("relevant", None) if active is not None: - queryset = queryset.filter(Q(end_step__isnull=True) | Q(senator__alive=False)) - + queryset = queryset.filter( + Q(end_step__isnull=True) | Q(senator__alive=False) + ) + return queryset diff --git a/backend/rorapp/views/token.py b/backend/rorapp/views/token.py index 5e30471b..2ec8b0ec 100644 --- a/backend/rorapp/views/token.py +++ b/backend/rorapp/views/token.py @@ -7,7 +7,10 @@ from rest_framework.response import Response from rest_framework_simplejwt.tokens import RefreshToken from rest_framework_simplejwt.views import TokenObtainPairView -from rorapp.serializers import MyTokenObtainPairSerializer, TokenObtainPairByEmailSerializer +from rorapp.serializers import ( + MyTokenObtainPairSerializer, + TokenObtainPairByEmailSerializer, +) class MyTokenObtainPairView(TokenObtainPairView): @@ -17,7 +20,7 @@ class MyTokenObtainPairView(TokenObtainPairView): class TokenObtainPairByEmailView(CreateAPIView): """ Takes an email and password pair as user credentials and returns an access and refresh JSON web token pair to prove the authentication of those credentials. - Used when signing in by email instead of by username. + Used when signing in by email instead of by username. """ serializer_class = TokenObtainPairByEmailSerializer @@ -31,8 +34,7 @@ def post(self, request, format=None): try: user = User.objects.get(email=request.data["email"]) user = authenticate( - username=user.username, - password=request.data["password"] + username=user.username, password=request.data["password"] ) except ObjectDoesNotExist: user = None @@ -43,17 +45,15 @@ def post(self, request, format=None): refresh = RefreshToken.for_user(user) return Response( { - 'refresh': str(refresh), - 'access': str(refresh.access_token), - 'user_id': user.id + "refresh": str(refresh), + "access": str(refresh.access_token), + "user_id": user.id, }, - status=status.HTTP_200_OK + status=status.HTTP_200_OK, ) else: # If authentication fails then respond with a 401 status return Response( - { - 'detail': 'No active account found with the given credentials' - }, - status=status.HTTP_401_UNAUTHORIZED + {"detail": "No active account found with the given credentials"}, + status=status.HTTP_401_UNAUTHORIZED, ) diff --git a/backend/rorapp/views/turn.py b/backend/rorapp/views/turn.py index 4d7c9938..221ff30a 100644 --- a/backend/rorapp/views/turn.py +++ b/backend/rorapp/views/turn.py @@ -14,20 +14,20 @@ class TurnViewSet(viewsets.ReadOnlyModelViewSet): def get_queryset(self): queryset = Turn.objects.all() - + # Filter against a `game` query parameter in the URL - game_id = self.request.query_params.get('game', None) + game_id = self.request.query_params.get("game", None) if game_id is not None: queryset = queryset.filter(game__id=game_id) # Ordering - ordering = self.request.query_params.get('ordering', None) + ordering = self.request.query_params.get("ordering", None) if ordering is not None: queryset = queryset.order_by(ordering) # Limit - limit = self.request.query_params.get('limit', None) + limit = self.request.query_params.get("limit", None) if limit is not None: - queryset = queryset[:int(limit)] + queryset = queryset[: int(limit)] return queryset diff --git a/backend/rorapp/views/user.py b/backend/rorapp/views/user.py index af070266..aaa0886e 100644 --- a/backend/rorapp/views/user.py +++ b/backend/rorapp/views/user.py @@ -14,7 +14,7 @@ class UserViewSet(viewsets.ReadOnlyModelViewSet): queryset = User.objects.all() def get_serializer_class(self): - if self.action == 'retrieve': + if self.action == "retrieve": obj = self.get_object() if self.request.user == obj: return UserDetailSerializer diff --git a/backend/rorapp/views/waitlist_entry.py b/backend/rorapp/views/waitlist_entry.py index b2956095..b018f9a4 100644 --- a/backend/rorapp/views/waitlist_entry.py +++ b/backend/rorapp/views/waitlist_entry.py @@ -8,14 +8,16 @@ from rest_framework.throttling import UserRateThrottle from django.utils import timezone + class CustomRateThrottle(UserRateThrottle): rate = "10/hour" + class WaitlistEntryViewSet(viewsets.ModelViewSet): queryset = WaitlistEntry.objects.all() serializer_class = WaitlistEntryCreateSerializer throttle_classes = [CustomRateThrottle] - + @transaction.atomic def create(self, request, *args, **kwargs): data = request.data @@ -23,21 +25,24 @@ def create(self, request, *args, **kwargs): isEntryPresent = WaitlistEntry.objects.filter(email=data["email"]) if isEntryPresent: - return Response({"email": data["email"], "entry_date": timezone.now()}, status=status.HTTP_201_CREATED) + return Response( + {"email": data["email"], "entry_date": timezone.now()}, + status=status.HTTP_201_CREATED, + ) else: return super().create(request, *args, **kwargs) def list(self, request, *args, **kwargs): - raise MethodNotAllowed('GET') - + raise MethodNotAllowed("GET") + def retrieve(self, request, *args, **kwargs): - raise MethodNotAllowed('GET') - + raise MethodNotAllowed("GET") + def destroy(self, request, *args, **kwargs): - raise MethodNotAllowed('DELETE') - + raise MethodNotAllowed("DELETE") + def update(self, request, *args, **kwargs): - raise MethodNotAllowed('PUT') - + raise MethodNotAllowed("PUT") + def partial_update(self, request, *args, **kwargs): - raise MethodNotAllowed('PATCH') \ No newline at end of file + raise MethodNotAllowed("PATCH") diff --git a/backend/rorsite/asgi.py b/backend/rorsite/asgi.py index 46f05901..35d8ed40 100644 --- a/backend/rorsite/asgi.py +++ b/backend/rorsite/asgi.py @@ -13,7 +13,7 @@ from django.core.asgi import get_asgi_application from channels.auth import AuthMiddlewareStack -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'rorsite.settings') +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rorsite.settings") # Initialize Django ASGI application early to ensure the AppRegistry # is populated before importing code that may import ORM models. django_asgi_app = get_asgi_application() @@ -23,14 +23,11 @@ { "http": get_asgi_application(), "websocket": AllowedHostsOriginValidator( - AuthMiddlewareStack( - URLRouter( - rorapp.routing.websocket_urlpatterns - ) - ) + AuthMiddlewareStack(URLRouter(rorapp.routing.websocket_urlpatterns)) ), } ) from rorapp.middleware import jwt_auth_middleware + application = jwt_auth_middleware.JwtAuthMiddleware(application) diff --git a/backend/rorsite/wsgi.py b/backend/rorsite/wsgi.py index 9e96cb4b..8e890954 100644 --- a/backend/rorsite/wsgi.py +++ b/backend/rorsite/wsgi.py @@ -11,6 +11,6 @@ from django.core.wsgi import get_wsgi_application -os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'rorsite.settings') +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "rorsite.settings") application = get_wsgi_application() diff --git a/backend/server/s3_download.py b/backend/server/s3_download.py index f3403bef..e1d3af52 100644 --- a/backend/server/s3_download.py +++ b/backend/server/s3_download.py @@ -2,12 +2,13 @@ import os s3 = boto3.client( - 's3', - aws_access_key_id=os.getenv('AWS_ACCESS_KEY_ID'), - aws_secret_access_key=os.getenv('AWS_SECRET_ACCESS_KEY'), - region_name=os.getenv('AWS_DEFAULT_REGION') + "s3", + aws_access_key_id=os.getenv("AWS_ACCESS_KEY_ID"), + aws_secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"), + region_name=os.getenv("AWS_DEFAULT_REGION"), ) + def download_file(bucket, key, filename): try: s3.download_file(bucket, key, filename) @@ -15,6 +16,13 @@ def download_file(bucket, key, filename): except Exception as e: print(f"Error downloading {key}: {str(e)}") -download_file('api-roronline-com-ssl', 'api_roronline_com.crt', '/etc/nginx/ssl/api_roronline_com.crt') -download_file('api-roronline-com-ssl', 'certificate.key', '/etc/nginx/ssl/certificate.key') -download_file('api-roronline-com-ssl', 'ca_bundle.crt', '/etc/nginx/ssl/ca_bundle.crt') + +download_file( + "api-roronline-com-ssl", + "api_roronline_com.crt", + "/etc/nginx/ssl/api_roronline_com.crt", +) +download_file( + "api-roronline-com-ssl", "certificate.key", "/etc/nginx/ssl/certificate.key" +) +download_file("api-roronline-com-ssl", "ca_bundle.crt", "/etc/nginx/ssl/ca_bundle.crt") diff --git a/frontend/classes/Faction.ts b/frontend/classes/Faction.ts index 96bea72b..7e07890c 100644 --- a/frontend/classes/Faction.ts +++ b/frontend/classes/Faction.ts @@ -11,7 +11,18 @@ interface FactionData { custom_name?: string } -type ColorNumber = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950 +type ColorNumber = + | 50 + | 100 + | 200 + | 300 + | 400 + | 500 + | 600 + | 700 + | 800 + | 900 + | 950 class Faction { id: number diff --git a/frontend/components/AttributeGrid.tsx b/frontend/components/AttributeGrid.tsx index 6b81179e..9cd6e90a 100644 --- a/frontend/components/AttributeGrid.tsx +++ b/frontend/components/AttributeGrid.tsx @@ -33,7 +33,11 @@ const AttributeGrid = ({ attributes }: AttributeGridProps) => { style={{ userSelect: "none" }} />
- +
{item.value}
diff --git a/frontend/components/FactionIcon.tsx b/frontend/components/FactionIcon.tsx index cd000f40..c8f629a7 100644 --- a/frontend/components/FactionIcon.tsx +++ b/frontend/components/FactionIcon.tsx @@ -61,7 +61,6 @@ const FactionIcon = ({ ) - const svgInsideButton = faction ? (