Пример #1
0
def addjob(request):
    board = request.board
    job_static_form = JobStaticForm(board = board, prefix="job_static_form")
    job_contact_form = JobContactForm(prefix="job_contact_form")
    JobForm = get_job_form(board = request.board)
    form = JobForm(prefix="form")
    if request.method == "POST":
        form = JobForm(data = request.POST, files = request.FILES, prefix = "form")
        job_static_form = JobStaticForm(board = request.board, data = request.POST, prefix = "job_static_form")
        job_contact_form = JobContactForm(data = request.POST, prefix = "job_contact_form")
        if form.is_valid() and job_static_form.is_valid() and job_contact_form.is_valid():
            job = job_static_form.save()
            Form = get_job_form(request.board, job = job, captcha_required=False)
            form = Form(data = request.POST, files = request.FILES,  prefix = "form")
            assert form.is_valid()
            form.save()
            contact = job_contact_form.save(commit = False)
            contact.job = job
            contact.board = request.board
            contact.save()
            #request.user.message_set.create(message="The job has been added.")
            #The job has been added. It is inactive yet. Ask user to pay via Paypal if needed.
            if not board.cost_per_job_listing:
                #There is no charge for adding Jobs to this board.
                job.is_active = True
                job.save()
                return HttpResponseRedirect(reverse("frontend_job", args=[job.job_slug]))
            else:
                return HttpResponseRedirect(reverse("frontend_job_paypal", args=[job.pk]))

    pages = board.page_set.all()
    payload = {"job_static_form": job_static_form, "job_contact_form": job_contact_form, "job_form": form, "pages": pages}
    return render_to_response("frontend/addjob.html", payload, RequestContext(request))
Пример #2
0
def add_job(request):

    "Add a job, via the backend."

    job_static_form = JobStaticForm(board = request.board, prefix = "job_static_form")

    job_contact_form = JobContactForm(prefix = "job_contact_form")

    Form = get_job_form(request.board, captcha_required=False)

    form = Form( prefix = "form")

    if request.method == 'POST':

        form = Form(data = request.POST, files = request.FILES, prefix = "form")

        job_static_form = JobStaticForm(board = request.board, data = request.POST, prefix = "job_static_form")

        job_contact_form = JobContactForm(data = request.POST, prefix = "job_contact_form")

        if form.is_valid() and job_static_form.is_valid() and job_contact_form.is_valid():

            job = job_static_form.save()

            Form = get_job_form(request.board, job=job, captcha_required=False)

            form = Form(data = request.POST, files = request.FILES, prefix = "form")

            assert form.is_valid()

            form.save()

            contact = job_contact_form.save(commit = False)

            contact.job = job

            contact.board = request.board

            contact.save()

            # since the job is added from admin, marking it as 

            # active by default

            job.is_active = True
            job.save()
            request.user.message_set.create(message="The job has been added.")

            return HttpResponseRedirect(reverse('zobpress_index'))

    payload = {'form':form, 'job_static_form': job_static_form, "job_contact_form": job_contact_form}

    return render_to_response('zobpress/addjob.html', payload, RequestContext(request))