def test_saved_searches(self):
        # User has no searches at all
        searches = saved_searches(self.staff_user, self.company, self.candidate)
        self.assertFalse(searches)

        # User has searches but none of them belong to the company
        SavedSearchFactory(user=self.candidate,
                           url='http://not-test.jobs/search?q=django',
                           feed='http://not-test.jobs/jobs/feed/rss?',
                           label='test Jobs')
        searches = saved_searches(self.staff_user, self.company, self.candidate)
        self.assertFalse(searches)

        # User has searches that belong to the company
        search1 = 'http://test.jobs/search?q=django'
        search2 = 'http://something.test2.jobs/search?q=python'
        SavedSearchFactory(user=self.candidate,
                           url=search1,
                           feed=search1,
                           label='test Jobs')
        searches = saved_searches(self.staff_user, self.company, self.candidate)
        self.assertEqual(len(searches), 1)
        SavedSearchFactory(user=self.candidate,
                           url=search2,
                           feed=search2,
                           label='test Jobs')
        searches = saved_searches(self.staff_user, self.company, self.candidate)
        self.assertEqual(len(searches), 2)
Example #2
0
def candidate_information(request):
    """
    Sends user info, primary name, and searches to candidate_information.html.
    Gathers the employer's (request.user) companies and microsites and puts
    the microsites' domains in a list for further checking and logic,
    see helpers.py.
    """

    user_id = request.REQUEST.get('user')
    company_id = request.REQUEST.get('company')
    anchor_id = request.REQUEST.get('anchor', False)
    after = request.REQUEST.get('after', False)
    before = request.REQUEST.get('before', False)
    candidates_page = request.REQUEST.get('page', False)

    # user gets pulled out from id
    try:
        user = User.objects.get(id=user_id)
        company = Company.objects.get(id=company_id)
    except User.DoesNotExist or Company.DoesNotExist:
        raise Http404

    if not user.opt_in_employers:
        raise Http404

    urls = saved_searches(request.user, company, user)

    if not urls:
        raise Http404

    manager = PrimaryNameProfileUnitManager(
        order=['employmenthistory', 'education', 'militaryservice'])
    models = manager.displayed_units(user.profileunits_set.all())

    primary_name = getattr(manager, 'primary_name', 'Name not given')

    if request.REQUEST.get('url'):
        microsite_url = request.REQUEST.get('url')
        coming_from = {'path': 'microsite', 'url': microsite_url}
    else:
        coming_from = {'path': 'view'}

    searches = user.savedsearch_set.filter(url__in=urls)

    data_dict = {
        'user_info': models,
        'company_id': company_id,
        'primary_name': primary_name,
        'the_user': user,
        'searches': searches,
        'after': after,
        'anchor': anchor_id,
        'before': before,
        'candidates_page': candidates_page,
        'coming_from': coming_from
    }

    return render_to_response('mydashboard/candidate_information.html',
                              data_dict, RequestContext(request))
Example #3
0
def candidate_information(request):
    """
    Sends user info, primary name, and searches to candidate_information.html.
    Gathers the employer's (request.user) companies and microsites and puts
    the microsites' domains in a list for further checking and logic,
    see helpers.py.

    """
    user_id = get_int_or_none(request.REQUEST.get('user'))
    company = get_company(request)

    if not user_id or not company:
        raise Http404

    # user gets pulled out from id
    try:
        candidate = User.objects.get(id=user_id)
    except User.DoesNotExist:
        raise Http404

    if not candidate.opt_in_employers:
        raise Http404

    urls = saved_searches(request.user, company, candidate)
    actions = analytics(request.user, company, candidate)
    actions = get_analytics_counts(actions)

    if not urls and not actions:
        raise Http404

    manager = PrimaryNameProfileUnitManager(order=['employmenthistory',
                                                   'education',
                                                   'militaryservice'])
    models = manager.displayed_units(candidate.profileunits_set.all())

    primary_name = getattr(manager, 'primary_name', 'Name not given')

    coming_from = {'path': 'view'}

    searches = candidate.savedsearch_set.all()
    searches = [search for search in searches
                if get_domain(search.feed).lower() in urls]

    modified_url = remove_param_from_url(request.build_absolute_uri(), 'user')
    query_string = "?%s" % urlparse(modified_url).query

    data_dict = {
        'user_info': models,
        'company_id': company.pk,
        'primary_name': primary_name,
        'the_user': candidate,
        'searches': searches,
        'coming_from': coming_from,
        'query_string': query_string,
        'actions': actions,
    }

    return render_to_response('mydashboard/candidate_information.html',
                              data_dict, RequestContext(request))
Example #4
0
def candidate_information(request):
    """
    Sends user info, primary name, and searches to candidate_information.html.
    Gathers the employer's (request.user) companies and microsites and puts
    the microsites' domains in a list for further checking and logic,
    see helpers.py.
    """

    user_id = request.REQUEST.get('user')
    company_id = request.REQUEST.get('company')
    anchor_id = request.REQUEST.get('anchor', False)
    after = request.REQUEST.get('after', False)
    before = request.REQUEST.get('before', False)    
    candidates_page = request.REQUEST.get('page', False)
    
    # user gets pulled out from id
    try:
        user = User.objects.get(id=user_id)
        company = Company.objects.get(id=company_id)
    except User.DoesNotExist or Company.DoesNotExist:
        raise Http404

    if not user.opt_in_employers:
        raise Http404

    urls = saved_searches(request.user, company, user)

    if not urls:
        raise Http404

    manager = PrimaryNameProfileUnitManager(order=['employmenthistory',
                                                   'education',
                                                   'militaryservice'])
    models = manager.displayed_units(user.profileunits_set.all())

    primary_name = getattr(manager, 'primary_name', 'Name not given')

    if request.REQUEST.get('url'):
        microsite_url = request.REQUEST.get('url')
        coming_from = {'path': 'microsite', 'url': microsite_url}
    else:
        coming_from = {'path': 'view'}

    searches = user.savedsearch_set.filter(url__in=urls)

    data_dict = {'user_info': models,
                 'company_id': company_id,
                 'primary_name': primary_name,
                 'the_user': user,
                 'searches': searches,
                 'after': after,
                 'anchor': anchor_id,
                 'before': before,                 
                 'candidates_page': candidates_page,
                 'coming_from': coming_from}

    return render_to_response('mydashboard/candidate_information.html',
                              data_dict, RequestContext(request))
Example #5
0
def candidate_information(request):
    """
    Sends user info, primary name, and searches to candidate_information.html.
    Gathers the employer's (request.user) companies and microsites and puts
    the microsites' domains in a list for further checking and logic,
    see helpers.py.
    """

    user_id = request.REQUEST.get("user")
    company_id = request.REQUEST.get("company")
    anchor_id = request.REQUEST.get("anchor", False)
    after = request.REQUEST.get("after", False)
    before = request.REQUEST.get("before", False)
    candidates_page = request.REQUEST.get("page", False)

    # user gets pulled out from id
    try:
        user = User.objects.get(id=user_id)
        company = Company.objects.get(id=company_id)
    except User.DoesNotExist or Company.DoesNotExist:
        raise Http404

    if not user.opt_in_employers:
        raise Http404

    urls = saved_searches(request.user, company, user)

    if not urls:
        raise Http404

    manager = PrimaryNameProfileUnitManager(order=["employmenthistory", "education", "militaryservice"])
    models = manager.displayed_units(user.profileunits_set.all())

    primary_name = getattr(manager, "primary_name", "Name not given")

    if request.REQUEST.get("url"):
        microsite_url = request.REQUEST.get("url")
        coming_from = {"path": "microsite", "url": microsite_url}
    else:
        coming_from = {"path": "view"}

    searches = user.savedsearch_set.filter(url__in=urls)

    data_dict = {
        "user_info": models,
        "company_id": company_id,
        "primary_name": primary_name,
        "the_user": user,
        "searches": searches,
        "after": after,
        "anchor": anchor_id,
        "before": before,
        "candidates_page": candidates_page,
        "coming_from": coming_from,
    }

    return render_to_response("mydashboard/candidate_information.html", data_dict, RequestContext(request))