def test_format_service_price(price_min, formatted_price):
    service = {
        'priceMin': price_min,
        'priceMax': '13.13',
        'priceUnit': 'Unit',
        'priceInterval': 'Second',
    }

    assert format_service_price(service) == formatted_price
コード例 #2
0
def test_format_service_price(price_min, formatted_price):
    service = {
        'priceMin': price_min,
        'priceMax': '13.13',
        'priceUnit': 'Unit',
        'priceInterval': 'Second',
    }

    assert format_service_price(service) == formatted_price
 def __init__(self, service_data):
     self.price = format_service_price(service_data)
     self.contact = {
         'name': 'Contact name',
         'phone': 'Contact number',
         'email': 'Contact email'
     }
     self.priceCaveats = self.get_price_caveats(service_data)
     self.serviceId = self.get_service_id(service_data)
     self.documents = self.get_documents(service_data)
     self.externalFrameworkUrl = self.get_external_framework_url(service_data)
コード例 #4
0
 def __init__(self, service_data, declaration=None):
     self.price = format_service_price(service_data)
     self.contact = {
         'name': 'Contact name',
         'phone': 'Contact number',
         'email': 'Contact email'
     }
     self.priceCaveats = self.get_price_caveats(service_data)
     self.serviceId = self.get_service_id(service_data)
     self.declaration = declaration or {}
     self.documents = self.get_documents(service_data)
コード例 #5
0
 def __init__(self, service_data):
     self.price = format_service_price(service_data)
     self.contact = {
         'name': 'Contact name',
         'phone': 'Contact number',
         'email': 'Contact email'
     }
     self.priceCaveats = self.get_price_caveats(service_data)
     self.serviceId = self.get_service_id(service_data)
     self.documents = self.get_documents(service_data)
     self.externalFrameworkUrl = self.get_external_framework_url(
         service_data)
コード例 #6
0
def framework_submission_services(framework_slug, lot_slug):
    framework, lot = get_framework_and_lot(data_api_client, framework_slug,
                                           lot_slug)

    drafts, complete_drafts = get_lot_drafts(data_api_client, framework_slug,
                                             lot_slug)
    declaration_status = get_declaration_status(data_api_client,
                                                framework_slug)
    if framework['status'] == 'pending' and declaration_status != 'complete':
        abort(404)

    if lot['oneServiceLimit']:
        draft = next(iter(drafts + complete_drafts), None)
        if not draft:
            draft = data_api_client.create_new_draft_service(
                framework_slug,
                lot_slug,
                current_user.supplier_id,
                {},
                current_user.email_address,
            )['services']

        return redirect(
            url_for('.view_service_submission',
                    framework_slug=framework_slug,
                    lot_slug=lot_slug,
                    service_id=draft['id']))

    for draft in chain(drafts, complete_drafts):
        draft['priceString'] = format_service_price(draft)
        content = content_loader.get_manifest(framework_slug,
                                              'edit_submission').filter(draft)
        sections = content.summary(draft)

        unanswered_required, unanswered_optional = count_unanswered_questions(
            sections)
        draft.update({
            'unanswered_required': unanswered_required,
            'unanswered_optional': unanswered_optional,
        })

    return render_template(
        "frameworks/services.html",
        complete_drafts=list(reversed(complete_drafts)),
        drafts=list(reversed(drafts)),
        declaration_status=declaration_status,
        framework=framework,
        lot=lot,
    ), 200
コード例 #7
0
def view_service(service_id):
    try:
        service = data_api_client.get_service(service_id)
        if service is None:
            flash(NO_SERVICE_MESSAGE.format(service_id=service_id), 'error')
            return redirect(url_for('.search_suppliers_and_services'))
        service_data = service['services']
    except HTTPError:
        flash(API_ERROR_MESSAGE.format(service_id=service_id), 'error')
        return redirect(url_for('.search_suppliers_and_services'))

    framework = get_framework_or_404(data_api_client,
                                     service_data['frameworkSlug'],
                                     allowed_statuses=['live', 'expired'])

    removed_by = removed_at = None
    if service_data['status'] != 'published':
        most_recent_audit_events = data_api_client.find_audit_events(
            latest_first="true",
            object_id=service_id,
            object_type="services",
            audit_type=AuditTypes.update_service_status)
        if most_recent_audit_events.get('auditEvents'):
            removed_by = most_recent_audit_events['auditEvents'][0]['user']
            removed_at = most_recent_audit_events['auditEvents'][0][
                'createdAt']

    service_data['priceString'] = format_service_price(service_data)
    sections = content_loader.get_manifest(
        service_data['frameworkSlug'],
        'edit_service_as_admin',
    ).filter(service_data, inplace_allowed=True).summary(service_data,
                                                         inplace_allowed=True)

    return render_template(
        "view_service.html",
        framework=framework,
        sections=sections,
        service_data=service_data,
        service_id=service_id,
        removed_by=removed_by,
        removed_at=removed_at,
        remove=request.args.get('remove', None),
        publish=request.args.get('publish', None),
    )
コード例 #8
0
def view(service_id):
    try:
        service = data_api_client.get_service(service_id)
        if service is None:
            flash({'no_service': service_id}, 'error')
            return redirect(url_for('.index'))
        service_data = service['services']
    except HTTPError:
        flash({'api_error': service_id}, 'error')
        return redirect(url_for('.index'))

    service_data['priceString'] = format_service_price(service_data)
    content = content_loader.get_manifest(
        'g-cloud-6', 'edit_service_as_admin').filter(service_data)

    return render_template_with_csrf("view_service.html",
                                     sections=content,
                                     service_data=service_data,
                                     service_id=service_id)
コード例 #9
0
def view(service_id):
    try:
        service = data_api_client.get_service(service_id)
        if service is None:
            flash({'no_service': service_id}, 'error')
            return redirect(url_for('.index'))
        service_data = service['services']
    except HTTPError:
        flash({'api_error': service_id}, 'error')
        return redirect(url_for('.index'))

    service_data['priceString'] = format_service_price(service_data)
    content = content_loader.get_manifest('g-cloud-6', 'edit_service_as_admin').filter(service_data)

    return render_template_with_csrf(
        "view_service.html",
        sections=content,
        service_data=service_data,
        service_id=service_id
    )
コード例 #10
0
def framework_submission_services(framework_slug, lot_slug):
    framework, lot = get_framework_and_lot(data_api_client, framework_slug, lot_slug)

    drafts, complete_drafts = get_lot_drafts(data_api_client, framework_slug, lot_slug)
    declaration_status = get_declaration_status(data_api_client, framework_slug)
    if framework['status'] == 'pending' and declaration_status != 'complete':
        abort(404)

    if lot['oneServiceLimit']:
        draft = next(iter(drafts + complete_drafts), None)
        if not draft:
            draft = data_api_client.create_new_draft_service(
                framework_slug, lot_slug, current_user.supplier_code, {}, current_user.email_address,
            )['services']

        return redirect(
            url_for('.view_service_submission',
                    framework_slug=framework_slug, lot_slug=lot_slug, service_id=draft['id'])
        )

    for draft in chain(drafts, complete_drafts):
        draft['priceString'] = format_service_price(draft)
        content = content_loader.get_manifest(framework_slug, 'edit_submission').filter(draft)
        sections = content.summary(draft)

        unanswered_required, unanswered_optional = count_unanswered_questions(sections)
        draft.update({
            'unanswered_required': unanswered_required,
            'unanswered_optional': unanswered_optional,
        })

    return render_template_with_csrf(
        "frameworks/services.html",
        complete_drafts=list(reversed(complete_drafts)),
        drafts=list(reversed(drafts)),
        declaration_status=declaration_status,
        framework=framework,
        lot=lot
    )
コード例 #11
0
 def check_service_price_formatting(price_min, formatted_price):
     service['priceMin'] = price_min
     assert format_service_price(service) == formatted_price