register and sign in pages
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
"""Seed data for atolls and islands.
|
||||
|
||||
Only the areas SAR Link actually serves are listed. Add more here (or in the
|
||||
admin) as coverage grows; `seed()` is idempotent, so re-running is safe.
|
||||
"""
|
||||
|
||||
ATOLLS = [
|
||||
{
|
||||
"name": "Faafu",
|
||||
"code": "F",
|
||||
"islands": ["Dharanboodhoo"],
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
def seed(atoll_model, island_model) -> tuple[int, int]:
|
||||
"""Create any missing atolls/islands. Returns (atolls, islands) created.
|
||||
|
||||
Takes the models as arguments so both the management command and the data
|
||||
migration can call it, the latter with historical models.
|
||||
"""
|
||||
atolls_created = 0
|
||||
islands_created = 0
|
||||
|
||||
for entry in ATOLLS:
|
||||
atoll, created = atoll_model.objects.get_or_create(
|
||||
name=entry["name"], defaults={"code": entry.get("code", "")}
|
||||
)
|
||||
atolls_created += int(created)
|
||||
|
||||
for island_name in entry["islands"]:
|
||||
_, created = island_model.objects.get_or_create(
|
||||
atoll=atoll, name=island_name
|
||||
)
|
||||
islands_created += int(created)
|
||||
|
||||
return atolls_created, islands_created
|
||||
Reference in New Issue
Block a user