Пример #1
0
 def post(self, request):
     if request.method == "POST":
         form = CompanyForm(request.POST)
         print(form.is_valid(), form.errors)
         if form.is_valid():
             form = form.save(commit=False)
             form.owner = request.user
             form.logo = 'https://place-hold.it/130x80'
             form.save()
             return redirect('/mycompany/', pk=form.pk)
     else:
         form = CompanyForm()
     return render(request, 'company_create.html', {'form': form})
Пример #2
0
def post_company(request):
    if request.method == 'POST':
        formset = CompanyForm(request.POST, user=request.user)
        if formset.is_valid():
            formset.save(commit=False)
            formset.pub_date = datetime.datetime.now
            formset.save()
            return HttpResponseRedirect('/')
    else:
        formset = CompanyForm(user=request.user)

    variables = RequestContext(request, {
        'formset': formset,
            })
    return render_to_response("jobs/post_company.html", variables)
Пример #3
0
def post(request):
    job_posted = False
    company = request.user.companies.first()
    if request.method == 'POST':
        company_form = CompanyForm(request.POST, instance=company)
        job_form = JobForm(request.POST)
        if company_form.is_valid() and job_form.is_valid():
            company = company_form.save(commit=False)
            company.user = request.user
            company.save()
            job = job_form.save(commit=False)
            job.user = request.user
            job.company = company
            job.save()
            job_posted = True
    else:
        company_form = CompanyForm(instance=company)
        job_form = JobForm()

    if job_posted:
        notify_slack("New job posting: {}".format(job.title),
                     settings.SLACK_BOARD_CHANNEL)

    context = dict(job_posted=job_posted,
                   company_form=company_form,
                   job_form=job_form)
    return render(request, 'jobs/post.html', context)
Пример #4
0
    def post(self, request):
        current_user = request.user
        company = Company.objects.get(owner=current_user)

        form = CompanyForm(request.POST, instance=company)

        if form.is_valid():
            form = form.save(commit=False)
            form.owner = current_user
            form.save()
            return redirect('/mycompany/')
        else:
            form = CompanyForm(instance=company)

        return render(request,
                      'company_edit.html',
                      context={
                          'form': form,
                          'company': company
                      })
Пример #5
0
def create_company(request):
    if request.POST:
        form = CompanyForm(request.POST, request.FILES)
        if form.is_valid():
            article = form.save(commit=False)
            article.author = request.user
            article.save()
            return redirect(article)
    else:
        form = CompanyForm()

    return render_to_response('jobs/create-company.html', RequestContext(request, {
        'active_tab': 'jobs',
        'subtitle': 'Create company',
        'form': form,
    }))