Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Dec 15, 2023
1 parent b562b8d commit 33d8e8b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 18 deletions.
2 changes: 1 addition & 1 deletion codeforlife/user/fixtures/schools.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"fields": {
"last_saved_at": "2023-01-01 00:00:00.0+00:00",
"name": "Example School",
"country": "UK",
"country": "GB",
"uk_county": "Surrey"
}
}
Expand Down
6 changes: 3 additions & 3 deletions codeforlife/user/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 3.2.20 on 2023-12-15 11:16
# Generated by Django 3.2.20 on 2023-12-15 16:05

from django.conf import settings
import django.core.validators
Expand Down Expand Up @@ -150,7 +150,7 @@ class Migration(migrations.Migration):
),
migrations.AddConstraint(
model_name='school',
constraint=models.CheckConstraint(check=models.Q(('uk_county__isnull', True), ('country', 'UK'), _connector='OR'), name='school__no_uk_county_if_country_not_uk'),
constraint=models.CheckConstraint(check=models.Q(('uk_county__isnull', True), ('country', 'GB'), _connector='OR'), name='school__no_uk_county_if_country_not_uk'),
),
migrations.AddField(
model_name='otpbypasstoken',
Expand Down Expand Up @@ -210,7 +210,7 @@ class Migration(migrations.Migration):
),
migrations.AddConstraint(
model_name='user',
constraint=models.CheckConstraint(check=models.Q(models.Q(('student__isnull', False), ('teacher__isnull', True)), models.Q(('student__isnull', True), ('teacher__isnull', False)), models.Q(('student__isnull', True), ('teacher__isnull', True)), _connector='OR'), name='user__profile'),
constraint=models.CheckConstraint(check=models.Q(('student__isnull', False), ('teacher__isnull', False), _negated=True), name='user__profile'),
),
migrations.AddConstraint(
model_name='user',
Expand Down
2 changes: 1 addition & 1 deletion codeforlife/user/models/school.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Meta(TypedModelMeta):
verbose_name_plural = _("schools")
constraints = [
models.CheckConstraint(
check=Q(uk_county__isnull=True) | Q(country="UK"),
check=Q(uk_county__isnull=True) | Q(country=Country.GB),
name="school__no_uk_county_if_country_not_uk",
),
]
16 changes: 3 additions & 13 deletions codeforlife/user/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,19 +197,9 @@ class Meta(TypedModelMeta):
constraints = [
# pylint: disable=unsupported-binary-operation
models.CheckConstraint(
check=(
Q(
teacher__isnull=True,
student__isnull=False,
)
| Q(
teacher__isnull=False,
student__isnull=True,
)
| Q(
teacher__isnull=True,
student__isnull=True,
)
check=~Q(
teacher__isnull=False,
student__isnull=False,
),
name="user__profile",
),
Expand Down

0 comments on commit 33d8e8b

Please sign in to comment.