diff --git a/core/lexicon.json b/core/lexicon.json index 17f27765e..170254224 100644 --- a/core/lexicon.json +++ b/core/lexicon.json @@ -17,7 +17,7 @@ {"name": "drilling_fluid", "description": null}, {"name": "elevation_method", "description": null}, {"name": "email_type", "description": null}, - {"name": "field_contact_role", "description": null}, + {"name": "participant_role", "description": null}, {"name": "geochronology", "description": null}, {"name": "horizontal_datum", "description": null}, {"name": "value_reason", "description": null}, @@ -262,10 +262,10 @@ {"categories": ["relation"], "term": "PLSS", "definition": "Public Land Survey System ID"}, {"categories": ["activity_type"], "term": "groundwater level", "definition": "groundwater level"}, {"categories": ["activity_type"], "term": "water chemistry", "definition": "water chemistry"}, - {"categories": ["field_contact_role"], "term": "Lead", "definition": "the leader of the field event"}, - {"categories": ["field_contact_role"], "term": "Participant", "definition": "a person participating in the field event"}, - {"categories": ["field_contact_role"], "term": "Observer", "definition": "a person observing the field event"}, - {"categories": ["field_contact_role"], "term": "Visitor", "definition": "a person visiting the field event"}, + {"categories": ["participant_role"], "term": "Lead", "definition": "the leader of the field event"}, + {"categories": ["participant_role"], "term": "Participant", "definition": "a person participating in the field event"}, + {"categories": ["participant_role"], "term": "Observer", "definition": "a person observing the field event"}, + {"categories": ["participant_role"], "term": "Visitor", "definition": "a person visiting the field event"}, {"categories": ["sample_matrix"], "term": "water", "definition": "water"}, {"categories": ["sample_matrix"], "term": "soil", "definition": "soil"}, {"categories": ["thing_type"], "term": "observation well", "definition": "a well used to monitor groundwater levels"}, diff --git a/db/contact.py b/db/contact.py index 3f4995f67..db0dfce1f 100644 --- a/db/contact.py +++ b/db/contact.py @@ -87,7 +87,7 @@ class Contact(Base, AutoBaseMixin, ReleaseMixin): # One-To-Many: A Contact can participate in many Field Events. field_event_participants: Mapped[list["FieldEventParticipant"]] = relationship( "FieldEventParticipant", - back_populates="contact", + back_populates="participant", cascade="all, delete-orphan", passive_deletes=True, ) diff --git a/db/field.py b/db/field.py index 551859dcc..0ebf7e6e0 100644 --- a/db/field.py +++ b/db/field.py @@ -31,7 +31,7 @@ class FieldEventParticipant(Base, AutoBaseMixin, ReleaseMixin): ) # TODO: get AMP feedback on the roles - field_contact_role: Mapped[str] = lexicon_term( + participant_role: Mapped[str] = lexicon_term( nullable=False, comment="Role of the contact in the field event" ) @@ -39,7 +39,7 @@ class FieldEventParticipant(Base, AutoBaseMixin, ReleaseMixin): field_event: Mapped["FieldEvent"] = relationship( "FieldEvent", back_populates="field_event_participants" ) - contact: Mapped["Contact"] = relationship( + participant: Mapped["Contact"] = relationship( "Contact", back_populates="field_event_participants" ) @@ -100,8 +100,8 @@ class FieldEvent(Base, AutoBaseMixin, ReleaseMixin): # --- Association Proxies --- # Proxy to directly access the Contact objects participating in this event. - contacts: AssociationProxy[list["Contact"]] = association_proxy( - "field_event_participants", "contact" + participants: AssociationProxy[list["Contact"]] = association_proxy( + "field_event_participants", "participant" ) diff --git a/db/sample.py b/db/sample.py index 04e647c62..9fe46f797 100644 --- a/db/sample.py +++ b/db/sample.py @@ -104,7 +104,7 @@ class Sample(Base, AutoBaseMixin, ReleaseMixin): "field_activity", "field_event.thing" ) contact: AssociationProxy["Contact"] = association_proxy( - "field_event_participant", "contact" + "field_event_participant", "participant" ) observations: Mapped[list["Observation"]] = relationship( "Observation", diff --git a/services/sample_helper.py b/services/sample_helper.py index e8fecab4d..20423de80 100644 --- a/services/sample_helper.py +++ b/services/sample_helper.py @@ -18,7 +18,7 @@ def get_db_samples( .joinedload(FieldActivity.field_event) .joinedload(FieldEvent.thing), joinedload(Sample.field_event_participant).joinedload( - FieldEventParticipant.contact + FieldEventParticipant.participant ), # Eagerly load related Contact ) diff --git a/tests/conftest.py b/tests/conftest.py index 062cf5e9f..97a28ffe0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -501,7 +501,7 @@ def field_event_participant(field_event, contact): field_event_participant = FieldEventParticipant( field_event_id=field_event.id, contact_id=contact.id, - field_contact_role="Lead", + participant_role="Lead", ) session.add(field_event_participant) session.commit()