2828- thing_id: Integer FK to Thing.id
2929"""
3030
31+ from starlette .requests import Request
32+ from starlette_admin .fields import HasOne
33+
3134from admin .views .base import OcotilloModelView
3235
3336
@@ -38,22 +41,56 @@ class ChemistrySampleInfoAdmin(OcotilloModelView):
3841
3942 # ========== Basic Configuration ==========
4043
41- name = "Chemistry Sample Info"
42- label = "Chemistry Sample Info"
44+ name = "NMA Chemistry Sample Info"
45+ label = "NMA Chemistry Sample Info"
4346 icon = "fa fa-flask"
4447
4548 # Integer PK
4649 pk_attr = "id"
4750 pk_type = int
4851
52+ def can_create (self , request : Request ) -> bool :
53+ return False
54+
55+ def can_edit (self , request : Request ) -> bool :
56+ return False
57+
58+ def can_delete (self , request : Request ) -> bool :
59+ return False
60+
4961 # ========== List View ==========
5062
51- sortable_fields = [
63+ list_fields = [
5264 "id" ,
5365 "nma_sample_pt_id" ,
54- "nma_object_id " ,
66+ "nma_wclab_id " ,
5567 "nma_sample_point_id" ,
68+ "nma_object_id" ,
69+ "nma_location_id" ,
70+ "thing_id" ,
71+ HasOne ("thing" , identity = "thing" ),
72+ "collection_date" ,
73+ "collection_method" ,
74+ "collected_by" ,
75+ "analyses_agency" ,
76+ "sample_type" ,
77+ "sample_material_not_h2o" ,
78+ "water_type" ,
79+ "study_sample" ,
80+ "data_source" ,
81+ "data_quality" ,
82+ "public_release" ,
83+ "added_day_to_date" ,
84+ "added_month_day_to_date" ,
85+ "sample_notes" ,
86+ ]
87+
88+ sortable_fields = [
89+ "id" ,
90+ "nma_sample_pt_id" ,
5691 "nma_wclab_id" ,
92+ "nma_sample_point_id" ,
93+ "nma_object_id" ,
5794 "collection_date" ,
5895 "sample_type" ,
5996 "data_source" ,
@@ -64,20 +101,20 @@ class ChemistrySampleInfoAdmin(OcotilloModelView):
64101 fields_default_sort = [("collection_date" , True )]
65102
66103 searchable_fields = [
67- "nma_sample_point_id" ,
68104 "nma_sample_pt_id" ,
69105 "nma_wclab_id" ,
106+ "nma_sample_point_id" ,
107+ "collection_date" ,
70108 "collected_by" ,
71109 "analyses_agency" ,
72- "sample_notes" ,
73- "collection_date" ,
74110 "sample_type" ,
75111 "sample_material_not_h2o" ,
76112 "water_type" ,
77113 "study_sample" ,
78114 "data_source" ,
79115 "data_quality" ,
80116 "public_release" ,
117+ "sample_notes" ,
81118 ]
82119
83120 page_size = 50
@@ -88,11 +125,12 @@ class ChemistrySampleInfoAdmin(OcotilloModelView):
88125 fields = [
89126 "id" ,
90127 "nma_sample_pt_id" ,
128+ "nma_wclab_id" ,
91129 "nma_sample_point_id" ,
92130 "nma_object_id" ,
93- "nma_wclab_id" ,
94131 "nma_location_id" ,
95132 "thing_id" ,
133+ HasOne ("thing" , identity = "thing" ),
96134 "collection_date" ,
97135 "collection_method" ,
98136 "collected_by" ,
@@ -109,30 +147,20 @@ class ChemistrySampleInfoAdmin(OcotilloModelView):
109147 "sample_notes" ,
110148 ]
111149
112- exclude_fields_from_create = [
113- "id" ,
114- "nma_object_id" ,
115- ]
116-
117- exclude_fields_from_edit = [
118- "id" ,
119- "nma_object_id" ,
120- ]
121-
122150 field_labels = {
123151 "id" : "ID" ,
124152 "nma_sample_pt_id" : "NMA SamplePtID (Legacy)" ,
153+ "nma_wclab_id" : "NMA WCLab_ID (Legacy)" ,
125154 "nma_sample_point_id" : "NMA SamplePointID (Legacy)" ,
126155 "nma_object_id" : "NMA OBJECTID (Legacy)" ,
127- "nma_wclab_id" : "NMA WCLab_ID (Legacy)" ,
128156 "nma_location_id" : "NMA LocationId (Legacy)" ,
129157 "thing_id" : "Thing ID" ,
130158 "collection_date" : "Collection Date" ,
131159 "collection_method" : "Collection Method" ,
132160 "collected_by" : "Collected By" ,
133161 "analyses_agency" : "Analyses Agency" ,
134162 "sample_type" : "Sample Type" ,
135- "sample_material_not_h2o" : "Sample Material ( Not H2O) " ,
163+ "sample_material_not_h2o" : "Sample Material Not H2O" ,
136164 "water_type" : "Water Type" ,
137165 "study_sample" : "Study Sample" ,
138166 "data_source" : "Data Source" ,
0 commit comments