def test_can_respond_to_open_to_selected_specialist_as_invited_recruiter( specialist_brief, supplier_user, supplier_domains): supplier_user.supplier.data['recruiter'] = 'yes' user_status = BriefUserStatus(specialist_brief, supplier_user) result = user_status.can_respond_to_specialist_opportunity() assert result is True
def test_can_not_respond_to_open_to_selected_specialist_as_unassessed_seller( specialist_brief, recruiter, supplier_user): supplier_user.supplier.data['recruiter'] = recruiter user_status = BriefUserStatus(specialist_brief, supplier_user) result = user_status.can_respond_to_specialist_opportunity() assert result is False
def test_can_not_respond_to_open_to_category_atm_as_unassessed_seller( atm_brief, recruiter, supplier_user): supplier_user.supplier.data['recruiter'] = recruiter user_status = BriefUserStatus(atm_brief, supplier_user) result = user_status.can_respond_to_atm_opportunity() assert result is False
def test_can_not_respond_to_rfx_as_unassessed_seller(rfx_brief, recruiter, supplier_user): supplier_user.supplier.data['recruiter'] = recruiter user_status = BriefUserStatus(rfx_brief, supplier_user) result = user_status.can_respond_to_rfx_or_training_opportunity() assert result is False
def test_can_not_respond_to_open_to_all_atm_as_recruiter( atm_brief, supplier_user): supplier_user.supplier.data['recruiter'] = 'yes' user_status = BriefUserStatus(atm_brief, supplier_user) result = user_status.can_respond_to_atm_opportunity() assert result is False
def test_can_respond_to_open_to_all_atm_as_assessed_seller( atm_brief, recruiter, supplier_user, supplier_domains): supplier_user.supplier.data['recruiter'] = recruiter user_status = BriefUserStatus(atm_brief, supplier_user) result = user_status.can_respond_to_atm_opportunity() assert result is True
def test_atm_brief_user_status_as_applicant(atm_brief, applicant_user, supplier_domains, case_studies, brief_assessments): user_status = BriefUserStatus(atm_brief, applicant_user) assert not user_status.is_approved_seller() assert not user_status.is_recruiter_only() assert not user_status.is_assessed_in_any_category() assert not user_status.has_evidence_in_draft_for_category() assert not user_status.is_assessed_for_category() assert not user_status.is_awaiting_domain_assessment() assert not user_status.is_awaiting_application_assessment() assert not user_status.has_been_assessed_for_brief() assert not user_status.can_respond() assert not user_status.has_responded()
def test_atm_brief_user_status_open_to_all_unassessed_seller( atm_brief, supplier_user): user_status = BriefUserStatus(atm_brief, supplier_user) assert user_status.is_approved_seller() assert not user_status.is_recruiter_only() assert not user_status.is_assessed_in_any_category() assert not user_status.has_evidence_in_draft_for_category() assert not user_status.is_assessed_for_category() assert not user_status.is_awaiting_domain_assessment() assert not user_status.is_awaiting_application_assessment() assert not user_status.has_been_assessed_for_brief() assert not user_status.can_respond() assert not user_status.has_responded()
def test_atm_brief_user_status_as_applicant(atm_brief, applicant_user, supplier_domains, case_studies, brief_assessments): user_status = BriefUserStatus(atm_brief, applicant_user) assert not user_status.is_approved_seller() assert not user_status.is_recruiter_only() assert not user_status.is_assessed_in_any_category() assert not user_status.has_chosen_brief_category() assert not user_status.is_assessed_for_category() assert not user_status.is_awaiting_domain_assessment() assert not user_status.is_awaiting_application_assessment() assert not user_status.has_been_assessed_for_brief() assert not user_status.can_respond() assert not user_status.has_responded()
def test_atm_brief_user_status_open_to_category_unassessed_seller(atm_brief, supplier_user): user_status = BriefUserStatus(atm_brief, supplier_user) assert user_status.is_approved_seller() assert not user_status.is_recruiter_only() assert not user_status.is_assessed_in_any_category() assert not user_status.has_chosen_brief_category() assert not user_status.is_assessed_for_category() assert not user_status.is_awaiting_domain_assessment() assert not user_status.is_awaiting_application_assessment() assert not user_status.has_been_assessed_for_brief() assert not user_status.can_respond() assert not user_status.has_responded()
def get_brief(brief_id): """Get brief --- tags: - brief parameters: - name: brief_id in: path type: number required: true responses: 200: description: Brief retrieved successfully. schema: type: object properties: brief: type: object brief_response_count: type: number invited_seller_count: type: number can_respond: type: boolean open_to_all: type: boolean is_brief_owner: type: boolean is_buyer: type: boolean has_responded: type: boolean has_chosen_brief_category: type: boolean is_assessed_for_category: type: boolean is_assessed_in_any_category: type: boolean is_approved_seller: type: boolean is_awaiting_application_assessment: type: boolean is_awaiting_domain_assessment: type: boolean has_been_assessed_for_brief: type: boolean open_to_category: type: boolean is_applicant: type: boolean is_recruiter: type: boolean domains: type: array items: type: object 403: description: Unauthorised to view brief. 404: description: Brief not found. 500: description: Unexpected error. """ brief = briefs.find(id=brief_id).one_or_none() if not brief: not_found("No brief for id '%s' found" % (brief_id)) user_role = current_user.role if hasattr(current_user, 'role') else None invited_sellers = brief.data['sellers'] if 'sellers' in brief.data else {} is_buyer = False is_brief_owner = False brief_user_ids = [user.id for user in brief.users] if user_role == 'buyer': is_buyer = True if current_user.id in brief_user_ids: is_brief_owner = True if brief.status == 'draft' and not is_brief_owner: return forbidden("Unauthorised to view brief") brief_response_count = len(brief_responses_service.get_brief_responses(brief_id, None)) invited_seller_count = len(invited_sellers) open_to_all = brief.lot.slug == 'atm' and brief.data.get('openTo', '') == 'all' open_to_category = brief.lot.slug == 'atm' and brief.data.get('openTo', '') == 'category' is_applicant = user_role == 'applicant' # gather facts about the user's status against this brief user_status = BriefUserStatus(brief, current_user) has_chosen_brief_category = user_status.has_chosen_brief_category() is_assessed_for_category = user_status.is_assessed_for_category() is_assessed_in_any_category = user_status.is_assessed_in_any_category() is_awaiting_application_assessment = user_status.is_awaiting_application_assessment() is_awaiting_domain_assessment = user_status.is_awaiting_domain_assessment() has_been_assessed_for_brief = user_status.has_been_assessed_for_brief() is_recruiter_only = user_status.is_recruiter_only() is_approved_seller = user_status.is_approved_seller() can_respond = user_status.can_respond() has_responded = user_status.has_responded() # remove private data for non brief owners brief.data['contactEmail'] = '' brief.data['users'] = None if not is_buyer: if 'sellers' in brief.data: brief.data['sellers'] = {} brief.responses_zip_filesize = None brief.data['contactNumber'] = '' if not can_respond: brief.data['proposalType'] = [] brief.data['evaluationType'] = [] brief.data['responseTemplate'] = [] brief.data['requirementsDocument'] = [] brief.data['industryBriefing'] = '' brief.data['backgroundInformation'] = '' brief.data['outcome'] = '' brief.data['endUsers'] = '' brief.data['workAlreadyDone'] = '' brief.data['timeframeConstraints'] = '' brief.data['attachments'] = [] else: brief.data['contactEmail'] = [user.email_address for user in brief.users][0] if not is_brief_owner: if 'sellers' in brief.data: brief.data['sellers'] = {} brief.data['industryBriefing'] = '' brief.data['contactNumber'] = '' domains = [] for domain in domain_service.all(): domains.append({ 'id': str(domain.id), 'name': domain.name }) return jsonify(brief=brief.serialize(with_users=False, with_author=is_brief_owner), brief_response_count=brief_response_count, invited_seller_count=invited_seller_count, can_respond=can_respond, has_chosen_brief_category=has_chosen_brief_category, is_assessed_for_category=is_assessed_for_category, is_assessed_in_any_category=is_assessed_in_any_category, is_approved_seller=is_approved_seller, is_awaiting_application_assessment=is_awaiting_application_assessment, is_awaiting_domain_assessment=is_awaiting_domain_assessment, has_been_assessed_for_brief=has_been_assessed_for_brief, open_to_all=open_to_all, open_to_category=open_to_category, is_brief_owner=is_brief_owner, is_buyer=is_buyer, is_applicant=is_applicant, is_recruiter_only=is_recruiter_only, has_responded=has_responded, domains=domains)