Exemple #1
0
    def post(self, request):
        form = CompanyForm(request.POST)
        company = request.user.mycompany.first()
        if form.is_valid():
            data = form.cleaned_data
            company.name = data['name']
            company.location = data['location']
            company.logo = data['logo']
            company.description = data['description']
            company.employee_count = data['employee_count']
            company.save()

            return redirect('/mycompany/')
        return render(request, 'company_new_create.html', {'form': form})
Exemple #2
0
 def post(self, request):
     company_form = CompanyForm(request.POST, request.FILES)
     if company_form.is_valid():
         Company.objects.create(
             name=company_form.cleaned_data['name'],
             location=company_form.cleaned_data['location'],
             logo=company_form.cleaned_data['logo'],
             description=company_form.cleaned_data['description'],
             employee_count=company_form.cleaned_data['employee_count'],
             owner=request.user,
         )
         messages.success(request, 'success')
         return redirect('company')
     else:
         raise Http404
Exemple #3
0
 def post(self, request):
     company = Company.objects.get(owner=request.user)
     company_form = CompanyForm(request.POST, request.FILES)
     if company_form.is_valid():
         changed_data = company_form.cleaned_data
         company.name = changed_data['name']
         company.location = changed_data['location']
         company.logo = changed_data['logo'] if changed_data['logo'] is not None else company.logo
         company.description = changed_data['description']
         company.employee_count = changed_data['employee_count']
         company.save()
         messages.success(request, 'success')
         return HttpResponseRedirect(request.path_info)
     else:
         raise Http404
Exemple #4
0
 def post(self, request):
     form = CompanyForm(request.POST)
     if form.is_valid():
         data = form.cleaned_data
         user = request.user
         company = Company.objects.create(
             name=data['name'],
             location=data['location'],
             logo=data['logo'],
             description=data['description'],
             employee_count=data['employee_count'],
             owner=user,
         )
         return redirect('/mycompany/')
     return render(request, 'company_new_create.html', {'form': form})
Exemple #5
0
 def get(self, request):
     if Company.objects.filter(owner=request.user):
         return redirect('company')
     else:
         company_form = CompanyForm()
         context = {'company_form': company_form}
         return render(request, 'jobs/employer/company-edit.html', context)
Exemple #6
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,
    }))
Exemple #7
0
def edit_company(request, object_id):
    entry = get_object_or_404(Company,pk=object_id)
    if request.user.id != entry.author.id:
        return HttpResponseForbidden('<strong>Access Forbidden. You do not have permission to access this page. </strong>') #    if request.method == 'POST':
    if request.method == 'POST':
        formset = CompanyForm(instance=entry, data=request.POST, user=request.user)
        if formset.is_valid():
            entry.pk = object_id
            entry.save()
            return HttpResponseRedirect(reverse('job_company_detail', kwargs = {'slug':entry.slug, 'object_id':entry.id,}))
    else:      
        formset = CompanyForm(instance=entry, user=request.user)
        
    variables = RequestContext(request, {
        'formset': formset,
        'object_id': object_id,
            })

    return render_to_response("jobs/edit_company.html", variables)
 def get(self, request):
     try:
         company = Company.objects.get(owner=request.user)
         form = CompanyForm(instance=company)
         return render(request,
                       'company_edit.html',
                       context={
                           'company': company,
                           'form': form
                       })
     except Company.DoesNotExist:
         return render(request, 'company_not_found.html', context={})
Exemple #9
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)
Exemple #10
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)
Exemple #11
0
 def get(self, request):
     try:
         company = Company.objects.get(owner=request.user)
     except Company.DoesNotExist:
         return render(request, 'jobs/employer/company-create.html')
     else:
         company_form = CompanyForm()
         company_form['name'].initial = company.name
         company_form['location'].initial = company.location
         company_form['logo'].initial = company.logo
         company_form['description'].initial = company.description
         company_form['employee_count'].initial = company.employee_count
         context = {'company': company, 'company_form': company_form}
         return render(request, 'jobs/employer/company-edit.html', context)
    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
                      })
Exemple #13
0
 def get(self, request):
     company = request.user.mycompany.all()
     no_company = 0
     user = request.user
     if len(company) == no_company:
         return redirect(reverse('letsstart'))
     else:
         form = CompanyForm(
             initial={
                 'name': request.user.mycompany.first().name,
                 'location': request.user.mycompany.first().location,
                 'logo': request.user.mycompany.first().logo,
                 'description': request.user.mycompany.first().description,
                 'employee_count':
                 request.user.mycompany.first().employee_count,
                 'owner': user,
             })
         context = {
             'form': form,
         }
     return render(request, 'company-edit.html', context=context)
 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})
    def get(self, request):

        form = CompanyForm()

        return render(request, 'company_create.html', context={'form': form})