-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: school.country is optional * remove postcode and make name unique * all uk counties * add choices * make county field work * add county options * remove postcode * hide/show county field * show/hide county field pt.2 * merge from master * remove redundant test * fix: create postcode * fix assertion * feedback * Merge branch 'master' into county_field * ignore .venv
- Loading branch information
Showing
21 changed files
with
288 additions
and
198 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,5 @@ node_modules | |
|
||
# tunnel software | ||
ngrok | ||
|
||
.venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Generated by Django 3.2.20 on 2023-11-06 18:56 | ||
|
||
from django.apps.registry import Apps | ||
from django.db import migrations, models | ||
|
||
|
||
def unique_school_names(apps: Apps, *args): | ||
School = apps.get_model("common", "School") | ||
|
||
schools = School.objects.values("name").annotate(name_count=models.Count("name")).filter(name_count__gt=1) | ||
for school in schools: | ||
schools = list(School.objects.filter(name=school["name"]).order_by("id")) | ||
for index in range(school["name_count"]): | ||
if index > 0: | ||
school = schools[index] | ||
school.name += f" {index + 1}" | ||
school.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("common", "0046_alter_school_country"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name="school", | ||
name="postcode", | ||
), | ||
migrations.RunPython(code=unique_school_names), | ||
migrations.AlterField( | ||
model_name="school", | ||
name="name", | ||
field=models.CharField(max_length=200, unique=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.