Docker Image and first iteration
This commit is contained in:
1 parent
723b64b1c4
commit
bd9209ebb7
40 files changed
+26643
No files matched your search
@@ -0,0 +1,57 @@
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
initial = True
|
||||
|
||||
dependencies = []
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name="Region",
|
||||
fields=[
|
||||
("code", models.CharField(max_length=8, primary_key=True, serialize=False)),
|
||||
("name", models.CharField(max_length=120)),
|
||||
(
|
||||
"level",
|
||||
models.CharField(
|
||||
choices=[("country", "Country"), ("subdivision", "Subdivision")],
|
||||
max_length=16,
|
||||
),
|
||||
),
|
||||
(
|
||||
"parent",
|
||||
models.ForeignKey(
|
||||
blank=True,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="subdivisions",
|
||||
to="showcase.region",
|
||||
),
|
||||
),
|
||||
],
|
||||
options={"ordering": ("name",)},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name="PortfolioEntry",
|
||||
fields=[
|
||||
("id", models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
|
||||
("entry_type", models.CharField(choices=[("work", "Work"), ("cv", "CV")], max_length=8)),
|
||||
("title", models.CharField(max_length=160)),
|
||||
("organization", models.CharField(blank=True, max_length=160)),
|
||||
("start_date", models.DateField(blank=True, null=True)),
|
||||
("end_date", models.DateField(blank=True, null=True)),
|
||||
("summary", models.TextField()),
|
||||
("url", models.URLField(blank=True)),
|
||||
("is_published", models.BooleanField(default=False)),
|
||||
("display_order", models.PositiveIntegerField(default=0)),
|
||||
("regions", models.ManyToManyField(related_name="entries", to="showcase.region")),
|
||||
],
|
||||
options={
|
||||
"verbose_name_plural": "portfolio entries",
|
||||
"ordering": ("display_order", "-start_date", "title"),
|
||||
},
|
||||
),
|
||||
]
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def seed_regions(apps, schema_editor):
|
||||
region_model = apps.get_model("showcase", "Region")
|
||||
seed_path = Path(__file__).with_name("regions.json")
|
||||
regions = json.loads(seed_path.read_text())
|
||||
|
||||
for region in regions["countries"]:
|
||||
region_model.objects.update_or_create(
|
||||
code=region["code"],
|
||||
defaults={"name": region["name"], "level": "country", "parent": None},
|
||||
)
|
||||
|
||||
for region in regions["subdivisions"]:
|
||||
region_model.objects.update_or_create(
|
||||
code=region["code"],
|
||||
defaults={
|
||||
"name": region["name"],
|
||||
"level": "subdivision",
|
||||
"parent_id": region["parentCode"],
|
||||
},
|
||||
)
|
||||
|
||||
|
||||
def unseed_regions(apps, schema_editor):
|
||||
apps.get_model("showcase", "Region").objects.all().delete()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [("showcase", "0001_initial")]
|
||||
|
||||
operations = [migrations.RunPython(seed_regions, unseed_regions)]
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user