Ejemplo n.º 1
0
def index(request):
    paginator = Paginator(Job.get_publicly_available_jobs(), 5)
    page = request.GET.get('page')
    try:
        public_jobs_to_display = paginator.page(page)
    except:
        public_jobs_to_display = paginator.page(1)

    context_dict = {
        "publicly_available_jobs": public_jobs_to_display,
        "premium_available_jobs": Job.get_premium_jobs(),
        "new_job_form": JobForm,
        "pages": paginator.page_range
    }
    return render(request, template_name="index.html", context=context_dict)
Ejemplo n.º 2
0
def index(request):
    search = request.GET.get('search', '')
    # Just to avoid search for less then 3 letters
    search = search if len(search) > 3 else None
    # Passing the value to Paginator
    paginator = Paginator(Job.get_publicly_available_jobs(search), 5)

    page = request.GET.get('page')
    try:
        public_jobs_to_display = paginator.page(page)
    except:
        public_jobs_to_display = paginator.page(1)

    context_dict = {
        "publicly_available_jobs": public_jobs_to_display,
        "premium_available_jobs": Job.get_premium_jobs(),
        "new_job_form": JobForm,
        "pages": paginator.page_range,
        "search": search if search is not None else ''
    }
    return render(request, template_name="index.html", context=context_dict)
Ejemplo n.º 3
0
 def test_premium_available(self):
     self.assertTrue((self.job in Job.get_premium_jobs()))