def suppliers_details(supplier_id): supplier = data_api_client.get_supplier( supplier_id=supplier_id)["suppliers"] all_frameworks = data_api_client.find_frameworks().get('frameworks') live_framework_names = [ f['name'] for f in all_frameworks if f['status'] == 'live' and f['framework'] == 'g-cloud' ] if any( supplier.get('service_counts', {}).get(framework_name, 0) > 0 for framework_name in live_framework_names): first_character_of_supplier_name = supplier["name"][:1] if is_alpha(first_character_of_supplier_name): prefix = process_prefix(prefix=first_character_of_supplier_name, format='template') else: prefix = u"other" return render_template( 'suppliers_details.html', supplier=supplier, prefix=prefix, gcloud_framework_description=get_framework_description( data_api_client, 'g-cloud'), ) else: abort(404)
def get_service_by_id(service_id): try: service = data_api_client.get_service(service_id) if service is None: abort(404, "Service ID '{}' can not be found".format(service_id)) if service['services']['frameworkStatus'] not in ("live", "expired"): abort(404, "Service ID '{}' can not be found".format(service_id)) service_data = service['services'] service_view_data = Service( service_data, content_loader.get_builder('inoket-1', 'display_service').filter( service_data ) ) try: # get supplier data and add contact info to service object supplier = data_api_client.get_supplier( service_data['supplierId'] ) supplier_data = supplier['suppliers'] service_view_data.meta.set_contact_attribute( supplier_data['contactInformation'][0].get('contactName'), supplier_data['contactInformation'][0].get('phoneNumber'), supplier_data['contactInformation'][0].get('email') ) except HTTPError as e: abort(e.status_code) service_unavailability_information = None status_code = 200 if service['serviceMadeUnavailableAuditEvent'] is not None: service_unavailability_information = { 'date': dateformat(service['serviceMadeUnavailableAuditEvent']['createdAt']), 'type': service['serviceMadeUnavailableAuditEvent']['type'] } # mark the resource as unavailable in the headers status_code = 410 return render_template( 'service.html', service=service_view_data, service_unavailability_information=service_unavailability_information, lot=service_view_data.lot.lower(), lot_label=get_label_for_lot_param(service_view_data.lot.lower()), service_id=service_id), status_code except AuthException: abort(500, "Application error") except KeyError: abort(404, "Service ID '%s' can not be found" % service_id) except HTTPError as e: abort(e.status_code)
def get_service_by_id(service_id): try: service = data_api_client.get_service(service_id) if service is None: abort(404, "Service ID '{}' can not be found".format(service_id)) if service['services']['frameworkStatus'] not in ("live", "expired"): abort(404, "Service ID '{}' can not be found".format(service_id)) service_data = service['services'] service_view_data = Service( service_data, content_loader.get_builder('g-cloud-6', 'display_service').filter(service_data)) try: # get supplier data and add contact info to service object supplier = data_api_client.get_supplier( service_data['supplierCode']) supplier_data = supplier['suppliers'] service_view_data.meta.set_contact_attribute( supplier_data['contactInformation'][0].get('contactName'), supplier_data['contactInformation'][0].get('phoneNumber'), supplier_data['contactInformation'][0].get('email')) except HTTPError as e: abort(e.status_code) date_formatter = DateFormatter(current_app.config['DM_TIMEZONE']) service_unavailability_information = None status_code = 200 if service['serviceMadeUnavailableAuditEvent'] is not None: service_unavailability_information = { 'date': date_formatter.dateformat( service['serviceMadeUnavailableAuditEvent']['createdAt']), 'type': service['serviceMadeUnavailableAuditEvent']['type'] } # mark the resource as unavailable in the headers status_code = 410 return render_template('service.html', service=service_view_data, service_unavailability_information= service_unavailability_information, lot=service_view_data.lot.lower(), lot_label=get_label_for_lot_param( service_view_data.lot.lower())), status_code except AuthException: abort(500, "Application error") except KeyError: abort(404, "Service ID '%s' can not be found" % service_id) except HTTPError as e: abort(e.status_code)
def suppliers_details(supplier_id): supplier = data_api_client.get_supplier(supplier_id=supplier_id)["suppliers"] template_data = get_template_data(main, {"title": "Digital Marketplace - Suppliers"}) first_character_of_supplier_name = supplier["name"][:1] if is_alpha(first_character_of_supplier_name): prefix = process_prefix(supplier["name"][:1]) else: prefix = "123" return render_template("suppliers_details.html", supplier=supplier, prefix=prefix, **template_data)
def suppliers_details(supplier_id): supplier = data_api_client.get_supplier( supplier_id=supplier_id)["suppliers"] first_character_of_supplier_name = supplier["name"][:1] if is_alpha(first_character_of_supplier_name): prefix = process_prefix( prefix=first_character_of_supplier_name, format='template') else: prefix = u"other" return render_template( 'suppliers_details.html', supplier=supplier, prefix=prefix )
def create_new_work_order(framework_slug, lot_slug, brief_id): brief = data_api_client.get_brief(brief_id)["briefs"] if not is_brief_correct( brief, framework_slug, lot_slug, current_user.id ): abort(404) form = WorkOrderSellerForm(formdata=request.form, data_api_client=data_api_client, brief_id=brief_id) if not form.validate(): return render_template_with_csrf( 'workorder/select-seller.html', status_code=400, brief=brief, form=form ) try: seller = data_api_client.get_supplier(form.seller.data)['supplier'] work_order = data_api_client.create_work_order( briefId=brief_id, supplierCode=form.seller.data, workOrder=_create_work_order_from_brief(brief, seller) )['workOrder'] except APIError as e: form.errors['seller'] = [e.message] return render_template_with_csrf( 'workorder/select-seller.html', status_code=e.status_code, brief=brief, form=form, ) return redirect( url_for( 'buyers.get_work_order', work_order_id=work_order['id'], ) )
def get_brief_by_id(framework_slug, brief_id): briefs = data_api_client.get_brief(brief_id) brief = briefs.get('briefs') if brief['lotSlug'] in ['rfx', 'atm', 'specialist', 'training2']: return redirect('/2/%s/opportunities/%s' % (framework_slug, brief_id), 301) if brief['status'] not in ['live', 'closed']: if ( not current_user.is_authenticated or (brief['users'] and brief['users'][0]['id'] != current_user.id) or current_user.id not in [tb.get('userId') for tb in brief.get('teamBriefs', [])] ): abort(404, "Opportunity '{}' can not be found".format(brief_id)) if current_user.is_authenticated and current_user.role == 'supplier': brief_responses = data_api_client.find_brief_responses( brief_id, current_user.supplier_code)["briefResponses"] selected_for_brief = _is_supplier_selected_for_brief(brief) else: brief_responses = None selected_for_brief = False brief['clarificationQuestions'] = [ dict(question, number=index+1) for index, question in enumerate(brief['clarificationQuestions']) ] brief_content = content_loader.get_builder(framework_slug, 'display_brief').filter( brief ) sections = brief_content.summary(brief) unanswered_required, unanswered_optional = count_unanswered_questions(sections) brief_of_current_user = False if not current_user.is_anonymous and len(brief.get('users')) > 0: brief_of_current_user = brief['users'][0]['id'] == current_user.id is_restricted_brief = brief.get('sellerSelector', '') in ('someSellers', 'oneSeller') brief_published_date = brief['dates'].get('published_date', None) feature_date = current_app.config['MULTI_CANDIDATE_PUBLISHED_DATE'] published_date = pendulum.parse(brief_published_date) if brief_published_date else feature_date.subtract(days=1) application_url = "/2/brief/{}/respond".format(brief['id']) application_specialist_url = application_url application_specialist_submitted_url = None if published_date >= feature_date: application_specialist_url = "/2/brief/{}/specialist/respond".format(brief['id']) application_specialist_submitted_url = "/2/brief/{}/specialist/respond/submitted".format(brief['id']) application_training_url = "/2/brief/{}/training/respond".format(brief['id']) add_case_study_url = None profile_application_status = None supplier = None unassessed_domains = {} assessed_domains = {} profile_url = None supplier_assessments = {} supplier_framework = None if current_user.is_authenticated: if current_user.supplier_code is not None: supplier = data_api_client.get_supplier( current_user.supplier_code ).get('supplier', None) profile_application_id = current_user.application_id if supplier is not None: profile_url = '/supplier/{}'.format(supplier.get('code')) assessed_domains = supplier.get('domains').get('assessed', None) unassessed_domains = supplier.get('domains').get('unassessed', None) legacy_domains = supplier.get('domains').get('legacy', None) if profile_application_id is None: profile_application_id = supplier.get('application_id', None) supplier_code = supplier.get('code') supplier_assessments = data_api_client.req.assessments().supplier(supplier_code).get() if len(legacy_domains) != 0: for i in range(len(legacy_domains)): supplier_assessments['assessed'].append(legacy_domains[i]) supplier_framework_ids = supplier.get('frameworks') for i in range(len(supplier_framework_ids)): if supplier.get('frameworks')[i].get('framework_id') == 7: supplier_framework = 'digital-marketplace' if supplier_framework is None: supplier_framework = 'digital-service-professionals' if profile_application_id is not None: try: profile_application = data_api_client.req.applications(profile_application_id).get() if unassessed_domains is None: unassessed_domains = profile_application.get( 'application').get('supplier').get('domains', None).get('unassessed', None) if assessed_domains is None: assessed_domains = profile_application.get( 'application').get('supplier').get('domains', None).get('assessed', None) profile_application_status = profile_application.get('application').get('status', None) if profile_application.get('application').get('type') == 'edit': profile_application_status = 'approved' except APIError: pass except HTTPError: pass domain_id = None if brief.get('areaOfExpertise'): current_domain = data_api_client.req.domain(brief['areaOfExpertise']).get() domain_id = current_domain['domain']['id'] elif brief['lotSlug'] == 'training': domain_id = 15 # training return render_template_with_csrf( 'brief.html', add_case_study_url=add_case_study_url, application_url=application_url, application_specialist_url=application_specialist_url, application_specialist_submitted_url=application_specialist_submitted_url, application_training_url=application_training_url, assessed_domains=assessed_domains, brief=brief, brief_responses=brief_responses, brief_of_current_user=brief_of_current_user, content=brief_content, domain_id=domain_id, is_restricted_brief=is_restricted_brief, selected_for_brief=selected_for_brief, profile_application_status=profile_application_status, profile_url=profile_url, unassessed_domains=unassessed_domains, supplier_assessments=supplier_assessments, supplier_framework=supplier_framework, unanswered_required=unanswered_required, training_domain_name='Training, Learning and Development' )
def get_brief_by_id(framework_slug, brief_id): briefs = data_api_client.get_brief(brief_id) brief = briefs.get('briefs') if brief['lotSlug'] in ['rfx', 'atm']: return redirect('/2/%s/opportunities/%s' % (framework_slug, brief_id), 301) if brief['status'] not in ['live', 'closed']: if not current_user.is_authenticated or brief['users'][0]['id'] != current_user.id: abort(404, "Opportunity '{}' can not be found".format(brief_id)) if current_user.is_authenticated and current_user.role == 'supplier': brief_responses = data_api_client.find_brief_responses( brief_id, current_user.supplier_code)["briefResponses"] selected_for_brief = _is_supplier_selected_for_brief(brief) else: brief_responses = None selected_for_brief = False brief['clarificationQuestions'] = [ dict(question, number=index+1) for index, question in enumerate(brief['clarificationQuestions']) ] brief_content = content_loader.get_builder(framework_slug, 'display_brief').filter( brief ) sections = brief_content.summary(brief) unanswered_required, unanswered_optional = count_unanswered_questions(sections) brief_of_current_user = False if not current_user.is_anonymous and len(brief.get('users')) > 0: brief_of_current_user = brief['users'][0]['id'] == current_user.id is_restricted_brief = brief.get('sellerSelector', '') in ('someSellers', 'oneSeller') brief_published_date = brief['dates'].get('published_date', None) feature_date = current_app.config['MULTI_CANDIDATE_PUBLISHED_DATE'] published_date = pendulum.parse(brief_published_date) if brief_published_date else feature_date.subtract(days=1) application_url = "/2/brief/{}/respond".format(brief['id']) application_specialist_url = application_url application_specialist_submitted_url = None if published_date >= feature_date: application_specialist_url = "/2/brief/{}/specialist/respond".format(brief['id']) application_specialist_submitted_url = "/2/brief/{}/specialist/respond/submitted".format(brief['id']) application_training_url = "/2/brief/{}/training/respond".format(brief['id']) add_case_study_url = None profile_application_status = None supplier = None unassessed_domains = {} assessed_domains = {} profile_url = None supplier_assessments = {} supplier_framework = None if current_user.is_authenticated: if current_user.supplier_code is not None: supplier = data_api_client.get_supplier( current_user.supplier_code ).get('supplier', None) profile_application_id = current_user.application_id if supplier is not None: profile_url = '/supplier/{}'.format(supplier.get('code')) assessed_domains = supplier.get('domains').get('assessed', None) unassessed_domains = supplier.get('domains').get('unassessed', None) legacy_domains = supplier.get('domains').get('legacy', None) if profile_application_id is None: profile_application_id = supplier.get('application_id', None) supplier_code = supplier.get('code') supplier_assessments = data_api_client.req.assessments().supplier(supplier_code).get() if len(legacy_domains) != 0: for i in range(len(legacy_domains)): supplier_assessments['assessed'].append(legacy_domains[i]) supplier_framework_ids = supplier.get('frameworks') for i in range(len(supplier_framework_ids)): if supplier.get('frameworks')[i].get('framework_id') == 7: supplier_framework = 'digital-marketplace' if supplier_framework is None: supplier_framework = 'digital-service-professionals' if profile_application_id is not None: try: profile_application = data_api_client.req.applications(profile_application_id).get() if unassessed_domains is None: unassessed_domains = profile_application.get( 'application').get('supplier').get('domains', None).get('unassessed', None) if assessed_domains is None: assessed_domains = profile_application.get( 'application').get('supplier').get('domains', None).get('assessed', None) profile_application_status = profile_application.get('application').get('status', None) if profile_application.get('application').get('type') == 'edit': profile_application_status = 'approved' except APIError: pass except HTTPError: pass domain_id = None if brief.get('areaOfExpertise'): current_domain = data_api_client.req.domain(brief['areaOfExpertise']).get() domain_id = current_domain['domain']['id'] elif brief['lotSlug'] == 'training': domain_id = 15 # training return render_template_with_csrf( 'brief.html', add_case_study_url=add_case_study_url, application_url=application_url, application_specialist_url=application_specialist_url, application_specialist_submitted_url=application_specialist_submitted_url, application_training_url=application_training_url, assessed_domains=assessed_domains, brief=brief, brief_responses=brief_responses, brief_of_current_user=brief_of_current_user, content=brief_content, domain_id=domain_id, is_restricted_brief=is_restricted_brief, selected_for_brief=selected_for_brief, profile_application_status=profile_application_status, profile_url=profile_url, unassessed_domains=unassessed_domains, supplier_assessments=supplier_assessments, supplier_framework=supplier_framework, unanswered_required=unanswered_required, training_domain_name='Training, Learning and Development' )
def get_brief_by_id(framework_slug, brief_id): briefs = data_api_client.get_brief(brief_id) brief = briefs.get('briefs') if brief['status'] not in ['live', 'closed']: if not current_user.is_authenticated or brief['users'][0][ 'id'] != current_user.id: abort(404, "Opportunity '{}' can not be found".format(brief_id)) if current_user.is_authenticated and current_user.role == 'supplier': brief_responses = data_api_client.find_brief_responses( brief_id, current_user.supplier_code)["briefResponses"] else: brief_responses = None brief['clarificationQuestions'] = [ dict(question, number=index + 1) for index, question in enumerate(brief['clarificationQuestions']) ] brief_content = content_loader.get_builder(framework_slug, 'display_brief').filter(brief) brief_of_current_user = False if not current_user.is_anonymous and len(brief.get('users')) > 0: brief_of_current_user = brief['users'][0]['id'] == current_user.id is_restricted_brief = brief.get('sellerSelector', '') in ('someSellers', 'oneSeller') application_url = "/sellers/opportunities/{}/responses/create".format( brief['id']) add_case_study_url = None profile_application_status = None supplier = None unassessed_domains = {} assessed_domains = {} profile_url = None supplier_assessments = {} supplier_framework = None if current_user.is_authenticated: if current_user.supplier_code is not None: supplier = data_api_client.get_supplier( current_user.supplier_code).get('supplier', None) profile_application_id = current_user.application_id if supplier is not None: profile_url = '/supplier/{}'.format(supplier.get('code')) assessed_domains = supplier.get('domains').get('assessed', None) unassessed_domains = supplier.get('domains').get( 'unassessed', None) legacy_domains = supplier.get('domains').get('legacy', None) if profile_application_id is None: profile_application_id = supplier.get('application_id', None) supplier_code = supplier.get('code') supplier_assessments = data_api_client.req.assessments().supplier( supplier_code).get() if len(legacy_domains) != 0: for i in range(len(legacy_domains)): supplier_assessments['assessed'].append(legacy_domains[i]) supplier_framework_ids = supplier.get('frameworks') for i in range(len(supplier_framework_ids)): if supplier.get('frameworks')[i].get('framework_id') == 7: supplier_framework = 'digital-marketplace' if supplier_framework is None: supplier_framework = 'digital-service-professionals' if profile_application_id is not None: try: profile_application = data_api_client.req.applications( profile_application_id).get() if unassessed_domains is None: unassessed_domains = profile_application.get( 'application').get('supplier').get( 'domains', None).get('unassessed', None) if assessed_domains is None: assessed_domains = profile_application.get( 'application').get('supplier').get( 'domains', None).get('assessed', None) profile_application_status = profile_application.get( 'application').get('status', None) if profile_application.get('application').get( 'type') == 'edit': profile_application_status = 'approved' except APIError: pass except HTTPError: pass domain_id = None if brief.get('areaOfExpertise'): current_domain = data_api_client.req.domain( brief['areaOfExpertise']).get() domain_id = current_domain['domain']['id'] return render_template_with_csrf( 'brief.html', add_case_study_url=add_case_study_url, application_url=application_url, assessed_domains=assessed_domains, brief=brief, brief_responses=brief_responses, brief_of_current_user=brief_of_current_user, content=brief_content, domain_id=domain_id, is_restricted_brief=is_restricted_brief, profile_application_status=profile_application_status, profile_url=profile_url, show_pdf_link=brief['status'] in ['live', 'closed'], unassessed_domains=unassessed_domains, supplier_assessments=supplier_assessments, supplier_framework=supplier_framework)