parent
811a0966d5
commit
24cb89e6ee
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class AccountsConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'accounts'
|
@ -0,0 +1,32 @@
|
||||
# Generated by Django 3.2.13 on 2022-05-04 18:30
|
||||
|
||||
import django.contrib.auth.models
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('auth', '0012_alter_user_first_name_max_length'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='HockeyUser',
|
||||
fields=[
|
||||
('user_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='auth.user')),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'user',
|
||||
'verbose_name_plural': 'users',
|
||||
'abstract': False,
|
||||
},
|
||||
bases=('auth.user',),
|
||||
managers=[
|
||||
('objects', django.contrib.auth.models.UserManager()),
|
||||
],
|
||||
),
|
||||
]
|
Binary file not shown.
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
from django.contrib.auth.models import User
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
class HockeyUser(User):
|
||||
pass
|
||||
def __str__(self):
|
||||
return f"{self.username}"
|
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,33 @@
|
||||
from .models import Player, Team, Season, Goal, Game, Division
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
||||
@admin.register(Player)
|
||||
class PlayerAdmin(admin.ModelAdmin):
|
||||
list_display = ["last_name", "first_name"]
|
||||
search_fields = ["last_name", "first_name"]
|
||||
|
||||
@admin.register(Season)
|
||||
class SeasonAdmin(admin.ModelAdmin):
|
||||
list_display = ["name", "start_date", "end_date"]
|
||||
list_display = ["name", "start_date", "end_date"]
|
||||
|
||||
@admin.register(Game)
|
||||
class GameAdmin(admin.ModelAdmin):
|
||||
list_display = ["name", "home_team", "away_team", "date_of", "time_of"]
|
||||
search_fields = ["name", "home_team", "away_team", "date_of", "time_of"]
|
||||
|
||||
@admin.register(Goal)
|
||||
class GoalAdmin(admin.ModelAdmin):
|
||||
list_display = ["game", "scorer"]
|
||||
search_fields = ["game", "scorer"]
|
||||
|
||||
@admin.register(Team)
|
||||
class TeamAdmin(admin.ModelAdmin):
|
||||
list_display = ["name", "season"]
|
||||
search_fields = ["name", "season"]
|
||||
|
||||
@admin.register(Division)
|
||||
class DivisionAdmin(admin.ModelAdmin):
|
||||
list_display = ["name"]
|
||||
search_fields = ["name"]
|
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class CoreConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'core'
|
Binary file not shown.
@ -0,0 +1,18 @@
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from core.models import Player, Team, Season, Penelty
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Populate database with teams from a CSV.'
|
||||
|
||||
def load_teams(self):
|
||||
pass
|
||||
|
||||
# TODO: find way to add argument
|
||||
def add_argument(self, parser):
|
||||
pass
|
||||
|
||||
def handle(self, *args, **kwargs):
|
||||
self.stdout.write("Populating teams...")
|
||||
self.load_teams()
|
||||
print(kwargs["csv_file"])
|
||||
self.stdout.write(self.style.SUCCESS('Successfully populate teams from {}.'))
|
@ -0,0 +1,21 @@
|
||||
from django.core.management.base import BaseCommand, CommandError
|
||||
from core.models import Player, Team, Season, Penelty
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = 'Populate database with csv stats.'
|
||||
|
||||
LOADING_FUNCTIONS = [
|
||||
self.get_csvs,
|
||||
self.load_csvs
|
||||
]
|
||||
|
||||
def get_csvs(self):
|
||||
pass
|
||||
|
||||
def load_csvs(self):
|
||||
pass
|
||||
|
||||
def handle(self, *args, **kwargs):
|
||||
self.stdout.write("Populating CSVs...")
|
||||
self.load_csvs()
|
||||
self.stdout.write(self.style.SUCCESS('Successfully populated CSV files into database.'))
|
@ -0,0 +1,83 @@
|
||||
# Generated by Django 3.2.13 on 2022-05-04 19:20
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Division',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=64)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Game',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('_name', models.CharField(blank=True, max_length=64, null=True)),
|
||||
('date_of', models.DateField()),
|
||||
('time_of', models.TimeField(blank=True, null=True)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Season',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=32)),
|
||||
('start_date', models.DateField(blank=True, null=True)),
|
||||
('end_date', models.DateField(blank=True, null=True)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Team',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=32)),
|
||||
('division', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='teams', to='core.division')),
|
||||
('season', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='teams', to='core.season')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Player',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('first_name', models.CharField(blank=True, max_length=32)),
|
||||
('last_name', models.CharField(max_length=32)),
|
||||
('middle_names', models.CharField(blank=True, max_length=64)),
|
||||
('teams', models.ManyToManyField(blank=True, related_name='players', to='core.Team')),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Goal',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('assists', models.ManyToManyField(blank=True, related_name='assists', to='core.Player')),
|
||||
('game', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='goals', to='core.game')),
|
||||
('scorer', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='goals', to='core.player')),
|
||||
],
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='game',
|
||||
name='away_team',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='away_games', to='core.team'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='game',
|
||||
name='home_team',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='home_games', to='core.team'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='game',
|
||||
name='season',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='games', to='core.season'),
|
||||
),
|
||||
]
|
@ -0,0 +1,32 @@
|
||||
# Generated by Django 3.2.13 on 2022-05-04 21:24
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='goal',
|
||||
name='period',
|
||||
field=models.IntegerField(choices=[(1, '1st'), (2, '2nd'), (3, '3rd'), (4, 'OT'), (5, '2OT'), (6, '3OT'), (7, '4OT'), (8, '5OT'), (9, '6OT'), (0, 'SO')], default=1),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='goal',
|
||||
name='time',
|
||||
field=models.DurationField(blank=True, null=True),
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Shot',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('game', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='shots', to='core.game')),
|
||||
('shooter', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='shots', to='core.player')),
|
||||
],
|
||||
),
|
||||
]
|
@ -0,0 +1,23 @@
|
||||
# Generated by Django 3.2.13 on 2022-05-04 21:25
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0002_auto_20220504_2124'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='shot',
|
||||
name='period',
|
||||
field=models.IntegerField(choices=[(1, '1st'), (2, '2nd'), (3, '3rd'), (4, 'OT'), (5, '2OT'), (6, '3OT'), (7, '4OT'), (8, '5OT'), (9, '6OT'), (0, 'SO')], default=1),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='shot',
|
||||
name='time',
|
||||
field=models.DurationField(blank=True, null=True),
|
||||
),
|
||||
]
|
@ -0,0 +1,17 @@
|
||||
# Generated by Django 3.2.13 on 2022-05-04 22:59
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0003_auto_20220504_2125'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameModel(
|
||||
old_name='Shot',
|
||||
new_name='ShotOnGoal',
|
||||
),
|
||||
]
|
@ -0,0 +1,17 @@
|
||||
# Generated by Django 3.2.13 on 2022-05-04 22:59
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0004_rename_shot_shotongoal'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameModel(
|
||||
old_name='ShotOnGoal',
|
||||
new_name='Shot',
|
||||
),
|
||||
]
|
@ -0,0 +1,34 @@
|
||||
# Generated by Django 3.2.13 on 2022-05-04 23:06
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0005_rename_shotongoal_shot'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='goal',
|
||||
name='goalie',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='goals_on', to='core.player'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='shot',
|
||||
name='blocker',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='blocked_shots', to='core.player'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='shot',
|
||||
name='goalie',
|
||||
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='shots_on', to='core.player'),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='shot',
|
||||
name='shot_type',
|
||||
field=models.CharField(choices=[('O', 'On Goal'), ('M', 'Missed'), ('B', 'Blocked')], default='O', max_length=1),
|
||||
),
|
||||
]
|
@ -0,0 +1,45 @@
|
||||
# Generated by Django 3.2.13 on 2022-05-04 23:42
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0006_auto_20220504_2306'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='PeneltyLength',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(choices=[('M', 'Minor'), ('D', 'Double Minor'), ('J', 'Major'), ('C', 'Misconduct'), ('G', 'Game Misconduct'), ('S', 'Shot')], max_length=1)),
|
||||
('length', models.DurationField()),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='PeneltyType',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('name', models.CharField(choices=[('B', 'Boarding'), ('C', 'Charging'), ('D', 'Delay of Game'), ('X', 'Cross-Checking'), ('E', 'Elbowing'), ('G', 'Grasping the Facemask'), ('H', 'High Sticking'), ('O', 'Holding'), ('K', 'Hooking'), ('I', 'Interference'), ('M', 'Miscounduct'), ('R', 'Roughing'), ('S', 'Slashing'), ('P', 'Spearing'), ('T', 'Tripping'), ('U', 'Unsportsmanlike Conduct')], max_length=1)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Penelty',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('penelty_classification', models.CharField(choices=[('I', 'Individual'), ('T', 'Team')], default='I', max_length=1)),
|
||||
('period', models.IntegerField(choices=[(1, '1st'), (2, '2nd'), (3, '3rd'), (4, 'OT'), (5, '2OT'), (6, '3OT'), (7, '4OT'), (8, '5OT'), (9, '6OT'), (0, 'SO')])),
|
||||
('time', models.DurationField()),
|
||||
('drawn_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='penelties_drawn', to='core.player')),
|
||||
('game', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='penelties', to='core.game')),
|
||||
('on_ind', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='penelties_given', to='core.player')),
|
||||
('on_team', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='penelties_given', to='core.team')),
|
||||
('penelty_length', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='given_out', to='core.peneltylength')),
|
||||
('penelty_type', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='given_out', to='core.peneltytype')),
|
||||
('served_by', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='penelties_served', to='core.player')),
|
||||
],
|
||||
),
|
||||
]
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,134 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
class Season(models.Model):
|
||||
name = models.CharField(max_length=32, blank=False, null=False)
|
||||
start_date = models.DateField(blank=True, null=True)
|
||||
end_date = models.DateField(blank=True, null=True)
|
||||
|
||||
class Division(models.Model):
|
||||
name = models.CharField(max_length=64, blank=False, null=False)
|
||||
|
||||
class Team(models.Model):
|
||||
name = models.CharField(max_length=32, blank=False, null=False)
|
||||
season = models.ForeignKey(Season, related_name="teams", on_delete=models.PROTECT, blank=False, null=False)
|
||||
division = models.ForeignKey(Division, related_name="teams", on_delete=models.PROTECT, blank=False, null=False)
|
||||
|
||||
class Player(models.Model):
|
||||
first_name = models.CharField(max_length=32, blank=True, null=False)
|
||||
last_name = models.CharField(max_length=32, blank=False, null=False)
|
||||
middle_names = models.CharField(max_length=64, blank=True, null=False)
|
||||
teams = models.ManyToManyField(Team, related_name="players", blank=True)
|
||||
|
||||
class Game(models.Model):
|
||||
_name = models.CharField(max_length=64, blank=True, null=True)
|
||||
home_team = models.ForeignKey(Team, related_name="home_games", on_delete=models.PROTECT, blank=True, null=True)
|
||||
away_team = models.ForeignKey(Team, related_name="away_games", on_delete=models.PROTECT, blank=True, null=True)
|
||||
season = models.ForeignKey(Season, related_name="games", on_delete=models.PROTECT, blank=False, null=False)
|
||||
date_of = models.DateField(blank=False, null=False)
|
||||
time_of = models.TimeField(blank=True, null=True)
|
||||
|
||||
def name(self):
|
||||
return name if name else f"{home_team} v. {away_team}"
|
||||
|
||||
PERIOD_CHOICES = [
|
||||
(1, "1st"),
|
||||
(2, "2nd"),
|
||||
(3, "3rd"),
|
||||
(4, "OT"),
|
||||
(5, "2OT"),
|
||||
(6, "3OT"),
|
||||
(7, "4OT"),
|
||||
(8, "5OT"),
|
||||
(9, "6OT"),
|
||||
(0, "SO")
|
||||
]
|
||||
|
||||
class Goal(models.Model):
|
||||
scorer = models.ForeignKey(Player, related_name="goals", on_delete=models.PROTECT, blank=False, null=False)
|
||||
game = models.ForeignKey(Game, related_name="goals", on_delete=models.PROTECT, blank=False, null=False)
|
||||
# NOTE: may be null if empty net
|
||||
goalie = models.ForeignKey(Player, related_name="goals_on", on_delete=models.PROTECT, blank=True, null=True)
|
||||
assists = models.ManyToManyField(Player, related_name="assists", blank=True)
|
||||
period = models.IntegerField(choices=PERIOD_CHOICES, blank=False, null=False, default=1)
|
||||
time = models.DurationField(blank=True, null=True)
|
||||
# TODO allow no time column during SO
|
||||
|
||||
class Shot(models.Model):
|
||||
SHOT_TYPE_CHOICES = [
|
||||
("O", "On Goal"),
|
||||
("M", "Missed"),
|
||||
("B", "Blocked"),
|
||||
]
|
||||
# NOTE: default shot type is "on goal"
|
||||
shot_type = models.CharField(max_length=1, choices=SHOT_TYPE_CHOICES, blank=False, null=False, default="O")
|
||||
shooter = models.ForeignKey(Player, related_name="shots", on_delete=models.PROTECT, blank=False, null=False)
|
||||
game = models.ForeignKey(Game, related_name="shots", on_delete=models.PROTECT, blank=False, null=False)
|
||||
period = models.IntegerField(choices=PERIOD_CHOICES, blank=False, null=False, default=1)
|
||||
time = models.DurationField(blank=True, null=True)
|
||||
# NOTE: the goalie the shot was on; note that only player.shots_on.filter(shot_type="O") count as saved goals
|
||||
# NOTE: may be blank if an attempt is made on an open net
|
||||
goalie = models.ForeignKey(Player, related_name="shots_on", on_delete=models.PROTECT, blank=True, null=True)
|
||||
# TODO allow no time column during SO
|
||||
# this is only set in the case of a shot_type="B" for blocked
|
||||
blocker = models.ForeignKey(Player, related_name="blocked_shots", on_delete=models.PROTECT, blank=True, null=True)
|
||||
|
||||
# NOTE: game misconducts will eject a player from the game, but the penelty may be served by another player
|
||||
class PeneltyLength(models.Model):
|
||||
PENELTY_LENGTH_CHOICES = [
|
||||
("M", "Minor"), # 2 mins in NHL
|
||||
("D", "Double Minor"), # 4 mins in NHL
|
||||
("J", "Major"), # 5 mins in NHL
|
||||
("C", "Misconduct"), # 10 mins in NHL
|
||||
("G", "Game Misconduct"), # ejection from game in NHL
|
||||
("S", "Shot"), # penelty shot
|
||||
]
|
||||
name = models.CharField(max_length=1, choices=PENELTY_LENGTH_CHOICES, blank=False, null=False)
|
||||
length = models.DurationField(blank=False, null=False)
|
||||
|
||||
# NOTE: i.e.: "Minor (2:00)", or "Misconduct (10:00")", or "Shot"
|
||||
# TODO: filter shot
|
||||
def __str__(self):
|
||||
return f"{self.name} ({self.length})"
|
||||
|
||||
class PeneltyType(models.Model):
|
||||
PENELTY_TYPE_CHOICES = [
|
||||
("B", "Boarding"),
|
||||
("C", "Charging"),
|
||||
("D", "Delay of Game"),
|
||||
("X", "Cross-Checking"),
|
||||
("E", "Elbowing"),
|
||||
("G", "Grasping the Facemask"),
|
||||
("H", "High Sticking"),
|
||||
("O", "Holding"),
|
||||
("K", "Hooking"),
|
||||
("I", "Interference"),
|
||||
("M", "Miscounduct"), # see above where misconduct equals 10 minutes
|
||||
("R", "Roughing"),
|
||||
("S", "Slashing"),
|
||||
("P", "Spearing"),
|
||||
("T", "Tripping"),
|
||||
("U", "Unsportsmanlike Conduct"),
|
||||
]
|
||||
name = models.CharField(max_length=1, choices=PENELTY_TYPE_CHOICES, blank=False, null=False)
|
||||
|
||||
class Penelty(models.Model):
|
||||
PENELTY_GIVEN_CHOICES = [
|
||||
("I", "Individual"),
|
||||
("T", "Team"), # e.g., too many men
|
||||
]
|
||||
# default="I" because individual penelties are much more common
|
||||
penelty_classification = models.CharField(max_length=1, choices=PENELTY_GIVEN_CHOICES, blank=False, null=False, default="I")
|
||||
penelty_type = models.ForeignKey(PeneltyType, related_name="given_out", on_delete=models.PROTECT, blank=False, null=False)
|
||||
penelty_length = models.ForeignKey(PeneltyLength, related_name="given_out", on_delete=models.PROTECT, blank=False, null=False)
|
||||
game = models.ForeignKey(Game, related_name="penelties", on_delete=models.PROTECT, blank=False, null=False)
|
||||
# NOTE: may be none if team penelty like too many men
|
||||
on_ind = models.ForeignKey(Player, related_name="penelties_given", on_delete=models.PROTECT, blank=True, null=True)
|
||||
# NOTE: may be noen if individual penelty
|
||||
on_team = models.ForeignKey(Team, related_name="penelties_given", on_delete=models.PROTECT, blank=True, null=True)
|
||||
# NOTE: some player will ALWAYS serve the penelty
|
||||
served_by = models.ForeignKey(Player, related_name="penelties_served", on_delete=models.PROTECT, blank=False, null=False)
|
||||
# NOTE: an indiviaul will not be named in the case of a delay of game; some misconducts, like swearing at a referee also would not list a "drawn_by"
|
||||
drawn_by = models.ForeignKey(Player, related_name="penelties_drawn", on_delete=models.PROTECT, blank=True, null=True)
|
||||
period = models.IntegerField(choices=PERIOD_CHOICES, blank=False, null=False)
|
||||
time = models.DurationField(blank=False, null=False)
|
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
@ -0,0 +1,3 @@
|
||||
from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
|
|
|
|
Can't render this file because it has a wrong number of fields in line 6.
|
|
Can't render this file because it has a wrong number of fields in line 9.
|
|
|
Can't render this file because it has a wrong number of fields in line 15.
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue