Example #1
0
def rating_feedback_from_submitted_form(action: dict, db_session=None):
    """Adds rating and feeback to incident based on submitted form data."""
    incident_id = action["view"]["private_metadata"]["incident_id"]
    incident = incident_service.get(db_session=db_session,
                                    incident_id=incident_id)

    user_email = action["user"]["email"]
    participant = participant_service.get_by_incident_id_and_email(
        db_session=db_session, incident_id=incident_id, email=user_email)

    submitted_form = action.get("view")
    parsed_form_data = parse_submitted_form(submitted_form)

    feedback = parsed_form_data.get(IncidentRatingFeedbackBlockFields.feedback)
    rating = parsed_form_data.get(
        IncidentRatingFeedbackBlockFields.rating)["value"]
    anonymous = parsed_form_data.get(
        IncidentRatingFeedbackBlockFields.anonymous)["value"]

    feedback_in = FeedbackCreate(rating=rating, feedback=feedback)
    feedback = feedback_service.create(db_session=db_session,
                                       feedback_in=feedback_in)

    incident.feedback.append(feedback)

    if anonymous == "":
        participant.feedback.append(feedback)
        db_session.add(participant)

    db_session.add(incident)
    db_session.commit()
Example #2
0
def test_create(session, incident, incident_type, incident_priority):
    from dispatch.feedback.service import create
    from dispatch.feedback.models import FeedbackCreate

    incident.incident_type = incident_type
    incident.incident_priority = incident_priority
    rating = "Neither satisfied nor dissatisfied"
    feedback = "The incident commander did an excellent job"

    feedback_in = FeedbackCreate(rating=rating,
                                 feedback=feedback,
                                 incident=incident)
    feedback = create(db_session=session, feedback_in=feedback_in)
    assert feedback
Example #3
0
def rating_feedback_from_submitted_form(
    user_id: str,
    user_email: str,
    channel_id: str,
    incident_id: int,
    action: dict,
    config: SlackConversationConfiguration = None,
    db_session=None,
    slack_client=None,
):
    """Adds rating and feeback to incident based on submitted form data."""
    incident = incident_service.get(db_session=db_session, incident_id=incident_id)

    participant = participant_service.get_by_incident_id_and_email(
        db_session=db_session, incident_id=incident_id, email=user_email
    )

    submitted_form = action.get("view")
    parsed_form_data = parse_submitted_form(submitted_form)

    feedback = parsed_form_data.get(RatingFeedbackBlockId.feedback)
    rating = parsed_form_data.get(RatingFeedbackBlockId.rating, {}).get("value")

    feedback_in = FeedbackCreate(
        rating=rating, feedback=feedback, project=incident.project, incident=incident
    )
    feedback = feedback_service.create(db_session=db_session, feedback_in=feedback_in)

    incident.feedback.append(feedback)

    # we only really care if this exists, if it doesn't then flag is false
    if not parsed_form_data.get(RatingFeedbackBlockId.anonymous):
        participant.feedback.append(feedback)
        db_session.add(participant)

    db_session.add(incident)
    db_session.commit()

    send_message(
        client=slack_client,
        conversation_id=user_id,
        text="Thank you for your feedback!",
    )
Example #4
0
def rating_feedback_from_submitted_form(
    user_id: str,
    user_email: str,
    channel_id: str,
    incident_id: int,
    action: dict,
    db_session=None,
    slack_client=None,
):
    """Adds rating and feeback to incident based on submitted form data."""
    incident = incident_service.get(db_session=db_session,
                                    incident_id=incident_id)

    participant = participant_service.get_by_incident_id_and_email(
        db_session=db_session, incident_id=incident_id, email=user_email)

    submitted_form = action.get("view")
    parsed_form_data = parse_submitted_form(submitted_form)

    feedback = parsed_form_data.get(RatingFeedbackBlockId.feedback)
    rating = parsed_form_data.get(RatingFeedbackBlockId.rating)["value"]
    anonymous = parsed_form_data.get(RatingFeedbackBlockId.anonymous)["value"]

    feedback_in = FeedbackCreate(rating=rating,
                                 feedback=feedback,
                                 project=incident.project)
    feedback = feedback_service.create(db_session=db_session,
                                       feedback_in=feedback_in)

    incident.feedback.append(feedback)

    if anonymous == "":
        participant.feedback.append(feedback)
        db_session.add(participant)

    db_session.add(incident)
    db_session.commit()

    send_message(
        client=slack_client,
        conversation_id=user_id,
        text="Thank you for your feedback!",
    )