Skip to content

Commit

Permalink
fix defaults for ContentAPI datetime fields
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkLark86 committed Nov 11, 2024
1 parent 3215c1f commit 194f10e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions content_api/items/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from pydantic import Field, field_validator

from superdesk.core.resources import ResourceModel, dataclass, fields, validators, ModelWithVersions
from superdesk.utc import utcnow


ContentAssociation = Annotated[
Expand Down Expand Up @@ -145,9 +146,9 @@ class ContentAPIItem(ResourceModel, ModelWithVersions):
uri: Annotated[fields.Keyword | None, validators.validate_iunique_value_async("items", "uri")] = None
usageterms: str | None = None
version: str | None = None
versioncreated: datetime = Field(default_factory=datetime.now)
firstcreated: datetime = Field(default_factory=datetime.now)
firstpublished: datetime = Field(default_factory=datetime.now)
versioncreated: datetime = Field(default_factory=utcnow)
firstcreated: datetime = Field(default_factory=utcnow)
firstpublished: datetime = Field(default_factory=utcnow)
embargoed: datetime | None = None
evolvedfrom: fields.Keyword | None = None
nextversion: fields.Keyword | None = None
Expand Down Expand Up @@ -175,7 +176,7 @@ class ContentAPIItem(ResourceModel, ModelWithVersions):
agenda_href: fields.Keyword | None = None

refs: list[ContentReference] = Field(default_factory=list)
expiry: datetime = Field(default_factory=datetime.now)
expiry: datetime | None = None

@field_validator("version", mode="before")
def parse_version(cls, value: int | str | None) -> str | None:
Expand Down

0 comments on commit 194f10e

Please sign in to comment.