Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions core/lexicon.json

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to add these roles to the role category that exists for Contacts, or is it better to have a separate category for participant_role?

@jacob-a-brown jacob-a-brown Oct 3, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first I thought to do that, but they kind of serve two different purposes. role describes the person (or organization) (e.g. Geologist, Biologist, Technician etc), whereas participant_role describes what role the person had in the field event (Lead, Participant, Observer etc). Trevor Kludt, for example, is a Technician, but during the field events he can be a Lead or a Participant

Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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"},
Expand Down
2 changes: 1 addition & 1 deletion db/contact.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
8 changes: 4 additions & 4 deletions db/field.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ 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"
)

# --- Relationships ---
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"
)

Expand Down Expand Up @@ -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"
)


Expand Down
2 changes: 1 addition & 1 deletion db/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion services/sample_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading