Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

✨ Add more References fields #3

Closed
wants to merge 2 commits into from
Closed
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
19 changes: 17 additions & 2 deletions findrefs/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

from typing import TYPE_CHECKING

from django.core.validators import RegexValidator
from django.db import models
from django.db.models import CASCADE, PROTECT
Expand All @@ -8,7 +10,9 @@
BigIntegerField,
BooleanField,
CharField,
DateTimeField,
ForeignKey,
JSONField,
TextField,
)
from lnschema_core.models import (
Expand All @@ -22,6 +26,9 @@
ValidateFields,
)

if TYPE_CHECKING:
Zethson marked this conversation as resolved.
Show resolved Hide resolved
from datetime import datetime


class Reference(Record, CanCurate, TracksRun, TracksUpdates, ValidateFields):
"""References such as a publication or document, with unique identifiers and metadata.
Expand Down Expand Up @@ -64,8 +71,16 @@ class Meta(Record.Meta, TracksRun.Meta, TracksUpdates.Meta):
],
)
"""Digital Object Identifier (DOI) for the reference."""
text: str | None = TextField(null=True)
"""Text of the reference such as the abstract or the full-text to enable search."""
description: str = TextField(null=True, default=None)
"""Description of the reference."""
authors: list[str] | None = JSONField(null=True, default=None)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will the authors field look like?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought of just having ["firstname lastname, firstname, lastname"] and then populating this field. I did not want to create a whole Authors table just for that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean ["firstname lastname", "firstname lastname"]?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, yes.

"""List of authors for the reference."""
abstract: str | None = TextField(null=True, default=None)
"""Abstract text of the reference ."""
full_text: str | None = TextField(null=True, default=None)
"""Full text of the reference."""
published_at: datetime = DateTimeField(null=True, default=None)
"""Publication date."""
artifacts: Artifact = models.ManyToManyField(
Artifact, through="ArtifactReference", related_name="references"
)
Expand Down
Loading