feat: add sync support for Log.is_group_assignment

This commit is contained in:
Lance Edgar 2026-02-28 20:15:10 -06:00
parent a5550091d3
commit 3ae4d639ec
7 changed files with 69 additions and 0 deletions

View file

@ -0,0 +1,39 @@
"""add Log.is_group_assignment
Revision ID: f3c7e273bfa3
Revises: 47d0ebd84554
Create Date: 2026-02-28 20:04:40.700474
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import wuttjamaican.db.util
# revision identifiers, used by Alembic.
revision: str = "f3c7e273bfa3"
down_revision: Union[str, None] = "47d0ebd84554"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# log
op.add_column("log", sa.Column("is_group_assignment", sa.Boolean(), nullable=True))
op.add_column(
"log_version",
sa.Column(
"is_group_assignment", sa.Boolean(), autoincrement=False, nullable=True
),
)
def downgrade() -> None:
# log
op.drop_column("log_version", "is_group_assignment")
op.drop_column("log", "is_group_assignment")

View file

@ -120,6 +120,14 @@ class Log(model.Base):
""",
)
is_group_assignment = sa.Column(
sa.Boolean(),
nullable=True,
doc="""
Whether the log represents a group assignment.
""",
)
status = sa.Column(
sa.String(length=20),
nullable=False,
@ -207,6 +215,7 @@ def add_log_proxies(subclass):
Log.make_proxy(subclass, "log", "log_type")
Log.make_proxy(subclass, "log", "message")
Log.make_proxy(subclass, "log", "timestamp")
Log.make_proxy(subclass, "log", "is_group_assignment")
Log.make_proxy(subclass, "log", "status")
Log.make_proxy(subclass, "log", "notes")
Log.make_proxy(subclass, "log", "assets")

View file

@ -459,6 +459,7 @@ class ToFarmOSLog(ToFarmOS):
"uuid",
"name",
"timestamp",
"is_group_assignment",
"status",
"notes",
]
@ -516,6 +517,7 @@ class ToFarmOSLog(ToFarmOS):
"uuid": UUID(log["id"]),
"name": log["attributes"]["name"],
"timestamp": self.normalize_datetime(log["attributes"]["timestamp"]),
"is_group_assignment": log["attributes"]["is_group_assignment"],
"status": log["attributes"]["status"],
"notes": notes,
}
@ -527,6 +529,8 @@ class ToFarmOSLog(ToFarmOS):
attrs["name"] = source_data["name"]
if "timestamp" in self.fields:
attrs["timestamp"] = self.format_datetime(source_data["timestamp"])
if "is_group_assignment" in self.fields:
attrs["is_group_assignment"] = source_data["is_group_assignment"]
if "status" in self.fields:
attrs["status"] = source_data["status"]
if "notes" in self.fields:

View file

@ -361,6 +361,7 @@ class FromWuttaFarmLog(FromWuttaFarm):
"uuid",
"name",
"timestamp",
"is_group_assignment",
"status",
"notes",
]
@ -370,6 +371,7 @@ class FromWuttaFarmLog(FromWuttaFarm):
"uuid": log.farmos_uuid or self.app.make_true_uuid(),
"name": log.message,
"timestamp": log.timestamp,
"is_group_assignment": log.is_group_assignment,
"status": log.status,
"notes": log.notes,
"_src_object": log,

View file

@ -967,6 +967,7 @@ class LogImporterBase(FromFarmOS, ToWutta):
"log_type",
"message",
"timestamp",
"is_group_assignment",
"notes",
"status",
]
@ -1093,6 +1094,7 @@ class ActivityLogImporter(LogImporterBase):
"log_type",
"message",
"timestamp",
"is_group_assignment",
"notes",
"status",
"assets",
@ -1112,6 +1114,7 @@ class HarvestLogImporter(LogImporterBase):
"log_type",
"message",
"timestamp",
"is_group_assignment",
"notes",
"status",
"assets",
@ -1131,6 +1134,7 @@ class MedicalLogImporter(LogImporterBase):
"log_type",
"message",
"timestamp",
"is_group_assignment",
"notes",
"status",
"assets",
@ -1150,6 +1154,7 @@ class ObservationLogImporter(LogImporterBase):
"log_type",
"message",
"timestamp",
"is_group_assignment",
"notes",
"status",
"assets",

View file

@ -23,6 +23,7 @@
View for farmOS Harvest Logs
"""
import colander
from webhelpers2.html import tags
from wuttaweb.forms.schema import WuttaDateTime, WuttaDictEnum
@ -85,6 +86,7 @@ class LogMasterView(FarmOSMasterView):
"timestamp",
"assets",
"quantities",
"is_group_assignment",
"notes",
"status",
"log_type_name",
@ -213,6 +215,9 @@ class LogMasterView(FarmOSMasterView):
# quantities
f.set_node("quantities", FarmOSQuantityRefs(self.request))
# is_group_assignment
f.set_node("is_group_assignment", colander.Boolean())
# notes
f.set_node("notes", Notes())

View file

@ -181,6 +181,11 @@ class LogMasterView(WuttaFarmMasterView):
# assets
g.set_renderer("assets", self.render_assets_for_grid)
# is_group_assignment
g.set_renderer("is_group_assignment", "boolean")
g.set_sorter("is_group_assignment", model.Log.is_group_assignment)
g.set_filter("is_group_assignment", model.Log.is_group_assignment)
# owners
g.set_label("owners", "Owner")
g.set_renderer("owners", self.render_owners_for_grid)