Пример #1
0
def get_data(request):
    url = request.GET.get('url')
    try:
        company = str(request.GET.get('company'))
        page = int(request.GET.get('page'))
    except ValueError:
        return HttpResponseBadRequest()
    if not url or not page:
        return HttpResponseBadRequest()
    offset = (page - 1) * PER_PAGE
    limit = PER_PAGE
    if url == 'company':
        comps = Company.objects.filter(name__icontains=company,
                                       is_publicated=True)[offset:offset +
                                                           limit]
        return render(request, 'company-entities.html', {'companies': comps})
    if url == 'salary':
        comps = Company.objects.filter(name__icontains=company,
                                       is_publicated=True)[offset:offset +
                                                           limit]
        avg_salaries = Salary.avg_salaries(comps)
        return render(request, 'salary-entities.html', {
            'companies': comps,
            'q': company,
            'avg_sals': avg_salaries
        })
    if url == 'interview':
        comps = Company.objects.filter(name__icontains=company,
                                       is_publicated=True)[offset:offset +
                                                           limit]
        return render(request, 'interview-entities.html', {'companies': comps})
Пример #2
0
def salaries(request):
    company = request.GET.get('q')
    if company is None:
        company = ''
    comps = Company.objects.filter(name__icontains=company, is_publicated=True)[:PER_PAGE]

    # aggregate salaries by positions
    avg_salaries = Salary.avg_salaries(comps)
    return render(request, 'search-salary.html',
                  {'companies': comps, 'q': company, 'avg_sals': avg_salaries, 'url': 'salary'})
Пример #3
0
def salaries(request):
    company = request.GET.get('q')
    if company is None:
        company = ''
    comps = Company.objects.filter(name__icontains=company,
                                   is_publicated=True)[:PER_PAGE]

    # aggregate salaries by positions
    avg_salaries = Salary.avg_salaries(comps)
    return render(
        request, 'search-salary.html', {
            'companies': comps,
            'q': company,
            'avg_sals': avg_salaries,
            'url': 'salary'
        })
Пример #4
0
def get_data(request):
    url = request.GET.get('url')
    try:
        company = str(request.GET.get('company'))
        page = int(request.GET.get('page'))
    except ValueError:
        return HttpResponseBadRequest()
    if not url or not page:
        return HttpResponseBadRequest()
    offset = (page - 1) * PER_PAGE
    limit = PER_PAGE
    if url == 'company':
        comps = Company.objects.filter(name__icontains=company, is_publicated=True)[offset:offset + limit]
        return render(request, 'company-entities.html', {'companies': comps})
    if url == 'salary':
        comps = Company.objects.filter(name__icontains=company, is_publicated=True)[offset:offset + limit]
        avg_salaries = Salary.avg_salaries(comps)
        return render(request, 'salary-entities.html', {'companies': comps, 'q': company, 'avg_sals': avg_salaries})
    if url == 'interview':
        comps = Company.objects.filter(name__icontains=company, is_publicated=True)[offset:offset + limit]
        return render(request, 'interview-entities.html', {'companies': comps})