Beispiel #1
0
def users(request):
    users = auth.models.User.objects.all()
    users = users.annotate(count=Count("edits"))
    users = users.order_by("-count")

    paginator = DiggPaginator(users, 25, body=8)
    try:
        page = paginator.page(int(request.GET.get("page", 1)))
    except ValueError:
        raise Http404
    except EmptyPage:
        raise Http404
    page = paginator.page(request.GET.get("page", 1))
    return render(request, "users.html", {"paginator": paginator, "page": page})
Beispiel #2
0
def feed(request, tag=None, page=1):
    jobs = models.Job.objects.filter(published__isnull=False, deleted__isnull=True)
    title = "code4lib jobs feed"
    feed_url = "http://" + request.META["HTTP_HOST"] + reverse("feed")
    subject = None
    if tag:
        subject = get_object_or_404(models.Subject, slug=tag)
        jobs = jobs.filter(subjects__in=[subject])
        title = "code4lib jobs feed - %s" % subject.name
        feed_url = "http://" + request.META["HTTP_HOST"] + reverse("feed_tag", args=[tag])

    jobs = jobs.order_by("-published")
    if jobs.count() == 0:
        raise Http404
    updated = jobs[0].updated

    paginator = DiggPaginator(jobs, 50, body=8)
    try:
        page = paginator.page(page)
    except EmptyPage:
        raise Http404

    return render_to_response(
        "feed.xml",
        {"subject": subject, "page": page, "updated": updated},
        mimetype="application/atom+xml",
        context_instance=RequestContext(request),
    )
Beispiel #3
0
def jobs(request, subject_slug=None):
    jobs = models.Job.objects.filter(published__isnull=False, deleted__isnull=True)
    jobs = jobs.order_by("-published")

    # filter by subject if we were given one
    if subject_slug:
        subject = get_object_or_404(models.Subject, slug=subject_slug)
        jobs = jobs.filter(subjects__in=[subject])
        feed_url = "http://" + request.META["HTTP_HOST"] + reverse("feed_tag", args=[subject.slug])
        feed_title = "code4lib jobs feed - %s" % subject.name
    else:
        feed_url = "http://" + request.META["HTTP_HOST"] + reverse("feed")
        feed_title = "code4lib jobs feed"
        subject = None

    paginator = DiggPaginator(jobs, 20, body=8)
    try:
        page = paginator.page(request.GET.get("page", 1))
    except EmptyPage:
        raise Http404

    context = {
        "jobs": page.object_list,
        "page": page,
        "paginator": paginator,
        "subject": subject,
        "feed_url": feed_url,
        "feed_title": feed_title,
    }
    return render(request, "jobs.html", context)
Beispiel #4
0
def tags(request):
    # add a new subject
    if request.method == "POST":
        s, created = models.Subject.objects.get_or_create(name=request.POST.get("subjectName"))
        s.type = request.POST.get("subjectTypeName")
        s.freebase_id = request.POST.get("subjectId")
        s.freebase_type_id = request.POST.get("subjectTypeId")

        kw = models.Keyword.objects.get(id=request.POST.get("keywordId"))
        s.keywords.add(kw)
        s.save()
        return redirect(reverse("subject", args=[s.slug]))

    subjects = models.Subject.objects.filter(jobs__deleted__isnull=True)
    subjects = subjects.annotate(num_jobs=Count("jobs"))
    subjects = subjects.filter(num_jobs__gt=0)
    subjects = subjects.order_by("-num_jobs")
    paginator = DiggPaginator(subjects, 25, body=8)
    try:
        page = paginator.page(int(request.GET.get("page", 1)))
    except ValueError:
        raise Http404
    except EmptyPage:
        raise Http404
    context = {"paginator": paginator, "page": page}
    return render(request, "tags.html", context)
Beispiel #5
0
def employers(request):
    employers = models.Employer.objects.all()
    employers = employers.annotate(num_jobs=Count("jobs"))
    employers = employers.filter(num_jobs__gt=0)
    employers = employers.order_by("-num_jobs")
    paginator = DiggPaginator(employers, 25, body=8)
    page = paginator.page(request.GET.get("page", 1))
    context = {"paginator": paginator, "page": page}
    return render(request, "employers.html", context)
Beispiel #6
0
def matcher(request):
    keywords = models.Keyword.objects.all()
    keywords = keywords.annotate(num_jobs=Count("jobs"))
    keywords = keywords.filter(num_jobs__gt=2, ignore=False, subject__isnull=True)
    keywords = keywords.order_by("-num_jobs")

    paginator = DiggPaginator(keywords, 25, body=8)
    page = paginator.page(request.GET.get("page", 1))
    if request.is_ajax():
        template = "matcher_table.html"
    else:
        template = "matcher.html"
    return render(request, template, {"page": page, "paginator": paginator})
Beispiel #7
0
def employers(request):
    employers = models.Employer.objects.all()
    employers = employers.annotate(num_jobs=Count("jobs"))
    employers = employers.filter(num_jobs__gt=0)
    employers = employers.order_by("-num_jobs")
    paginator = DiggPaginator(employers, 25, body=8)
    try:
        page = paginator.page(int(request.GET.get("page", 1)))
    except ValueError:
        raise Http404
    except EmptyPage:
        raise Http404
    context = {"paginator": paginator, "page": page}
    return render(request, "employers.html", context)
Beispiel #8
0
def feed(request, page=1):
    jobs = models.Job.objects.filter(published__isnull=False, deleted__isnull=True)
    jobs = jobs.order_by("-published")
    updated = jobs[0].updated

    paginator = DiggPaginator(jobs, 25, body=8)
    page = paginator.page(page)

    return render_to_response(
        "feed.xml",
        {"page": page, "updated": updated},
        mimetype="application/atom+xml",
        context_instance=RequestContext(request),
    )
Beispiel #9
0
def jobs(request, subject_slug=None):
    jobs = models.Job.objects.all().order_by("-post_date")

    # filter by subject if we were given one
    if subject_slug:
        subject = get_object_or_404(models.Subject, slug=subject_slug)
        jobs = jobs.filter(subjects__in=[subject])
    else:
        subject = None

    paginator = DiggPaginator(jobs, 20, body=8)
    page = paginator.page(request.GET.get("page", 1))

    context = {"jobs": page.object_list, "page": page, "paginator": paginator, "subject": subject}
    return render(request, "jobs.html", context)
Beispiel #10
0
def jobs(request, subject_slug=None):
    jobs = models.Job.objects.filter(published__isnull=False, deleted__isnull=True)
    jobs = jobs.order_by("-published")

    # filter by subject if we were given one
    if subject_slug:
        subject = get_object_or_404(models.Subject, slug=subject_slug)
        jobs = jobs.filter(subjects__in=[subject])
    else:
        subject = None

    paginator = DiggPaginator(jobs, 20, body=8)
    try:
        page = paginator.page(request.GET.get("page", 1))
    except EmptyPage:
        return HttpResponseNotFound()

    context = {"jobs": page.object_list, "page": page, "paginator": paginator, "subject": subject}
    return render(request, "jobs.html", context)
Beispiel #11
0
def tags(request):
    # add a new subject
    if request.method == "POST":
        s, created = models.Subject.objects.get_or_create(name=request.POST.get("subjectName"))
        s.type = request.POST.get("subjectTypeName")
        s.freebase_id = request.POST.get("subjectId")
        s.freebase_type_id = request.POST.get("subjectTypeId")

        kw = models.Keyword.objects.get(id=request.POST.get("keywordId"))
        s.keywords.add(kw)
        s.save()
        return redirect(reverse("subject", args=[s.slug]))

    subjects = models.Subject.objects.all()
    subjects = subjects.annotate(num_jobs=Count("jobs"))
    subjects = subjects.order_by("-num_jobs")
    paginator = DiggPaginator(subjects, 25, body=8)
    page = paginator.page(request.GET.get("page", 1))
    context = {"paginator": paginator, "page": page}
    return render(request, "tags.html", context)
Beispiel #12
0
def matcher_table(request):
    keywords = _kw()
    paginator = DiggPaginator(keywords, 25, body=8)
    page = paginator.page(request.GET.get("page", 1))
    return render(request, "matcher_table.html", {"page": page})
Beispiel #13
0
def users(request):
    users = auth.models.User.objects.all().order_by("username")
    paginator = DiggPaginator(users, 25, body=8)
    page = paginator.page(request.GET.get("page", 1))
    return render(request, "users.html", {"paginator": paginator, "page": page})