Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/cal_bc/projects/forms/model_section.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.forms import ModelForm
from cal_bc.projects.models.model_section import ModelSection
from django.utils.translation import gettext as _


class ModelSectionForm(ModelForm):
class Meta:
model = ModelSection
fields = ["section_fields"]

def get_labels(self) -> dict[str, str]:
return {"section_fields": _(self.object.name)}
18 changes: 3 additions & 15 deletions src/cal_bc/projects/forms/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,11 @@ class Meta:
fields = [
"name",
"district",
"type",
"location",
"construction_period_length",
"data_direction",
"peak_periods_length",
"model",
]

labels = {
"name": _("Project Name"),
"type": _("Project Type"),
"location": _("Project Location"),
"construction_period_length": _("Length of Construction Period"),
"data_direction": _("One- or Two-Way Data"),
"peak_periods_length": _("Length of Peak Period(s) (up to 24 hrs)"),
}

help_texts = {
"construction_period_length": _("years"),
"peak_periods_length": _("hours"),
"model": _("Model"),
"district": _("District"),
}
19 changes: 19 additions & 0 deletions src/cal_bc/projects/forms/project_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
from django.forms import ModelForm
from cal_bc.projects.models.project_field import ProjectField
from django.utils.translation import gettext as _


class ProjectFieldForm(ModelForm):
class Meta:
model = ProjectField
fields = ["value", "project"]
labels = {"value": _("Value")}
widgets = {"project": Hidden()}

Check failure on line 11 in src/cal_bc/projects/forms/project_field.py

View workflow job for this annotation

GitHub Actions / Run linter

Ruff (F821)

src/cal_bc/projects/forms/project_field.py:11:31: F821 Undefined name `Hidden`

def get_labels(self) -> dict[str, str]:
return {"value": _(self.object.model_section_field.name)}


ProjectFieldFormset = inlineformset_factory(

Check failure on line 17 in src/cal_bc/projects/forms/project_field.py

View workflow job for this annotation

GitHub Actions / Run linter

Ruff (F821)

src/cal_bc/projects/forms/project_field.py:17:23: F821 Undefined name `inlineformset_factory`
ModelSectionField, ProjectField, form=ProjectFieldForm, allow_create=False

Check failure on line 18 in src/cal_bc/projects/forms/project_field.py

View workflow job for this annotation

GitHub Actions / Run linter

Ruff (F821)

src/cal_bc/projects/forms/project_field.py:18:5: F821 Undefined name `ModelSectionField`
)
28 changes: 28 additions & 0 deletions src/cal_bc/projects/migrations/0001_create_models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Generated by Django 5.2.7 on 2025-10-11 00:25

from django.db import migrations, models


class Migration(migrations.Migration):
initial = True

dependencies = []

operations = [
migrations.CreateModel(
name="Model",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(null=False)),
("url", models.CharField(null=False)),
],
),
]
11 changes: 0 additions & 11 deletions src/cal_bc/projects/migrations/0001_initial.py

This file was deleted.

15 changes: 12 additions & 3 deletions src/cal_bc/projects/migrations/0002_create_projects.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Generated by Django 5.2.7 on 2025-10-11 00:34
# Generated by Django 5.2.7 on 2025-10-18 19:46

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("projects", "0001_initial"),
("projects", "0001_create_models"),
]

operations = [
Expand All @@ -21,7 +22,15 @@ class Migration(migrations.Migration):
verbose_name="ID",
),
),
("name", models.CharField()),
("name", models.CharField(null=False)),
(
"model",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="projects.model",
null=False,
),
),
],
),
]
33 changes: 33 additions & 0 deletions src/cal_bc/projects/migrations/0003_add_project_district.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Generated by Django 5.2.7 on 2025-10-15 22:42

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("projects", "0002_create_projects"),
]

operations = [
migrations.AddField(
model_name="project",
name="district",
field=models.IntegerField(
choices=[
(1, "District 1 - Eureka"),
(2, "District 2 - Redding"),
(3, "District 3 - Marysville / Sacramento"),
(4, "District 4 - Bay Area / Oakland"),
(5, "District 5 - Central Coast"),
(6, "District 6 - Fresno / Bakersfield"),
(7, "District 7 - Los Angeles / Ventura"),
(8, "District 8 - San Bernardino / Riverside"),
(9, "District 9 - Bishop"),
(10, "District 10 - Stockton"),
(11, "District 11 - San Diego"),
(12, "District 12 - Orange County"),
],
null=False,
),
),
]

This file was deleted.

37 changes: 37 additions & 0 deletions src/cal_bc/projects/migrations/0004_create_model_section.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated by Django 5.2.7 on 2025-10-18 20:18

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("projects", "0003_add_project_district"),
]

operations = [
migrations.CreateModel(
name="ModelSection",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(null=False)),
("help_text", models.CharField(null=False)),
(
"model",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="projects.model",
null=False,
),
),
],
),
]
38 changes: 38 additions & 0 deletions src/cal_bc/projects/migrations/0005_create_model_section_field.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 5.2.7 on 2025-10-18 23:24

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("projects", "0004_create_model_section"),
]

operations = [
migrations.CreateModel(
name="ModelSectionField",
fields=[
(
"id",
models.BigAutoField(
auto_created=True,
primary_key=True,
serialize=False,
verbose_name="ID",
),
),
("name", models.CharField(null=False)),
("cell", models.CharField(null=False)),
("help_text", models.CharField(null=False)),
(
"model_section",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
to="projects.modelsection",
null=False,
),
),
],
)
]
Loading
Loading