Skip to content

Commit

Permalink
add link and linkText to document model and api
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrey committed Oct 28, 2024
1 parent fda4302 commit 29697c7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
37 changes: 37 additions & 0 deletions programs/migrations/0095_document_link_document_linktext.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Generated by Django 4.2.15 on 2024-10-24 20:25

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


class Migration(migrations.Migration):

dependencies = [
("translations", "0004_translation_no_auto"),
("programs", "0094_rename_category_v2_program_category"),
]

operations = [
migrations.AddField(
model_name="document",
name="link",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="document_link",
to="translations.translation",
),
),
migrations.AddField(
model_name="document",
name="linkText",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.PROTECT,
related_name="document_link_text",
to="translations.translation",
),
),
]
5 changes: 4 additions & 1 deletion programs/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ def create_instance(cls, external_name: str, Model: type["Document"]) -> "Docume
class Document(models.Model):
external_name = models.CharField(max_length=120, blank=True, null=True, unique=True)
text = models.ForeignKey(Translation, related_name="documents", blank=False, null=False, on_delete=models.PROTECT)
link = models.ForeignKey(Translation, related_name="document_link", blank=True, null=True, on_delete=models.PROTECT)
linkText = models.ForeignKey(Translation, related_name="document_link_text", blank=True, null=True, on_delete=models.PROTECT)

objects = DocumentManager()

Expand Down Expand Up @@ -241,6 +243,7 @@ class ProgramDataController(ModelDataController["Program"]):

FplDataType = TypedDict("FplDataType", {"year": str, "period": str})
LegalStatusesDataType = list[TypedDict("LegalStatusDataType", {"status": str})]
DocumentDataType = TypedDict("DocDataType", {"text": str, "link": str, "link_text": str})
DataType = TypedDict(
"DataType",
{
Expand All @@ -249,7 +252,7 @@ class ProgramDataController(ModelDataController["Program"]):
"name_abbreviated": str,
"active": bool,
"low_confidence": bool,
"documents": list[str],
"documents": list[DocumentDataType],
"category": Optional[str],
},
)
Expand Down

0 comments on commit 29697c7

Please sign in to comment.