Skip to content

Commit

Permalink
Format code files (#520)
Browse files Browse the repository at this point in the history
  • Loading branch information
iamlogand authored Jul 21, 2024
1 parent 5fe01ec commit b0d5600
Show file tree
Hide file tree
Showing 149 changed files with 1,217 additions and 871 deletions.
2 changes: 1 addition & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion backend/docker-compose.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ services:

web:
build: .
command: ["/app/server/start.sh"]
command: [ "/app/server/start.sh" ]
volumes:
- .:/app
- static_volume:/app/staticfiles
Expand Down
6 changes: 3 additions & 3 deletions backend/docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion backend/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions backend/manage.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -18,5 +19,5 @@ def main():
execute_from_command_line(sys.argv)


if __name__ == '__main__':
if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions backend/rorapp/admin/concession.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
11 changes: 10 additions & 1 deletion backend/rorapp/admin/enemy_leader.py
Original file line number Diff line number Diff line change
@@ -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",
)
2 changes: 1 addition & 1 deletion backend/rorapp/admin/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
2 changes: 1 addition & 1 deletion backend/rorapp/admin/senator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
2 changes: 1 addition & 1 deletion backend/rorapp/admin/senator_action_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
2 changes: 1 addition & 1 deletion backend/rorapp/admin/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
9 changes: 8 additions & 1 deletion backend/rorapp/admin/title.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
)
2 changes: 1 addition & 1 deletion backend/rorapp/admin/turn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
2 changes: 1 addition & 1 deletion backend/rorapp/admin/waitlist_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
4 changes: 2 additions & 2 deletions backend/rorapp/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 1 addition & 2 deletions backend/rorapp/functions/concession_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion backend/rorapp/functions/game_deleter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 1 addition & 3 deletions backend/rorapp/functions/mortality_phase_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion backend/rorapp/management/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .commands import Command # noqa: F401
from .commands import Command # noqa: F401
2 changes: 1 addition & 1 deletion backend/rorapp/management/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .createsu import Command
from .createsu import Command
11 changes: 4 additions & 7 deletions backend/rorapp/management/commands/createsu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
if not User.objects.filter(username="tempsuperuser").exists():
User.objects.create_superuser(username="tempsuperuser", password="password")
print("Superuser has been created.")
18 changes: 12 additions & 6 deletions backend/rorapp/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
],
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
]
13 changes: 8 additions & 5 deletions backend/rorapp/migrations/0003_game_owner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
]
7 changes: 3 additions & 4 deletions backend/rorapp/migrations/0005_alter_game_creation_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
]
7 changes: 3 additions & 4 deletions backend/rorapp/migrations/0006_alter_game_start_date.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
),
]
Loading

0 comments on commit b0d5600

Please sign in to comment.