Skip to content

Commit

Permalink
fix(django): resolve `RemovedInDjango60Warning: CheckConstraint.check…
Browse files Browse the repository at this point in the history
… is deprecated`
  • Loading branch information
zyv committed Aug 20, 2024
1 parent 49159a7 commit 0405886
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Migration(migrations.Migration):
migrations.AddConstraint(
model_name="logentry",
constraint=models.CheckConstraint(
check=models.Q(("arrival_time__gt", django.db.models.expressions.F("departure_time"))),
condition=models.Q(("arrival_time__gt", django.db.models.expressions.F("departure_time"))),
name="arrival_after_departure",
),
),
Expand Down
2 changes: 1 addition & 1 deletion logbook/migrations/0005_logentry_copilot_not_pilot.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Migration(migrations.Migration):
migrations.AddConstraint(
model_name="logentry",
constraint=models.CheckConstraint(
check=models.Q(("copilot", django.db.models.expressions.F("pilot")), _negated=True),
condition=models.Q(("copilot", django.db.models.expressions.F("pilot")), _negated=True),
name="copilot_not_pilot",
),
),
Expand Down
2 changes: 1 addition & 1 deletion logbook/migrations/0009_logentry_no_pic_no_xc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Migration(migrations.Migration):
migrations.AddConstraint(
model_name="logentry",
constraint=models.CheckConstraint(
check=models.Q(
condition=models.Q(
("time_function", "PIC"),
models.Q(models.Q(("time_function", "PIC"), _negated=True), ("cross_country", False)),
_connector="OR",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Migration(migrations.Migration):
migrations.AddConstraint(
model_name="certificate",
constraint=models.CheckConstraint(
check=models.Q(
condition=models.Q(
("valid_until__isnull", True),
("valid_until__gt", models.F("issue_date")),
_connector="OR",
Expand Down
2 changes: 1 addition & 1 deletion logbook/migrations/0020_certificate_supersedes_self.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Migration(migrations.Migration):
migrations.AddConstraint(
model_name="certificate",
constraint=models.CheckConstraint(
check=models.Q(("id", models.F("supersedes")), _negated=True),
condition=models.Q(("id", models.F("supersedes")), _negated=True),
name="supersedes_self",
),
),
Expand Down
6 changes: 3 additions & 3 deletions logbook/models/log_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ class LogEntry(models.Model):

class Meta:
constraints = (
CheckConstraint(check=Q(arrival_time__gt=F("departure_time")), name="arrival_after_departure"),
CheckConstraint(check=~Q(copilot=F("pilot")), name="copilot_not_pilot"),
CheckConstraint(condition=Q(arrival_time__gt=F("departure_time")), name="arrival_after_departure"),
CheckConstraint(condition=~Q(copilot=F("pilot")), name="copilot_not_pilot"),
CheckConstraint(
check=(
condition=(
Q(time_function=FunctionType.PIC) # PIC time may be XC or not XC
| ~Q(time_function=FunctionType.PIC) & Q(cross_country=False) # non-PIC time must be non-XC
),
Expand Down
4 changes: 2 additions & 2 deletions logbook/models/pilot.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ class Certificate(models.Model):
class Meta:
constraints = (
CheckConstraint(
check=Q(valid_until__isnull=True) | Q(valid_until__gt=F("issue_date")),
condition=Q(valid_until__isnull=True) | Q(valid_until__gt=F("issue_date")),
name="validity_after_issue",
),
CheckConstraint(
check=~Q(id=F("supersedes")),
condition=~Q(id=F("supersedes")),
name="supersedes_self",
),
UniqueConstraint(
Expand Down

0 comments on commit 0405886

Please sign in to comment.