fix: expose is_location and is_fixed for editing on Animal Asset
This commit is contained in:
parent
3336294b3b
commit
d46ba43d11
4 changed files with 40 additions and 21 deletions
|
|
@ -245,6 +245,8 @@ class AnimalAssetImporter(ToFarmOSAsset):
|
|||
"is_sterile",
|
||||
"produces_eggs",
|
||||
"birthdate",
|
||||
"is_location",
|
||||
"is_fixed",
|
||||
"notes",
|
||||
"archived",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -149,6 +149,8 @@ class AnimalAssetImporter(FromWuttaFarm, farmos_importing.model.AnimalAssetImpor
|
|||
"is_sterile",
|
||||
"produces_eggs",
|
||||
"birthdate",
|
||||
"is_location",
|
||||
"is_fixed",
|
||||
"notes",
|
||||
"archived",
|
||||
]
|
||||
|
|
@ -162,6 +164,8 @@ class AnimalAssetImporter(FromWuttaFarm, farmos_importing.model.AnimalAssetImpor
|
|||
"is_sterile": animal.is_sterile,
|
||||
"produces_eggs": animal.produces_eggs,
|
||||
"birthdate": animal.birthdate,
|
||||
"is_location": animal.is_location,
|
||||
"is_fixed": animal.is_fixed,
|
||||
"notes": animal.notes,
|
||||
"archived": animal.archived,
|
||||
"_src_object": animal,
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ from collections import OrderedDict
|
|||
from webhelpers2.html import tags
|
||||
|
||||
from wuttaweb.forms.schema import WuttaDictEnum
|
||||
from wuttaweb.forms.widgets import WuttaDateTimeWidget
|
||||
from wuttaweb.util import get_form_data
|
||||
|
||||
from wuttafarm.db.model import AnimalType, AnimalAsset
|
||||
|
|
@ -236,27 +237,6 @@ class AnimalAssetView(AssetMasterView):
|
|||
"archived",
|
||||
]
|
||||
|
||||
form_fields = [
|
||||
"asset_name",
|
||||
"animal_type",
|
||||
"birthdate",
|
||||
"produces_eggs",
|
||||
"sex",
|
||||
"is_sterile",
|
||||
"notes",
|
||||
"asset_type",
|
||||
"owners",
|
||||
"locations",
|
||||
"groups",
|
||||
"archived",
|
||||
"drupal_id",
|
||||
"farmos_uuid",
|
||||
"thumbnail_url",
|
||||
"image_url",
|
||||
"thumbnail",
|
||||
"image",
|
||||
]
|
||||
|
||||
def configure_grid(self, grid):
|
||||
g = grid
|
||||
super().configure_grid(g)
|
||||
|
|
@ -290,9 +270,21 @@ class AnimalAssetView(AssetMasterView):
|
|||
animal = f.model_instance
|
||||
|
||||
# animal_type
|
||||
f.fields.insert_after("asset_name", "animal_type")
|
||||
f.set_node("animal_type", AnimalTypeRef(self.request))
|
||||
|
||||
# birthdate
|
||||
f.fields.insert_after("animal_type", "birthdate")
|
||||
# TODO: why must we assign the widget here? pretty sure that
|
||||
# was not needed when we declared form_fields directly, i.e.
|
||||
# instead of adding birthdate field in this method
|
||||
f.set_widget("birthdate", WuttaDateTimeWidget(self.request))
|
||||
|
||||
# produces_eggs
|
||||
f.fields.insert_after("birthdate", "produces_eggs")
|
||||
|
||||
# sex
|
||||
f.fields.insert_after("produces_eggs", "sex")
|
||||
if not (self.creating or self.editing) and animal.sex is None:
|
||||
pass # TODO: dict enum widget does not handle null values well
|
||||
else:
|
||||
|
|
@ -301,6 +293,9 @@ class AnimalAssetView(AssetMasterView):
|
|||
f.set_node("sex", WuttaDictEnum(self.request, sex_enum))
|
||||
f.set_required("sex", False)
|
||||
|
||||
# is_sterile
|
||||
f.fields.insert_after("sex", "is_sterile")
|
||||
|
||||
|
||||
def defaults(config, **kwargs):
|
||||
base = globals()
|
||||
|
|
|
|||
|
|
@ -77,6 +77,24 @@ class AssetMasterView(WuttaFarmMasterView):
|
|||
"archived": {"active": True, "verb": "is_false"},
|
||||
}
|
||||
|
||||
form_fields = [
|
||||
"asset_name",
|
||||
"notes",
|
||||
"asset_type",
|
||||
"owners",
|
||||
"locations",
|
||||
"is_location",
|
||||
"is_fixed",
|
||||
"groups",
|
||||
"archived",
|
||||
"drupal_id",
|
||||
"farmos_uuid",
|
||||
"thumbnail_url",
|
||||
"image_url",
|
||||
"thumbnail",
|
||||
"image",
|
||||
]
|
||||
|
||||
has_rows = True
|
||||
row_model_class = Log
|
||||
rows_viewable = True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue