예제 #1
0
def get_framework_contract_title(content_path: str,
                                 framework_slug: str) -> str:
    """The contract title is different for G-Cloud and DOS. Look up the correct name with the content loader"""
    content_loader = ContentLoader(content_path)
    content_loader.load_messages(framework_slug, ["e-signature"])
    return str(
        content_loader.get_message(framework_slug, "e-signature",
                                   "framework_contract_title"))
    mail_client = scripts_notify_client(GOVUK_NOTIFY_API_KEY, logger=logger)
    api_client = DataAPIClient(base_url=get_api_endpoint_from_stage(STAGE),
                               auth_token=get_auth_token('api', STAGE))

    context_helper = SuccessfulSupplierContextForNotify(
        api_client, FRAMEWORK_SLUG, supplier_ids=supplier_ids, logger=logger)
    context_helper.populate_data()
    context_data = context_helper.get_users_personalisations()
    framework = api_client.get_framework(FRAMEWORK_SLUG).get('frameworks')

    prefix = "[Dry Run] " if DRY_RUN else ""

    # Add in any framework-specific dates etc here
    extra_template_context = {
        "contract_title":
        content_loader.get_message(FRAMEWORK_SLUG, 'e-signature',
                                   'framework_contract_title'),
        "intentionToAwardAt_dateformat":
        nodaydateformat(framework['intentionToAwardAtUTC']),
        "frameworkLiveAt_dateformat":
        nodaydateformat(framework['frameworkLiveAtUTC'])
    }

    user_count = len(context_data)
    for user_number, (user_email,
                      personalisation) in enumerate(context_data.items(),
                                                    start=1):
        logger.info(
            f"{prefix}Sending email to supplier user {user_number} of {user_count} '{hash_string(user_email)}'"
        )

        personalisation.update(extra_template_context)
예제 #3
0
            arguments.get("--notify-template-id")):
        raise ValueError(
            "Either specify both --notify-key and --notify-template-id or neither"
        )

    stage = arguments['<stage>']
    data_api_client = DataAPIClient(get_api_endpoint_from_stage(stage),
                                    get_auth_token('api', stage))
    framework_slug = arguments['<framework_slug>']
    framework = data_api_client.get_framework(framework_slug)["frameworks"]
    document_directory = arguments['<documents_directory>']
    content_path = arguments['<content_path>']
    content_loader = ContentLoader(content_path)
    if framework['isESignatureSupported']:
        content_loader.load_messages(framework_slug, ['e-signature'])
        contract_title = content_loader.get_message(
            framework_slug, 'e-signature', 'framework_contract_title')
    else:
        contract_title = 'Framework Agreement'

    dry_run = arguments['--dry-run']
    dm_notify_client = arguments.get("--notify-key") and scripts_notify_client(
        arguments["--notify-key"], logger=logger)

    if dry_run:
        bucket = None
    else:
        bucket = S3(get_bucket_name(stage, "agreements"))

    failure_count = 0

    for file_path in get_all_files_of_type(document_directory, "pdf"):