(key, value)
status=<STATUS SLUG>

    Status filtering is applied to the event as well as to the messages / XFormSession.
status=<STATUS SLUG>
status = <STATUS SLUG >
def _status_filter_consumer(key, value):
    """status=<STATUS SLUG>

    Status filtering is applied to the event as well as to the messages / XFormSession.
    """
    slug_values = {v: k for k, v in MessagingEvent.STATUS_SLUGS.items()}
    if key != "status":
        return {}

    try:
        model_value = slug_values[value]
    except KeyError:
        raise BadRequest(SLUG_FILTER_ERROR_MESSAGE.format(value=value, filter_name='status'))

    # match functionality in corehq.pps.reports.standard.sms.MessagingEventsReport.get_filters
    if model_value == MessagingEvent.STATUS_ERROR:
        return {"status": (Q(status=model_value) | Q(sms__error=True))}
    elif model_value == MessagingEvent.STATUS_IN_PROGRESS:
        # We need to check for id__isnull=False below because the
        # query we make in this report has to do a left join, and
        # in this particular filter we can only validly check
        # session_is_open=True if there actually are
        # subevent and xforms session records
        return {"status": (
            Q(status=model_value)
            | (Q(xforms_session__id__isnull=False) & Q(xforms_session__session_is_open=True))
        )}
    elif model_value == MessagingEvent.STATUS_NOT_COMPLETED:
        return {"status": (
            Q(status=model_value)
            | (Q(xforms_session__session_is_open=False) & Q(xforms_session__submission_id__isnull=True))
        )}
    else:
        return {"status": model_value}
def _status_filter_consumer ( key , value ) : slug_values = { v : k for k , v in MessagingEvent . STATUS_SLUGS . items ( ) } if key != "status" : return { } try : model_value = slug_values [ value ] except KeyError : raise BadRequest ( SLUG_FILTER_ERROR_MESSAGE . format ( value = value , filter_name = 'status' ) ) # match functionality in corehq.pps.reports.standard.sms.MessagingEventsReport.get_filters if model_value == MessagingEvent . STATUS_ERROR : return { "status" : ( Q ( status = model_value ) | Q ( sms__error = True ) ) } elif model_value == MessagingEvent . STATUS_IN_PROGRESS : # We need to check for id__isnull=False below because the # query we make in this report has to do a left join, and # in this particular filter we can only validly check # session_is_open=True if there actually are # subevent and xforms session records return { "status" : ( Q ( status = model_value ) | ( Q ( xforms_session__id__isnull = False ) & Q ( xforms_session__session_is_open = True ) ) ) } elif model_value == MessagingEvent . STATUS_NOT_COMPLETED : return { "status" : ( Q ( status = model_value ) | ( Q ( xforms_session__session_is_open = False ) & Q ( xforms_session__submission_id__isnull = True ) ) ) } else : return { "status" : model_value }