コード例 #1
0
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()
コード例 #2
0
def test_rfx_brief_user_status_non_selected_seller(rfx_brief, supplier_user, case_studies, brief_assessments):
    user_status = BriefUserStatus(rfx_brief, supplier_user)
    assert user_status.is_approved_seller()
    assert not user_status.is_recruiter_only()
    assert user_status.is_assessed_in_any_category()
    assert not user_status.has_chosen_brief_category()
    assert 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()
コード例 #3
0
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_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()
コード例 #4
0
def test_rfx_brief_user_status_non_selected_seller(rfx_brief, supplier_user,
                                                   case_studies,
                                                   brief_assessments):
    user_status = BriefUserStatus(rfx_brief, supplier_user)
    assert user_status.is_approved_seller()
    assert not user_status.is_recruiter_only()
    assert user_status.is_assessed_in_any_category()
    assert not user_status.has_evidence_in_draft_for_category()
    assert 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()
コード例 #5
0
def test_atm_brief_user_status_open_to_category_rejected_domain_seller(atm_brief, supplier_user, supplier_domains,
                                                                       case_studies, brief_assessments):
    atm_brief.publish()
    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 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 user_status.has_been_assessed_for_brief()
    assert not user_status.can_respond()
    assert not user_status.has_responded()
コード例 #6
0
def test_atm_brief_user_status_open_to_category_rejected_domain_seller(
        atm_brief, supplier_user, supplier_domains, case_studies,
        brief_assessments):
    atm_brief.publish()
    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 user_status.has_been_assessed_for_brief()
    assert not user_status.can_respond()
    assert not user_status.has_responded()
コード例 #7
0
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)