Skip to content

Commit fd0d1f8

Browse files
committed
Add country code field to driver and team
1 parent 865449d commit fd0d1f8

9 files changed

+1454
-1387
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
repos:
22
- repo: https://github.com/astral-sh/ruff-pre-commit
33
# Ruff version.
4-
rev: v0.8.3
4+
rev: v0.9.9
55
hooks:
66
# Run the linter.
77
- id: ruff

docs/database.svg

+1,339-1,331
Loading

jolpica/formula_one/importer/json_models.py

+2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ class TeamObject(F1ObjectSchema):
107107
reference: str | None = None
108108
name: str | None = None
109109
nationality: str | None = None
110+
country_code: str | None = Field(None, max_length=3)
110111
wikipedia: HttpUrl | None = None
111112

112113

@@ -126,6 +127,7 @@ class DriverObject(F1ObjectSchema):
126127
surname: str | None = None
127128
abbreviation: str | None = None
128129
nationality: str | None = None
130+
country_code: str | None = Field(None, max_length=3)
129131
permanent_car_number: PositiveInt | None = None
130132
date_of_birth: date | None = None
131133
wikipedia: HttpUrl | None = None
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Generated by Django 5.1.6 on 2025-03-02 20:06
2+
3+
import django.db.models.deletion
4+
from django.db import migrations, models
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
("formula_one", "0003_lap_is_deleted"),
11+
]
12+
13+
operations = [
14+
migrations.AddField(
15+
model_name="driver",
16+
name="country_code",
17+
field=models.CharField(
18+
blank=True,
19+
max_length=3,
20+
null=True,
21+
verbose_name="3 Letter country code (ISO 3166-1 alpha-3)",
22+
),
23+
),
24+
migrations.AddField(
25+
model_name="team",
26+
name="country_code",
27+
field=models.CharField(
28+
blank=True,
29+
max_length=3,
30+
null=True,
31+
verbose_name="3 Letter country code (ISO 3166-1 alpha-3)",
32+
),
33+
),
34+
migrations.AlterField(
35+
model_name="session",
36+
name="point_system",
37+
field=models.ForeignKey(
38+
default=1,
39+
on_delete=django.db.models.deletion.PROTECT,
40+
related_name="sessions",
41+
to="formula_one.pointsystem",
42+
),
43+
),
44+
]

jolpica/formula_one/models/driver.py

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class Driver(models.Model):
2727
surname = models.CharField(max_length=255)
2828
abbreviation = models.CharField(max_length=10, null=True, blank=True)
2929
nationality = models.CharField(max_length=255, null=True, blank=True)
30+
country_code = models.CharField("3 Letter country code (ISO 3166-1 alpha-3)", max_length=3, null=True, blank=True)
3031
permanent_car_number = models.PositiveSmallIntegerField(null=True, blank=True)
3132
date_of_birth = models.DateField(null=True, blank=True)
3233
wikipedia = models.URLField(max_length=255, null=True, blank=True)

jolpica/formula_one/models/models.dbml

+2
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ May track reserve drivers with no sessions, or junior drivers only taking part i
254254
surname char [not null]
255255
abbreviation char [null]
256256
nationality char [null]
257+
country_code char [null]
257258
permanent_car_number positive_small_integer [null]
258259
date_of_birth date [null]
259260
wikipedia url [null]
@@ -528,6 +529,7 @@ Information about a Constructor / Team
528529
reference char [unique, null]
529530
name char [not null]
530531
nationality char [null]
532+
country_code char [null]
531533
wikipedia url [null]
532534

533535
indexes {

jolpica/formula_one/models/team.py

+1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class Team(models.Model):
3737
reference = models.CharField(max_length=32, unique=True, null=True, blank=True)
3838
name = models.CharField(max_length=255)
3939
nationality = models.CharField(max_length=255, null=True, blank=True)
40+
country_code = models.CharField("3 Letter country code (ISO 3166-1 alpha-3)", max_length=3, null=True, blank=True)
4041
wikipedia = models.URLField(max_length=255, null=True, blank=True)
4142

4243
def __str__(self) -> str:

jolpica/formula_one/tests/imports/test_deserialisers.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,9 @@ def test_factory_deserialisers_require_at_least_one_object():
260260
data = {"object_type": object_type, "foreign_keys": {}, "objects": []}
261261
result = deserialiser.deserialise(data)
262262

263-
assert "too_short" in [
264-
error["type"] for error in result.errors if "objects" in error["loc"]
265-
], "Not all deserialisers requite at least 1 object"
263+
assert "too_short" in [error["type"] for error in result.errors if "objects" in error["loc"]], (
264+
"Not all deserialisers requite at least 1 object"
265+
)
266266

267267

268268
@pytest.fixture

poetry.lock

+61-52
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)