From 280e02c15a93af2ded369c65f7c54864348579b9 Mon Sep 17 00:00:00 2001 From: HumanoidSandvichDispenser Date: Fri, 25 Oct 2024 17:32:43 -0700 Subject: [PATCH] Add playtime and end_time columns --- .../0005_playerinfo_team_playtime_and_more.py | 31 +++++++++++++++++++ backend/api/models.py | 10 +++--- 2 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 backend/api/migrations/0005_playerinfo_team_playtime_and_more.py diff --git a/backend/api/migrations/0005_playerinfo_team_playtime_and_more.py b/backend/api/migrations/0005_playerinfo_team_playtime_and_more.py new file mode 100644 index 0000000..176e03b --- /dev/null +++ b/backend/api/migrations/0005_playerinfo_team_playtime_and_more.py @@ -0,0 +1,31 @@ +# Generated by Django 5.1.2 on 2024-10-26 00:32 + +import datetime +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('api', '0004_remove_playermasteravailability_unique_master_availability_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='playerinfo_team', + name='playtime', + field=models.DurationField(default=datetime.timedelta(0)), + ), + migrations.AddField( + model_name='playermasteravailability', + name='end_time', + field=models.DateTimeField(default=datetime.datetime(2024, 10, 26, 0, 32, 4, 805564, tzinfo=datetime.timezone.utc)), + preserve_default=False, + ), + migrations.AddField( + model_name='playerteamavailability', + name='end_time', + field=models.DateTimeField(default=datetime.datetime(2024, 10, 26, 0, 32, 13, 959511, tzinfo=datetime.timezone.utc)), + preserve_default=False, + ), + ] diff --git a/backend/api/models.py b/backend/api/models.py index a3fa80c..93ecca6 100644 --- a/backend/api/models.py +++ b/backend/api/models.py @@ -1,3 +1,4 @@ +from datetime import timedelta from typing import override from django.db import models from cpkmodel import CPkModel @@ -44,6 +45,7 @@ class PlayerInfo_Team(models.Model): choices=TeamRole.choices, default=TeamRole.PLAYER ) + playtime = models.DurationField(default=timedelta(0)) created_at = models.DateTimeField(auto_now_add=True) @override @@ -88,8 +90,8 @@ class PlayerRole(models.Model): class PlayerTeamAvailability(models.Model): player_info_team = models.ForeignKey(PlayerInfo_Team, on_delete=models.CASCADE) - date = models.DateField() - hour = models.SmallIntegerField() + start_time = models.DateTimeField() + end_time = models.DateTimeField() class Meta: constraints = [ @@ -105,8 +107,8 @@ class PlayerTeamAvailability(models.Model): class PlayerMasterAvailability(models.Model): player_info = models.ForeignKey(PlayerInfo, on_delete=models.CASCADE) - date = models.DateField() - hour = models.SmallIntegerField() + start_time = models.DateTimeField() + end_time = models.DateTimeField() class Meta: constraints = [