コード例 #1
0
def build_submission_metadata_context(survey_type: str, submitted_at: datetime,
                                      tx_id: str) -> dict:
    submitted_on = {
        "term":
        lazy_gettext("Submitted on:"),
        "descriptions": [{
            "description":
            lazy_gettext("{date} at {time}").format(
                date=format_datetime(submitted_at, format="dd LLLL yyyy"),
                time=format_datetime(submitted_at, format="HH:mm"),
            )
        }],
    }
    submission_reference = {
        "term": lazy_gettext("Submission reference:"),
        "descriptions": [{
            "description": convert_tx_id(tx_id)
        }],
    }
    if survey_type == "social":
        return {
            "data-qa": "metadata",
            "termCol": 3,
            "descriptionCol": 9,
            "itemsList": [submitted_on],
        }
    return {
        "data-qa": "metadata",
        "termCol": 5,
        "descriptionCol": 7,
        "itemsList": [submitted_on, submission_reference],
    }
コード例 #2
0
ファイル: errors.py プロジェクト: ONSdigital/eq-survey-runner
def _render_error_page(status_code):
    tx_id = None
    metadata = get_metadata(current_user)
    if metadata:
        tx_id = convert_tx_id(metadata["tx_id"])
    user_agent = user_agent_parser.Parse(request.headers.get('User-Agent', ''))
    return render_theme_template('default', 'errors/error.html',
                                 status_code=status_code,
                                 ua=user_agent, tx_id=tx_id), status_code
コード例 #3
0
def build_metadata_context_for_survey_completed(survey_completed_metadata):
    return {
        'survey': {
            'period_str': survey_completed_metadata['period_str'],
        },
        'respondent': {
            'tx_id': convert_tx_id(survey_completed_metadata['tx_id']),
            'respondent_id': survey_completed_metadata['ru_ref'],
        },
    }
def build_metadata_context_for_survey_completed(session_data):

    metadata_context = {
        'submitted_time': session_data.submitted_time,
        'tx_id': convert_tx_id(session_data.tx_id),
        'ru_ref': session_data.ru_ref,
        'trad_as': session_data.trad_as,
    }

    if session_data.period_str:
        metadata_context['period_str'] = session_data.period_str
    if session_data.ru_name:
        metadata_context['ru_name'] = session_data.ru_name

    return metadata_context
コード例 #5
0
def build_metadata_context_for_survey_completed(session_data):

    metadata_context = {
        "submitted_time": session_data.submitted_time,
        "tx_id": convert_tx_id(session_data.tx_id),
        "ru_ref": session_data.ru_ref,
        "trad_as": session_data.trad_as,
        "account_service_url": session_data.account_service_url,
    }

    if session_data.period_str:
        metadata_context["period_str"] = session_data.period_str
    if session_data.ru_name:
        metadata_context["ru_name"] = session_data.ru_name

    return metadata_context
コード例 #6
0
def build_default_thank_you_context(session_data: SessionData) -> Mapping:

    context = {
        "submitted_time": session_data.submitted_time,
        "tx_id": convert_tx_id(session_data.tx_id),
        "ru_ref": session_data.ru_ref,
        "trad_as": session_data.trad_as,
        "account_service_url": session_data.account_service_url,
        "hide_signout_button": True,
    }

    if session_data.period_str:
        context["period_str"] = session_data.period_str
    if session_data.ru_name:
        context["ru_name"] = session_data.ru_name

    return context
コード例 #7
0
ファイル: metadata_context.py プロジェクト: qateam123/eq
def _build_respondent_meta(metadata):
    if metadata:
        respondent_id = metadata["ru_ref"]
        name = metadata["ru_name"]
        trading_as = metadata["trad_as"]
    else:
        respondent_id = None
        name = None
        trading_as = None

    respondent_meta = {
        "tx_id": convert_tx_id(metadata["tx_id"]),
        "respondent_id": respondent_id,
        "address": {
            "name": name,
            "trading_as": trading_as,
        },
    }
    return respondent_meta
コード例 #8
0
    def _build_respondent_meta():
        metadata = get_metadata(current_user)

        if metadata:
            respondent_id = metadata["ru_ref"]
            name = metadata["ru_name"]
            trading_as = metadata["trad_as"]
        else:
            respondent_id = None
            name = None
            trading_as = None

        respondent_meta = {
            "tx_id": convert_tx_id(metadata["tx_id"]),
            "respondent_id": respondent_id,
            "address": {
                "name": name,
                "trading_as": trading_as,
            },
        }
        return respondent_meta
コード例 #9
0
ファイル: errors.py プロジェクト: qateam123/eq
def get_tx_id():
    tx_id = None
    metadata = get_metadata(current_user)
    if metadata:
        tx_id = convert_tx_id(metadata["tx_id"])
    return tx_id
コード例 #10
0
def test_convert_tx_id():
    tx_id_to_convert = "bc26d5ef-8475-4710-ac82-753a0a150708"

    assert is_valid_uuid(tx_id_to_convert)
    assert "bc26-d5ef-8475-4710" == convert_tx_id(tx_id_to_convert)