Skip to content

Commit

Permalink
Update to Django 5
Browse files Browse the repository at this point in the history
This commit updates the Python version to 3.11 and bumps packages to
their update, most notably Django to version 5. There were some problems
with updating to 3.12 so we'll keep it lower for now.

This new version of Django brings some deprecations, such as model table
indexing being more explicit. Migrations are also needed for this.
  • Loading branch information
tienne-B committed May 9, 2024
1 parent dd86433 commit b234434
Show file tree
Hide file tree
Showing 34 changed files with 1,737 additions and 917 deletions.
2 changes: 1 addition & 1 deletion .python-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.9.12
3.11.9
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version: 2
build:
os: ubuntu-20.04
tools:
python: "3.9"
python: "3.12"

# Build documentation in the docs/ directory with Sphinx
sphinx:
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# run the application specified. docker-compose does not use this.

# Grab a python image
FROM python:3.9
FROM python:3.11
SHELL ["/bin/bash", "--login", "-c"]

# Just needed for all things python (note this is setting an env variable)
Expand Down
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ sphinx-rtd-theme = "*"
sphinx-intl = "*"

[requires]
python_version = "3.9"
python_version = "3.11"
2,035 changes: 1,164 additions & 871 deletions Pipfile.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion render.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ services:
- key: DJANGO_SECRET_KEY
generateValue: true
- key: PYTHON_VERSION
value: "3.9.9"
value: "3.12.3"
- key: WEB_CONCURRENCY
value: 4
- key: TAB_DIRECTOR_EMAIL
Expand Down
2 changes: 1 addition & 1 deletion runtime.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python-3.9.12
python-3.11.9
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Generated by Django 5.0.4 on 2024-05-04 13:21

import utils.models
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('adjallocation', '0009_auto_20200902_1208'),
('draw', '0008_alter_debateteam_side_alter_teamsideallocation_side'),
('participants', '0021_team_seed'),
]

operations = [
migrations.AlterUniqueTogether(
name='adjudicatoradjudicatorconflict',
unique_together=set(),
),
migrations.AlterUniqueTogether(
name='adjudicatorinstitutionconflict',
unique_together=set(),
),
migrations.AlterUniqueTogether(
name='adjudicatorteamconflict',
unique_together=set(),
),
migrations.AlterUniqueTogether(
name='debateadjudicator',
unique_together=set(),
),
migrations.AlterUniqueTogether(
name='teaminstitutionconflict',
unique_together=set(),
),
migrations.AddConstraint(
model_name='adjudicatoradjudicatorconflict',
constraint=utils.models.UniqueConstraint(fields=('adjudicator1', 'adjudicator2'), name='adjallo_adjudicatoradjudicatorconflict_adjudicator1__adjudicator2_uniq'),
),
migrations.AddConstraint(
model_name='adjudicatorinstitutionconflict',
constraint=utils.models.UniqueConstraint(fields=('adjudicator', 'institution'), name='adjallo_adjudicatorinstitutionconflict_adjudicator__institution_uniq'),
),
migrations.AddConstraint(
model_name='adjudicatorteamconflict',
constraint=utils.models.UniqueConstraint(fields=('adjudicator', 'team'), name='adjallo_adjudicatorteamconflict_adjudicator__team_uniq'),
),
migrations.AddConstraint(
model_name='debateadjudicator',
constraint=utils.models.UniqueConstraint(fields=('debate', 'adjudicator'), name='adjallo_debateadjudicator_debate__adjudicator_uniq'),
),
migrations.AddConstraint(
model_name='teaminstitutionconflict',
constraint=utils.models.UniqueConstraint(fields=('team', 'institution'), name='adjallo_teaminstitutionconflict_team__institution_uniq'),
),
]
12 changes: 7 additions & 5 deletions tabbycat/adjallocation/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from django.db import models
from django.utils.translation import gettext_lazy as _

from utils.models import UniqueConstraint


class DebateAdjudicatorManager(models.Manager):
use_for_related_fields = True
Expand Down Expand Up @@ -31,9 +33,9 @@ class DebateAdjudicator(models.Model):
timing_confirmed = models.BooleanField(null=True, verbose_name=_("available?"))

class Meta:
constraints = [UniqueConstraint(fields=['debate', 'adjudicator'])]
verbose_name = _("debate adjudicator")
verbose_name_plural = _("debate adjudicators")
unique_together = ('debate', 'adjudicator')

def __str__(self):
return '{} in {} ({})'.format(self.adjudicator, self.debate, self.get_type_display())
Expand All @@ -50,9 +52,9 @@ class AdjudicatorTeamConflict(models.Model):
verbose_name=_("team"))

class Meta:
constraints = [UniqueConstraint(fields=['adjudicator', 'team'])]
verbose_name = _("adjudicator-team conflict")
verbose_name_plural = _("adjudicator-team conflicts")
unique_together = ('adjudicator', 'team')

def __str__(self):
return '{} with {}'.format(self.adjudicator, self.team)
Expand All @@ -67,9 +69,9 @@ class AdjudicatorAdjudicatorConflict(models.Model):
verbose_name=_("adjudicator 2"))

class Meta:
constraints = [UniqueConstraint(fields=['adjudicator1', 'adjudicator2'])]
verbose_name = _("adjudicator-adjudicator conflict")
verbose_name_plural = _("adjudicator-adjudicator conflicts")
unique_together = ('adjudicator1', 'adjudicator2')

def __str__(self):
return '{} with {}'.format(self.adjudicator1, self.adjudicator2)
Expand All @@ -82,9 +84,9 @@ class AdjudicatorInstitutionConflict(models.Model):
verbose_name=_("institution"))

class Meta:
constraints = [UniqueConstraint(fields=['adjudicator', 'institution'])]
verbose_name = _("adjudicator-institution conflict")
verbose_name_plural = _("adjudicator-institution conflicts")
unique_together = ('adjudicator', 'institution')

def __str__(self):
return '{} with {}'.format(self.adjudicator, self.institution)
Expand All @@ -97,9 +99,9 @@ class TeamInstitutionConflict(models.Model):
verbose_name=_("institution"))

class Meta:
constraints = [UniqueConstraint(fields=['team', 'institution'])]
verbose_name = _("team-institution conflict")
verbose_name_plural = _("team-institution conflicts")
unique_together = ('team', 'institution')

def __str__(self):
return '{} with {}'.format(self.team, self.institution)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Generated by Django 5.0.4 on 2024-05-04 13:21

import utils.models
from django.conf import settings
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('adjallocation', '0010_alter_adjudicatoradjudicatorconflict_unique_together_and_more'),
('adjfeedback', '0014_alter_adjudicatorfeedback_submitter_type'),
('draw', '0008_alter_debateteam_side_alter_teamsideallocation_side'),
('participants', '0021_team_seed'),
('tournaments', '0010_alter_round_draw_type'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.AlterUniqueTogether(
name='adjudicatorfeedback',
unique_together=set(),
),
migrations.AlterUniqueTogether(
name='adjudicatorfeedbackbooleananswer',
unique_together=set(),
),
migrations.AlterUniqueTogether(
name='adjudicatorfeedbackfloatanswer',
unique_together=set(),
),
migrations.AlterUniqueTogether(
name='adjudicatorfeedbackintegeranswer',
unique_together=set(),
),
migrations.AlterUniqueTogether(
name='adjudicatorfeedbackmanyanswer',
unique_together=set(),
),
migrations.AlterUniqueTogether(
name='adjudicatorfeedbackquestion',
unique_together=set(),
),
migrations.AlterUniqueTogether(
name='adjudicatorfeedbackstringanswer',
unique_together=set(),
),
migrations.AddConstraint(
model_name='adjudicatorfeedback',
constraint=utils.models.UniqueConstraint(fields=('adjudicator', 'source_adjudicator', 'source_team', 'version'), name='adjfeed_adjudicatorfeedback_adjudicator__source_adjudicator__source_team__version_uniq'),
),
migrations.AddConstraint(
model_name='adjudicatorfeedbackbooleananswer',
constraint=utils.models.UniqueConstraint(fields=('question', 'feedback'), name='adjfeed_adjudicatorfeedbackbooleananswer_question__feedback_uniq'),
),
migrations.AddConstraint(
model_name='adjudicatorfeedbackfloatanswer',
constraint=utils.models.UniqueConstraint(fields=('question', 'feedback'), name='adjfeed_adjudicatorfeedbackfloatanswer_question__feedback_uniq'),
),
migrations.AddConstraint(
model_name='adjudicatorfeedbackintegeranswer',
constraint=utils.models.UniqueConstraint(fields=('question', 'feedback'), name='adjfeed_adjudicatorfeedbackintegeranswer_question__feedback_uniq'),
),
migrations.AddConstraint(
model_name='adjudicatorfeedbackmanyanswer',
constraint=utils.models.UniqueConstraint(fields=('question', 'feedback'), name='adjfeed_adjudicatorfeedbackmanyanswer_question__feedback_uniq'),
),
migrations.AddConstraint(
model_name='adjudicatorfeedbackquestion',
constraint=utils.models.UniqueConstraint(fields=('tournament', 'reference'), name='adjfeed_adjudicatorfeedbackquestion_tournament__reference_uniq'),
),
migrations.AddConstraint(
model_name='adjudicatorfeedbackquestion',
constraint=utils.models.UniqueConstraint(fields=('tournament', 'seq'), name='adjfeed_adjudicatorfeedbackquestion_tournament__seq_uniq'),
),
migrations.AddConstraint(
model_name='adjudicatorfeedbackstringanswer',
constraint=utils.models.UniqueConstraint(fields=('question', 'feedback'), name='adjfeed_adjudicatorfeedbackstringanswer_question__feedback_uniq'),
),
]
12 changes: 9 additions & 3 deletions tabbycat/adjfeedback/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from adjallocation.models import DebateAdjudicator
from results.models import Submission
from utils.models import UniqueConstraint


class AdjudicatorBaseScoreHistory(models.Model):
Expand Down Expand Up @@ -34,7 +35,7 @@ class AdjudicatorFeedbackAnswer(models.Model):

class Meta:
abstract = True
unique_together = [('question', 'feedback')]
constraints = [UniqueConstraint(fields=['question', 'feedback'])]


class AdjudicatorFeedbackBooleanAnswer(AdjudicatorFeedbackAnswer):
Expand Down Expand Up @@ -179,7 +180,10 @@ class AdjudicatorFeedbackQuestion(models.Model):
default=list)

class Meta:
unique_together = [('tournament', 'reference'), ('tournament', 'seq')]
constraints = [
UniqueConstraint(fields=['tournament', 'reference']),
UniqueConstraint(fields=['tournament', 'seq']),
]
verbose_name = _("adjudicator feedback question")
verbose_name_plural = _("adjudicator feedback questions")

Expand Down Expand Up @@ -242,7 +246,9 @@ class AdjudicatorFeedback(Submission):
help_text=_("Whether the feedback should affect the adjudicator's score"))

class Meta:
unique_together = [('adjudicator', 'source_adjudicator', 'source_team', 'version')]
constraints = [
UniqueConstraint(fields=['adjudicator', 'source_adjudicator', 'source_team', 'version']),
]
verbose_name = _("adjudicator feedback")
verbose_name_plural = _("adjudicator feedbacks")

Expand Down
2 changes: 1 addition & 1 deletion tabbycat/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ def update(self, instance, validated_data):

class InstitutionSerializer(serializers.ModelSerializer):
url = serializers.HyperlinkedIdentityField(view_name='api-global-institution-detail')
region = fields.CreatableSlugRelatedField(slug_field='name', queryset=Region.objects.all(), required=False)
region = fields.CreatableSlugRelatedField(slug_field='name', queryset=Region.objects.all(), required=False, allow_null=True)
venue_constraints = VenueConstraintSerializer(many=True, required=False)

class Meta:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Generated by Django 5.0.4 on 2024-05-04 13:21

import utils.models
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('availability', '0005_auto_20180307_2217'),
('contenttypes', '0002_remove_content_type_name'),
('tournaments', '0010_alter_round_draw_type'),
]

operations = [
migrations.AlterUniqueTogether(
name='roundavailability',
unique_together=set(),
),
migrations.AddConstraint(
model_name='roundavailability',
constraint=utils.models.UniqueConstraint(fields=('round', 'content_type', 'object_id'), name='availab_roundavailability_round__content_type__object_id_uniq'),
),
]
6 changes: 5 additions & 1 deletion tabbycat/availability/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
from django.db import models
from django.utils.translation import gettext_lazy as _

from utils.models import UniqueConstraint


class RoundAvailability(models.Model):

Expand All @@ -20,7 +22,9 @@ class RoundAvailability(models.Model):
verbose_name=_("round"))

class Meta:
unique_together = [('round', 'content_type', 'object_id')]
constraints = [
UniqueConstraint(fields=['round', 'content_type', 'object_id']),
]
verbose_name = _("round availability")
verbose_name_plural = _("round availabilities")

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Generated by Django 5.0.4 on 2024-05-04 13:21

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


class Migration(migrations.Migration):

dependencies = [
('breakqual', '0005_remove_league_fields'),
('participants', '0021_team_seed'),
('tournaments', '0010_alter_round_draw_type'),
]

operations = [
migrations.AlterUniqueTogether(
name='breakcategory',
unique_together=set(),
),
migrations.AlterUniqueTogether(
name='breakingteam',
unique_together=set(),
),
migrations.AlterIndexTogether(
name='breakcategory',
index_together=set(),
),
migrations.AlterField(
model_name='breakcategory',
name='is_general',
field=models.BooleanField(help_text='Are teams eligible for this break by default', verbose_name='is general'),
),
migrations.AddConstraint(
model_name='breakcategory',
constraint=utils.models.UniqueConstraint(fields=('tournament', 'seq'), name='breakqu_breakcategory_tournament__seq_uniq'),
),
migrations.AddConstraint(
model_name='breakcategory',
constraint=utils.models.UniqueConstraint(fields=('tournament', 'slug'), name='breakqu_breakcategory_tournament__slug_uniq'),
),
migrations.AddConstraint(
model_name='breakingteam',
constraint=utils.models.UniqueConstraint(fields=('break_category', 'team'), name='breakqu_breakingteam_break_category__team_uniq'),
),
]
Loading

0 comments on commit b234434

Please sign in to comment.