Example #1
0
def update_participant_from_submitted_form(
    user_id: str,
    user_email: str,
    channel_id: str,
    incident_id: int,
    action: dict,
    db_session=None,
    slack_client=None,
):
    """Saves form data."""
    submitted_form = action.get("view")

    parsed_form_data = parse_submitted_form(submitted_form)

    added_reason = parsed_form_data.get(UpdateParticipantBlockFields.reason_added)
    participant_id = int(parsed_form_data.get(UpdateParticipantBlockFields.participant)["value"])
    selected_participant = participant_service.get(
        db_session=db_session, participant_id=participant_id
    )
    participant_service.update(
        db_session=db_session,
        participant=selected_participant,
        participant_in=ParticipantUpdate(added_reason=added_reason),
    )

    dispatch_slack_service.send_ephemeral_message(
        client=slack_client,
        conversation_id=channel_id,
        user_id=user_id,
        text="You have successfully updated the participant.",
    )
Example #2
0
def update_participant_from_submitted_form(action: dict, db_session=None):
    """Saves form data."""
    submitted_form = action.get("view")

    parsed_form_data = parse_submitted_form(submitted_form)

    added_reason = parsed_form_data.get(
        UpdateParticipantBlockFields.reason_added)
    participant_id = int(
        parsed_form_data.get(
            UpdateParticipantBlockFields.participant)["value"])
    selected_participant = participant_service.get(
        db_session=db_session, participant_id=participant_id)
    participant_service.update(
        db_session=db_session,
        participant=selected_participant,
        participant_in=ParticipantUpdate(added_reason=added_reason),
    )
Example #3
0
def test_update(session, participant):
    from dispatch.participant.service import update
    from dispatch.participant.models import ParticipantUpdate

    location = "Updated location"

    participant_in = ParticipantUpdate(location=location)
    participant = update(db_session=session,
                         participant=participant,
                         participant_in=participant_in)
    assert participant.location == location