Skip to content

Commit

Permalink
Allow teams to not have a location
Browse files Browse the repository at this point in the history
Last year we had teams for Volunteers and "No Team", this lets us have that without making a location for "N/A"
  • Loading branch information
raccube committed Apr 10, 2024
1 parent 1adcb1f commit 778ffbe
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion helpdesk/teams/management/commands/import_from_srcomp.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ def _import_teams(self, srcomp_url: str) -> None:
)

# If not created, synchronise the pit locations.
if not created and team.pit_location.slug != team_data["location"]["name"]:
if not created and team.pit_location and team.pit_location.slug != team_data["location"]["name"]:
team.pit_location = TeamPitLocation.objects.get(slug=team_data["location"]["name"])
team.save(update_fields=["pit_location"])
22 changes: 22 additions & 0 deletions helpdesk/teams/migrations/0005_make_team_location_optional.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.11 on 2024-04-10 18:14

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("teams", "0004_add_team_comment"),
]

operations = [
migrations.AlterModelOptions(
name="team",
options={"ordering": ["tla"]},
),
migrations.AlterField(
model_name="team",
name="pit_location",
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.PROTECT, to="teams.teampitlocation"),
),
]
2 changes: 1 addition & 1 deletion helpdesk/teams/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Team(models.Model):
)
name = models.CharField("Team Name", max_length=100)
is_rookie = models.BooleanField("Is Rookie")
pit_location = models.ForeignKey(TeamPitLocation, on_delete=models.PROTECT)
pit_location = models.ForeignKey(TeamPitLocation, on_delete=models.PROTECT, null=True)

class Meta:
ordering = ["tla"]
Expand Down

0 comments on commit 778ffbe

Please sign in to comment.