Esempio n. 1
0
def get_job_detail_breadbox(request, job_id):
    job = get_job(request, job_id)
    if not job:
        return {}

    site_config = get_site_config(request)

    breadbox = helpers.job_breadcrumbs(job, site_config.browse_company_show)

    query_string = get_query_string(request)
    if query_string:
        # Append the query_path to all of the exising urls
        for field in breadbox:
            path = breadbox[field].get('path', '/jobs/')
            path_and_query_string = "%s?%s" % (path, query_string)
            new_url = (path_and_query_string if query_string
                       else breadbox[field]['path'])
            breadbox[field]['path'] = new_url

        # Create a new path for title and moc query string values
        # from the job information.
        fields = ['title', 'city']
        path = ''
        for field in fields:
            slab = getattr(job, '%s_slab' % field)
            path = "%s%s/" % (path, slab.split("::")[0])
        for field in ['q', 'moc']:
            if request.GET.get(field, None):
                breadbox[field] = {}
                qs = QueryDict(query_string).copy()
                del qs[field]
                breadbox[field]['path'] = "/%s?%s" % (path, qs.urlencode())
                breadbox[field]['display'] = request.GET.get(field)

    return breadbox
Esempio n. 2
0
def get_job_detail_breadbox(request, job_id):
    job = get_job(request, job_id)
    if not job:
        return {}

    site_config = get_site_config(request)

    breadbox = helpers.job_breadcrumbs(job, site_config.browse_company_show)

    query_string = get_query_string(request)
    if query_string:
        # Append the query_path to all of the exising urls
        for field in breadbox:
            path = breadbox[field].get('path', '/jobs/')
            path_and_query_string = "%s?%s" % (path, query_string)
            new_url = (path_and_query_string
                       if query_string else breadbox[field]['path'])
            breadbox[field]['path'] = new_url

        # Create a new path for title and moc query string values
        # from the job information.
        fields = ['title', 'city']
        path = ''
        for field in fields:
            slab = getattr(job, '%s_slab' % field)
            path = "%s%s/" % (path, slab.split("::")[0])
        for field in ['q', 'moc']:
            if request.GET.get(field, None):
                breadbox[field] = {}
                qs = QueryDict(query_string).copy()
                del qs[field]
                breadbox[field]['path'] = "/%s?%s" % (path, qs.urlencode())
                breadbox[field]['display'] = request.GET.get(field)

    return breadbox
Esempio n. 3
0
    def test_breadcrumbs(self):
        job_dict = {'city': 'Indianapolis',
                    'city_slab': 'indianapolis/indiana/usa/jobs::Indianapolis, IN',
                    'country': 'United States',
                    'country_slab': 'usa/jobs::United States',
                    'state': 'Indiana',
                    'state_slab': 'indiana/usa/jobs::Indiana',
                    'title': 'Retail Associate',
                    'title_slab': 'retail-associate/jobs-in::Retail Associate'}

        field_list = " ".join(field for field in job_dict)
        jobTuple = namedtuple('jobTuple', field_list)
        job = jobTuple(*job_dict.values())

        breadcrumbs = helpers.job_breadcrumbs(job)
        city_path = breadcrumbs['city']['path']
        state_path = breadcrumbs['state']['path']
        title_path = breadcrumbs['title']['path']
        country_path = breadcrumbs['country']['path']
        self.assertEqual(city_path,
                         '/retail-associate/jobs-in/indiana/usa/jobs/')
        self.assertEqual(state_path,
                         '/retail-associate/jobs-in/usa/jobs/')
        self.assertEqual(title_path,
                         '/indianapolis/indiana/usa/jobs/')
        self.assertEqual(country_path,
                         '/retail-associate/jobs-in/')
Esempio n. 4
0
    def test_breadcrumbs(self):
        job_dict = {
            'city': 'Indianapolis',
            'city_slab': 'indianapolis/indiana/usa/jobs::Indianapolis, IN',
            'country': 'United States',
            'country_slab': 'usa/jobs::United States',
            'state': 'Indiana',
            'state_slab': 'indiana/usa/jobs::Indiana',
            'title': 'Retail Associate',
            'title_slab': 'retail-associate/jobs-in::Retail Associate'
        }

        field_list = " ".join(field for field in job_dict)
        jobTuple = namedtuple('jobTuple', field_list)
        job = jobTuple(*job_dict.values())

        breadcrumbs = helpers.job_breadcrumbs(job)
        city_path = breadcrumbs['city']['path']
        state_path = breadcrumbs['state']['path']
        title_path = breadcrumbs['title']['path']
        country_path = breadcrumbs['country']['path']
        self.assertEqual(city_path,
                         '/retail-associate/jobs-in/indiana/usa/jobs/')
        self.assertEqual(state_path, '/retail-associate/jobs-in/usa/jobs/')
        self.assertEqual(title_path, '/indianapolis/indiana/usa/jobs/')
        self.assertEqual(country_path, '/retail-associate/jobs-in/')