コード例 #1
0
ファイル: views.py プロジェクト: yo-bj/shortimer
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))
コード例 #2
0
ファイル: views.py プロジェクト: mjgiarlo/shortimer
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')
    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))
コード例 #3
0
ファイル: views.py プロジェクト: anarchivist/shortimer
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)
コード例 #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)
コード例 #5
0
ファイル: views.py プロジェクト: yo-bj/shortimer
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)
コード例 #6
0
ファイル: views.py プロジェクト: thatandromeda/shortimer
def feed(request, tag=None, page=1):
    jobs_list = models.Job.objects.filter(published__isnull=False,
                                          deleted__isnull=True)
    subject = None
    if tag:
        subject = get_object_or_404(models.Subject, slug=tag)
        jobs_list = jobs_list.filter(subjects__in=[subject])

    jobs_list = jobs_list.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))
コード例 #7
0
ファイル: views.py プロジェクト: bibliotechy/shortimer
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)
コード例 #8
0
ファイル: views.py プロジェクト: mjgiarlo/shortimer
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)
    page = paginator.page(request.GET.get("page", 1))
    context = {
        "paginator": paginator,
        "page": page
        }
    return render(request, "tags.html", context)
コード例 #9
0
ファイル: views.py プロジェクト: mjgiarlo/shortimer
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)
コード例 #10
0
ファイル: views.py プロジェクト: anarchivist/shortimer
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
    })
コード例 #11
0
ファイル: views.py プロジェクト: todrobbins/shortimer
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)
    page = paginator.page(request.GET.get("page", 1))
    return render(request, "users.html", 
            {"paginator": paginator, "page": page})
コード例 #12
0
ファイル: views.py プロジェクト: bibliotechy/shortimer
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)
コード例 #13
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)
    page = paginator.page(request.GET.get("page", 1))
    return render(request, "users.html", {
        "paginator": paginator,
        "page": page
    })
コード例 #14
0
ファイル: views.py プロジェクト: anarchivist/shortimer
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))
コード例 #15
0
ファイル: views.py プロジェクト: anarchivist/shortimer
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)
コード例 #16
0
ファイル: views.py プロジェクト: mjgiarlo/shortimer
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})
コード例 #17
0
ファイル: views.py プロジェクト: anarchivist/shortimer
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})
コード例 #18
0
ファイル: views.py プロジェクト: code4lib/shortimer
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})
コード例 #19
0
ファイル: views.py プロジェクト: tfmorris/shortimer
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)
コード例 #20
0
ファイル: views.py プロジェクト: anarchivist/shortimer
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))
コード例 #21
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
    })
コード例 #22
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)
コード例 #23
0
ファイル: views.py プロジェクト: code4lib/shortimer
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)
コード例 #24
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)
コード例 #25
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)
コード例 #26
0
ファイル: views.py プロジェクト: anarchivist/shortimer
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)
コード例 #27
0
ファイル: views.py プロジェクト: mjgiarlo/shortimer
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})
コード例 #28
0
ファイル: views.py プロジェクト: mjgiarlo/shortimer
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})
コード例 #29
0
ファイル: views.py プロジェクト: anarchivist/shortimer
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})