diff --git a/CHANGELOG.md b/CHANGELOG.md index 2111345..f6b8703 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,12 +5,6 @@ All notable changes to WuttaFarm will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## v0.3.1 (2026-02-14) - -### Fix - -- update sterile, archived flags per farmOS 4.x - ## v0.3.0 (2026-02-13) ### Feat diff --git a/pyproject.toml b/pyproject.toml index 073879b..f8fc499 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,7 +5,7 @@ build-backend = "hatchling.build" [project] name = "WuttaFarm" -version = "0.3.1" +version = "0.3.0" description = "Web app to integrate with and extend farmOS" readme = "README.md" authors = [ diff --git a/src/wuttafarm/app.py b/src/wuttafarm/app.py index 9cfe25d..72dd675 100644 --- a/src/wuttafarm/app.py +++ b/src/wuttafarm/app.py @@ -65,24 +65,6 @@ class WuttaFarmAppHandler(base.AppHandler): handler = self.get_farmos_handler() return handler.get_farmos_client(*args, **kwargs) - def is_farmos_3x(self, *args, **kwargs): - """ - Check if the farmOS version is 3.x. This is a convenience - wrapper around - :meth:`~wuttafarm.farmos.handler.FarmOSHandler.is_farmos_3x()`. - """ - handler = self.get_farmos_handler() - return handler.is_farmos_3x(*args, **kwargs) - - def is_farmos_4x(self, *args, **kwargs): - """ - Check if the farmOS version is 4.x. This is a convenience - wrapper around - :meth:`~wuttafarm.farmos.handler.FarmOSHandler.is_farmos_4x()`. - """ - handler = self.get_farmos_handler() - return handler.is_farmos_4x(*args, **kwargs) - class WuttaFarmAppProvider(base.AppProvider): """ diff --git a/src/wuttafarm/farmos/handler.py b/src/wuttafarm/farmos/handler.py index 6eee14f..78e76b6 100644 --- a/src/wuttafarm/farmos/handler.py +++ b/src/wuttafarm/farmos/handler.py @@ -42,35 +42,6 @@ class FarmOSHandler(GenericHandler): hostname = self.get_farmos_url() return farmOS(hostname, **kwargs) - def get_farmos_version(self, client=None, *args, **kwargs): - """ - Returns the farmOS version in use. - """ - if not client: - client = self.get_farmos_client(*args, **kwargs) - info = client.info() - return info["meta"]["farm"]["version"] - - def is_farmos_3x(self, client=None, *args, **kwargs): - """ - Check if the farmOS version is 3.x. - """ - if not client: - client = self.get_farmos_client(*args, **kwargs) - - version = self.get_farmos_version(client) - return version[0] == "3" - - def is_farmos_4x(self, client=None, *args, **kwargs): - """ - Check if the farmOS version is 4.x. - """ - if not client: - client = self.get_farmos_client(*args, **kwargs) - - version = self.get_farmos_version(client) - return version[0] == "4" - def get_farmos_url(self, path=None, require=True): """ Returns the base URL for farmOS, or one with ``path`` appended. diff --git a/src/wuttafarm/importing/farmos.py b/src/wuttafarm/importing/farmos.py index 4acbe24..4717c78 100644 --- a/src/wuttafarm/importing/farmos.py +++ b/src/wuttafarm/importing/farmos.py @@ -52,7 +52,6 @@ class FromFarmOSHandler(ImportHandler): """ token = self.get_farmos_oauth2_token() self.farmos_client = self.app.get_farmos_client(token=token) - self.farmos_4x = self.app.is_farmos_4x(self.farmos_client) def get_farmos_oauth2_token(self): @@ -75,7 +74,6 @@ class FromFarmOSHandler(ImportHandler): def get_importer_kwargs(self, key, **kwargs): kwargs = super().get_importer_kwargs(key, **kwargs) kwargs["farmos_client"] = self.farmos_client - kwargs["farmos_4x"] = self.farmos_4x return kwargs @@ -243,28 +241,18 @@ class AnimalImporter(FromFarmOS, ToWutta): birthdate = self.app.localtime(birthdate) birthdate = self.app.make_utc(birthdate) - if self.farmos_4x: - sterile = animal["attributes"]["is_sterile"] - else: - sterile = animal["attributes"]["is_castrated"] - if notes := animal["attributes"]["notes"]: notes = notes["value"] - if self.farmos_4x: - active = not animal["attributes"]["archived"] - else: - active = animal["attributes"]["status"] == "active" - return { "farmos_uuid": UUID(animal["id"]), "drupal_id": animal["attributes"]["drupal_internal__id"], "name": animal["attributes"]["name"], "animal_type_uuid": animal_type.uuid, "sex": animal["attributes"]["sex"], - "is_sterile": sterile, + "is_sterile": animal["attributes"]["is_castrated"], "birthdate": birthdate, - "active": active, + "active": animal["attributes"]["status"] == "active", "notes": notes, "image_url": image_url, } @@ -357,18 +345,13 @@ class GroupImporter(FromFarmOS, ToWutta): if notes := group["attributes"]["notes"]: notes = notes["value"] - if self.farmos_4x: - active = not group["attributes"]["archived"] - else: - active = group["attributes"]["status"] == "active" - return { "farmos_uuid": UUID(group["id"]), "drupal_id": group["attributes"]["drupal_internal__id"], "name": group["attributes"]["name"], "is_location": group["attributes"]["is_location"], "is_fixed": group["attributes"]["is_fixed"], - "active": active, + "active": group["attributes"]["status"] == "active", "notes": notes, } @@ -417,11 +400,6 @@ class LandAssetImporter(FromFarmOS, ToWutta): if notes := land["attributes"]["notes"]: notes = notes["value"] - if self.farmos_4x: - active = not land["attributes"]["archived"] - else: - active = land["attributes"]["status"] == "active" - return { "farmos_uuid": UUID(land["id"]), "drupal_id": land["attributes"]["drupal_internal__id"], @@ -429,7 +407,7 @@ class LandAssetImporter(FromFarmOS, ToWutta): "land_type_uuid": land_type.uuid, "is_location": land["attributes"]["is_location"], "is_fixed": land["attributes"]["is_fixed"], - "active": active, + "active": land["attributes"]["status"] == "active", "notes": notes, } @@ -549,11 +527,6 @@ class StructureImporter(FromFarmOS, ToWutta): ): image_url = image_style["large"] - if self.farmos_4x: - active = not structure["attributes"]["archived"] - else: - active = structure["attributes"]["status"] == "active" - return { "farmos_uuid": UUID(structure["id"]), "drupal_id": structure["attributes"]["drupal_internal__id"], @@ -561,7 +534,7 @@ class StructureImporter(FromFarmOS, ToWutta): "structure_type_uuid": structure_type.uuid, "is_location": structure["attributes"]["is_location"], "is_fixed": structure["attributes"]["is_fixed"], - "active": active, + "active": structure["attributes"]["status"] == "active", "notes": notes, "image_url": image_url, } diff --git a/src/wuttafarm/web/views/farmos/animals.py b/src/wuttafarm/web/views/farmos/animals.py index d181a02..760ad34 100644 --- a/src/wuttafarm/web/views/farmos/animals.py +++ b/src/wuttafarm/web/views/farmos/animals.py @@ -51,6 +51,7 @@ class AnimalView(FarmOSMasterView): labels = { "animal_type": "Species / Breed", + "is_castrated": "Castrated", "location": "Current Location", } @@ -58,8 +59,8 @@ class AnimalView(FarmOSMasterView): "name", "birthdate", "sex", - "is_sterile", - "archived", + "is_castrated", + "status", ] sort_defaults = "name" @@ -69,8 +70,8 @@ class AnimalView(FarmOSMasterView): "animal_type", "birthdate", "sex", - "is_sterile", - "archived", + "is_castrated", + "status", "owners", "location", "notes", @@ -95,12 +96,6 @@ class AnimalView(FarmOSMasterView): # birthdate g.set_renderer("birthdate", "date") - # is_sterile - g.set_renderer("is_sterile", "boolean") - - # archived - g.set_renderer("archived", "boolean") - def get_instance(self): animal = self.farmos_client.resource.get_id( @@ -178,30 +173,16 @@ class AnimalView(FarmOSMasterView): birthdate = datetime.datetime.fromisoformat(birthdate) birthdate = self.app.localtime(birthdate) - sterile = None - if self.farmos_4x: - sterile = animal["attributes"]["is_sterile"] - else: - sterile = animal["attributes"]["is_castrated"] - - if notes := animal["attributes"]["notes"]: - notes = notes["value"] - - if self.farmos_4x: - archived = animal["attributes"]["archived"] - else: - archived = animal["attributes"]["status"] == "archived" - return { "uuid": animal["id"], "drupal_id": animal["attributes"]["drupal_internal__id"], "name": animal["attributes"]["name"], "birthdate": birthdate, - "sex": animal["attributes"]["sex"] or colander.null, - "is_sterile": sterile, - "location": colander.null, # TODO - "archived": archived, - "notes": notes or colander.null, + "sex": animal["attributes"]["sex"], + "is_castrated": animal["attributes"]["is_castrated"], + "location": "", # TODO + "status": animal["attributes"]["status"], + "notes": animal["attributes"]["notes"]["value"], } def configure_form(self, form): @@ -216,8 +197,8 @@ class AnimalView(FarmOSMasterView): f.set_node("birthdate", WuttaDateTime()) f.set_widget("birthdate", WuttaDateTimeWidget(self.request)) - # is_sterile - f.set_node("is_sterile", colander.Boolean()) + # is_castrated + f.set_node("is_castrated", colander.Boolean()) # location f.set_node("location", StructureType(self.request)) @@ -228,9 +209,6 @@ class AnimalView(FarmOSMasterView): # notes f.set_widget("notes", "notes") - # archived - f.set_node("archived", colander.Boolean()) - # image if url := animal.get("large_image_url"): f.set_widget("image", ImageWidget("animal image")) diff --git a/src/wuttafarm/web/views/farmos/groups.py b/src/wuttafarm/web/views/farmos/groups.py index df54b04..66224fe 100644 --- a/src/wuttafarm/web/views/farmos/groups.py +++ b/src/wuttafarm/web/views/farmos/groups.py @@ -50,7 +50,7 @@ class GroupView(FarmOSMasterView): "name", "is_fixed", "is_location", - "archived", + "status", "changed", ] @@ -60,7 +60,7 @@ class GroupView(FarmOSMasterView): "name", "is_fixed", "is_location", - "archived", + "status", "notes", "created", "changed", @@ -87,9 +87,6 @@ class GroupView(FarmOSMasterView): # changed g.set_renderer("changed", "datetime") - # archived - g.set_renderer("archived", "boolean") - def get_instance(self): group = self.farmos_client.resource.get_id( "asset", "group", self.request.matchdict["uuid"] @@ -110,11 +107,6 @@ class GroupView(FarmOSMasterView): changed = datetime.datetime.fromisoformat(changed) changed = self.app.localtime(changed) - if self.farmos_4x: - archived = group["attributes"]["archived"] - else: - archived = group["attributes"]["status"] == "archived" - return { "uuid": group["id"], "drupal_id": group["attributes"]["drupal_internal__id"], @@ -123,7 +115,7 @@ class GroupView(FarmOSMasterView): "changed": changed, "is_fixed": group["attributes"]["is_fixed"], "is_location": group["attributes"]["is_location"], - "archived": archived, + "status": group["attributes"]["status"], "notes": group["attributes"]["notes"]["value"], } @@ -148,9 +140,6 @@ class GroupView(FarmOSMasterView): f.set_node("changed", WuttaDateTime()) f.set_widget("changed", WuttaDateTimeWidget(self.request)) - # archived - f.set_node("archived", colander.Boolean()) - def get_xref_buttons(self, group): model = self.app.model session = self.Session() diff --git a/src/wuttafarm/web/views/farmos/land_assets.py b/src/wuttafarm/web/views/farmos/land_assets.py index ffea76d..64f43cc 100644 --- a/src/wuttafarm/web/views/farmos/land_assets.py +++ b/src/wuttafarm/web/views/farmos/land_assets.py @@ -52,7 +52,7 @@ class LandAssetView(FarmOSMasterView): "land_type", "is_fixed", "is_location", - "archived", + "status", "changed", ] @@ -63,7 +63,7 @@ class LandAssetView(FarmOSMasterView): "land_type", "is_fixed", "is_location", - "archived", + "status", "notes", "created", "changed", @@ -93,9 +93,6 @@ class LandAssetView(FarmOSMasterView): # changed g.set_renderer("changed", "datetime") - # archived - g.set_renderer("archived", "boolean") - def get_instance(self): land_asset = self.farmos_client.resource.get_id( "asset", "land", self.request.matchdict["uuid"] @@ -119,11 +116,6 @@ class LandAssetView(FarmOSMasterView): if notes := land["attributes"]["notes"]: notes = notes["value"] - if self.farmos_4x: - archived = land["attributes"]["archived"] - else: - archived = land["attributes"]["status"] == "archived" - return { "uuid": land["id"], "drupal_id": land["attributes"]["drupal_internal__id"], @@ -133,7 +125,7 @@ class LandAssetView(FarmOSMasterView): "changed": changed, "is_fixed": land["attributes"]["is_fixed"], "is_location": land["attributes"]["is_location"], - "archived": archived, + "status": land["attributes"]["status"], "notes": notes or colander.null, } @@ -158,9 +150,6 @@ class LandAssetView(FarmOSMasterView): f.set_node("changed", WuttaDateTime()) f.set_widget("changed", WuttaDateTimeWidget(self.request)) - # archived - f.set_node("archived", colander.Boolean()) - def get_xref_buttons(self, land): return [ self.make_button( diff --git a/src/wuttafarm/web/views/farmos/master.py b/src/wuttafarm/web/views/farmos/master.py index fff3d2c..955120b 100644 --- a/src/wuttafarm/web/views/farmos/master.py +++ b/src/wuttafarm/web/views/farmos/master.py @@ -58,7 +58,6 @@ class FarmOSMasterView(MasterView): def __init__(self, request, context=None): super().__init__(request, context=context) self.farmos_client = self.get_farmos_client() - self.farmos_4x = self.app.is_farmos_4x(self.farmos_client) self.raw_json = None def get_farmos_client(self): diff --git a/src/wuttafarm/web/views/farmos/structures.py b/src/wuttafarm/web/views/farmos/structures.py index 618c2fa..3626fb1 100644 --- a/src/wuttafarm/web/views/farmos/structures.py +++ b/src/wuttafarm/web/views/farmos/structures.py @@ -50,7 +50,7 @@ class StructureView(FarmOSMasterView): grid_columns = [ "name", - "archived", + "status", "created", "changed", ] @@ -59,7 +59,7 @@ class StructureView(FarmOSMasterView): form_fields = [ "name", - "archived", + "status", "structure_type", "is_location", "is_fixed", @@ -90,9 +90,6 @@ class StructureView(FarmOSMasterView): # changed g.set_renderer("changed", "datetime") - # archived - g.set_renderer("archived", "boolean") - def get_instance(self): structure = self.farmos_client.resource.get_id( "asset", "structure", self.request.matchdict["uuid"] @@ -148,11 +145,6 @@ class StructureView(FarmOSMasterView): changed = datetime.datetime.fromisoformat(changed) changed = self.app.localtime(changed) - if self.farmos_4x: - archived = structure["attributes"]["archived"] - else: - archived = structure["attributes"]["status"] == "archived" - return { "uuid": structure["id"], "drupal_id": structure["attributes"]["drupal_internal__id"], @@ -161,7 +153,7 @@ class StructureView(FarmOSMasterView): "is_fixed": structure["attributes"]["is_fixed"], "is_location": structure["attributes"]["is_location"], "notes": structure["attributes"]["notes"] or colander.null, - "archived": archived, + "status": structure["attributes"]["status"], "created": created, "changed": changed, } @@ -188,9 +180,6 @@ class StructureView(FarmOSMasterView): f.set_node("changed", WuttaDateTime()) f.set_widget("changed", WuttaDateTimeWidget(self.request)) - # archived - f.set_node("archived", colander.Boolean()) - # image if url := structure.get("large_image_url"): f.set_widget("image", ImageWidget("structure image"))