Exemple #1
0
    def fetch(self, url):
        feed = feedparser.parse(url)
        for entry in feed.entries:
            title = entry.title
            description = entry.summary.replace("\n", " ")
            description = re.sub(r"[ \t]+", " ", description)
            url = entry.link

            if Job.objects.filter(origin_url=url).count() != 0:
                continue
            job = Job(title=title, description=description, origin_url=url, url=url)
            job.save()
            autotag(job)
            log.info("added job for review: %s" % job)
Exemple #2
0
    def fetch(self, url):
        feed = feedparser.parse(url)
        print
        print url
        for entry in feed.entries:
            title = entry.title
            print title
            description = entry.summary.replace("\n", " ")
            description = re.sub(r"[ \t]+", " ", description)
            url = entry.link

            if Job.objects.filter(origin_url=url).count() != 0:
                continue
            job = Job(title=title, description=description, origin_url=url, url=url)
            job.save()
            autotag(job)
            log.info("added job for review: %s" % job)
Exemple #3
0
def job_edit(request, id=None):
    if id:
        j = get_object_or_404(models.Job, id=id)
    else:
        j = models.Job(creator=request.user)

    can_edit_description = _can_edit_description(request.user, j)

    if request.method == "GET":
        context = {
            "job": j,
            "curate_next": request.path == "/curate/employers/",
            "can_edit_description": can_edit_description,
            "error": request.session.pop("error", None),
            "job_types": models.JOB_TYPES,
            "google_api_key": settings.GOOGLE_API_KEY
        }
        return render(request, "job_edit.html", context)

    form = request.POST
    if form.get("action") == "view" and j.id:
        return redirect(reverse('job', args=[j.id]))

    _update_job(j, form, request.user)

    if form.get("action") == "autotag":
        autotag(j)

    if form.get("action") == "delete" and not j.published:
        j.deleted = datetime.datetime.now()
        j.save()

    if form.get("action") == "publish":
        publishable, msg = j.publishable()
        if not publishable:
            request.session['error'] = 'Cannot publish yet: %s' % msg
        else:
            j.publish(request.user)

    if request.path.startswith("/curate/"):
        return redirect(request.path)

    if j and not j.deleted:
        return redirect(reverse('job_edit', args=[j.id]))

    return redirect("/")  # job was deleted
Exemple #4
0
def job_edit(request, id=None):
    if id:
        j = get_object_or_404(models.Job, id=id)
    else:
        j = models.Job(creator=request.user)

    can_edit_description = _can_edit_description(request.user, j)

    if request.method == "GET":
        context = {
            "job": j,
            "curate_next": request.path == "/curate/employers/",
            "can_edit_description": can_edit_description,
            "error": request.session.pop("error", None),
            "job_types": models.JOB_TYPES,
            "google_api_key": settings.GOOGLE_API_KEY,
        }
        return render(request, "job_edit.html", context)

    form = request.POST
    if form.get("action") == "view" and j.id:
        return redirect(reverse("job", args=[j.id]))

    _update_job(j, form, request.user)

    if form.get("action") == "autotag":
        autotag(j)

    if form.get("action") == "delete" and not j.published:
        j.deleted = datetime.datetime.now()
        j.save()

    if form.get("action") == "publish":
        publishable, msg = j.publishable()
        if not publishable:
            request.session["error"] = "Cannot publish yet: %s" % msg
        else:
            j.publish(request.user)

    if request.path.startswith("/curate/"):
        return redirect(request.path)

    if j and not j.deleted:
        return redirect(reverse("job_edit", args=[j.id]))

    return redirect("/")  # job was deleted