コード例 #1
0
def postAJob(request):
    mlogger.debug("posting a job.......................")    
    if request.method == "GET":
        form  = JobForm(user=request.user)        
        return render_to_response('jobs/postjob.html',{'form':form},RequestContext(request))
    elif request.method =="POST":
        form =  JobForm(request.POST,user=request.user)
        if form.is_valid() :
            j=form.save(commit=False)                        
            j.postedby = request.user
            j.institute = request.institute
            j.save()
            
            if j.sendemail is not None :
                emaillist = j.sendemail.getEmailList(request.institute)
                fullurl = j.getfullurl(request.institute)
                deliverEmail('new_job_subject.html','new_job_message.html',{'institute':request.institute,'job':j,'fullurl':fullurl},emaillist)
                
            #Assign tags to jobs    
            j.tags = form.cleaned_data['tags']
            assignUserTagWeights(j.tags,request.user,settings.CONTRIBUTION_WEIGHT)          
            create_message(request,"Successfuly posted your job")
            return HttpResponseRedirect(reverse('displayjoburl'))            
        else:
           return render_to_response('jobs/postjob.html',{'form':form},RequestContext(request))
コード例 #2
0
def editJob(request,jobid):
    jobid = int(jobid)
    job = Job.objects.get(pk=jobid)
    originaltags = job.tags
    if request.user.id == job.postedby.id :
        if request.method == "GET" :
            mlogger.debug("the person who posted the job is editing")
            form = JobForm(instance=job,initial={'tags':' '.join(job.tags.values_list('name',flat=True))},user=request.user)            
            return render_to_response('jobs/postjob.html',{'form':form,'editmode':True},RequestContext(request))
        elif request.method == "POST":            
            form = JobForm(request.POST, instance=job,user=request.user)
            if form.is_valid() :
                newjob = form.save(commit=False)
                newjob.save()
                removeUserTagWeights(originaltags,request.user,settings.CONTRIBUTION_WEIGHT)                
                newjob.tags = form.cleaned_data['tags']
                #what about tags brother                  
                assignUserTagWeights(newjob.tags,request.user,settings.CONTRIBUTION_WEIGHT)                            
                create_message(request,"Successfuly edited your job")
                return HttpResponseRedirect(reverse('displayjoburl'))
            else:
                return render_to_response('jobs/postjob.html',{'form':form,'editmode':True},RequestContext(request))
    else :
        create_message(request,"You are not authorized to edit this job")
        return HttpResponseRedirect(reverse('viewjoburl',kwargs={'jobid':job.id}))
コード例 #3
0
def update_job(request, pk):
    job = get_object_or_404(Job, pk=pk)
    form = JobForm(request.POST or None, instance=job)
    if form.is_valid():
        form.save()
        return redirect('index')
    return render(request, 'job_form.html', {'form': form})
コード例 #4
0
 def test_job_form_is_invalid(self):
     self.form_data = {
         'employer': self.emp_pk,
         'title': 'title',
         'description': 'job_desc',
         'minimum_price': 1,
         'skills_required': self.skills
     }
     form = JobForm(data=self.form_data)
     self.assertFalse(form.is_valid())
コード例 #5
0
ファイル: views.py プロジェクト: maxnik/jobsforhackers
def create(request):
    if request.method == 'POST':
        form = JobForm(request.POST)
        if form.is_valid():
            job = Job(**form.cleaned_data)
            if users.is_current_user_admin():
                job.publish()
            job.put()
            return HttpResponseRedirect('/jobs/my')
    else:
        form = JobForm()
    return _custom_render_to_response('job_form.html', {'form': form, 'title': 'Add new job'})
コード例 #6
0
ファイル: views.py プロジェクト: ha-D/SharifJobPortal
def newJob(request):
    show_extra = False
    if request.method == "POST":
        form = JobForm(request.POST)
        if form.is_valid():
            job = form.save(False)
            job.user = request.userprofile
            job.save()
            show_extra = True
            return template(request, 'userpanel/employer/editJob.html', {'form' : form, 'show_extra': True, 'scroll_to_extra': True})
    else:
        form = JobForm()
    return template(request, 'userpanel/employer/editJob.html', {'form' : form, 'show_extra':show_extra})
コード例 #7
0
ファイル: views.py プロジェクト: ha-D/SharifJobPortal
def editJob(request, jobid):
    job = JobOpportunity.objects.get(id = jobid)
    show_extra = False
    if request.method == "POST":
        form = JobForm(request.POST, instance=job)
        if form.is_valid():
            form.save()
            show_extra = True
            return userpanel_jobs(request)
    else:
        show_extra = True
        form = JobForm(instance = job)
    return template(request, 'userpanel/employer/editJob.html', {'form' : form, 'show_extra': show_extra})
コード例 #8
0
ファイル: views.py プロジェクト: agiliq/django-jobs
def edit_job_done(request, id):
    job = models.Job.objects.get(id = id)
    if not job.is_editable:
        raise Http404    
    if request.method == 'POST':
        form = JobForm(request.POST, instance = job)
        if form.is_valid():
            job = form.save()
            return HttpResponseRedirect(job.get_absolute_url())
    elif request.method == 'GET':
        job = models.Job.objects.get(id = id)
        form = JobForm(instance = job)
    payload = {'form': form}
    return render_to_response('jobs/editjob.html', payload, RequestContext(request))
コード例 #9
0
ファイル: views.py プロジェクト: Dikutal/Dikutal
def create(request):
    if request.POST:
        form = JobForm(request.POST, request.FILES)
        if form.is_valid():
            article = form.save(commit=False)
            article.author = request.user
            article.save()
            article.published = article.created
            article.save()
            return redirect(article)
    else:
        form = JobForm()

    return render_to_response('jobs/create.html', RequestContext(request, {
        'form': form,
        'active_tab': 'jobs',
        'subtitle': 'Create job'
    }))
コード例 #10
0
ファイル: views.py プロジェクト: SteveStrop/djangoJob
def job_form(request, pk):
    """
    View for displaying a JobDetailView for editing will become the default and maybe make JobDetailView
    redundant
    """
    job = get_object_or_404(Job, pk=pk)
    # If this is a POST request then process the Form data
    if request.method == 'POST':

        # Create a form instance and populate it with data from the request (binding):
        form = JobForm(request.POST)

        # Check if the form is valid:
        if form.is_valid():
            # process the data in form.cleaned_data as required (here we just write it to the model appointment field)
            job.appointment = form.cleaned_data['appointment']
            job.floorplan = form.cleaned_data['floorplan']
            job.photos = form.cleaned_data['photos']
            job.ref = form.cleaned_data['ref']
            job.save()

            # redirect to a new URL:
            return HttpResponseRedirect(reverse('index'))

    # If this is a GET (or any other method) create the default form using field from forms.JobForm
    else:
        appointment = job.appointment
        floorplan = job.floorplan
        photos = job.photos
        ref = job.ref
        form = JobForm(
            initial={
                'ref': ref,
                'appointment': appointment,
                'floorplan': floorplan,
                'photos': photos
            })

    context = {
        'form': form,
        'job': job,
    }

    return render(request, 'jobs/job_form.html', context)
コード例 #11
0
 def save_job(self):
     form = JobForm({
         "title": self.title,
         "task": self.task,
         "place_of_work": self.place_of_work,
         "min_salary": self.min_salary,
         "max_salary": self.max_salary,
         "requirements": self.requirements,
         "working_hours": self.working_hours,
         "other": self.other,
         "url": self.url,
         }
     )
     # itt megtortenik a validation is, mert meg nem volt is_valid() hivas
     job = form.save(commit=False)
     job.job_type = JobType.objects.get_or_create(name = self.job_type)[0]
     job.job_provider = JobProvider.objects.get_or_create(
             name = self.provider_name
     )[0]
     job.save()
コード例 #12
0
ファイル: views.py プロジェクト: 20flint12/P_gBlog
def create_job(request):
    job_form = JobForm()
    success_message = 'Your job opportunity was added to our database, \
                    you will receive further information shortly.'
    if request.method == 'POST':
        job_form = JobForm(request.POST)
        if job_form.is_valid():
            new_job = job_form.save()
            messages.add_message(
                request,
                messages.INFO,
                success_message
            )
            subject = '{0} was submitted succesfully.'.format(new_job.title)
            context = Context({'option': new_job.title})
            message_plain = get_template(
            'jobs/email_templates/community_confirm.txt').render(context)
            message_html = get_template(
                'jobs/email_templates/community_confirm.html').render(context)
            recipient = new_job.contact_email
            send_job_mail(
                subject,
                message_plain,
                message_html,
                recipient
            )
            return redirect('jobs:confirm_submission')
    return TemplateResponse(
        request,
        'jobs/job_edit.html',
        {
            'form': job_form,
        }
    )
コード例 #13
0
ファイル: views.py プロジェクト: ramavadakattu/Groupalumini
def postAJob(request):
    mlogger.debug("posting a job.......................")
    if request.method == "GET":
        form = JobForm(user=request.user)
        return render_to_response('jobs/postjob.html', {'form': form},
                                  RequestContext(request))
    elif request.method == "POST":
        form = JobForm(request.POST, user=request.user)
        if form.is_valid():
            j = form.save(commit=False)
            j.postedby = request.user
            j.institute = request.institute
            j.save()

            if j.sendemail is not None:
                emaillist = j.sendemail.getEmailList(request.institute)
                fullurl = j.getfullurl(request.institute)
                deliverEmail('new_job_subject.html', 'new_job_message.html', {
                    'institute': request.institute,
                    'job': j,
                    'fullurl': fullurl
                }, emaillist)

            #Assign tags to jobs
            j.tags = form.cleaned_data['tags']
            assignUserTagWeights(j.tags, request.user,
                                 settings.CONTRIBUTION_WEIGHT)
            create_message(request, "Successfuly posted your job")
            return HttpResponseRedirect(reverse('displayjoburl'))
        else:
            return render_to_response('jobs/postjob.html', {'form': form},
                                      RequestContext(request))
コード例 #14
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)
コード例 #15
0
def create_job(request):
    if request.method == 'POST':
        form = JobForm(request.POST, request.FILES)
        if form.is_valid():
            c = form.save(commit=False)
            c.creator = request.user.employer
            c.save()
            return redirect('employers:employer-jobs', request.user.employer.slug)
    else:
        form = JobForm()
    return render(request, 'jobs/form.html', {'form': form})
コード例 #16
0
def edit_job_done(request, id):
    job = models.Job.objects.get(id=id)
    if not job.is_editable:
        raise Http404
    if request.method == 'POST':
        form = JobForm(request.POST, instance=job)
        if form.is_valid():
            job = form.save()
            return HttpResponseRedirect(job.get_absolute_url())
    elif request.method == 'GET':
        job = models.Job.objects.get(id=id)
        form = JobForm(instance=job)
    payload = {'form': form}
    return render_to_response('jobs/editjob.html', payload,
                              RequestContext(request))
コード例 #17
0
ファイル: views.py プロジェクト: ramavadakattu/Groupalumini
def editJob(request, jobid):
    jobid = int(jobid)
    job = Job.objects.get(pk=jobid)
    originaltags = job.tags
    if request.user.id == job.postedby.id:
        if request.method == "GET":
            mlogger.debug("the person who posted the job is editing")
            form = JobForm(instance=job,
                           initial={
                               'tags':
                               ' '.join(job.tags.values_list('name',
                                                             flat=True))
                           },
                           user=request.user)
            return render_to_response('jobs/postjob.html', {
                'form': form,
                'editmode': True
            }, RequestContext(request))
        elif request.method == "POST":
            form = JobForm(request.POST, instance=job, user=request.user)
            if form.is_valid():
                newjob = form.save(commit=False)
                newjob.save()
                removeUserTagWeights(originaltags, request.user,
                                     settings.CONTRIBUTION_WEIGHT)
                newjob.tags = form.cleaned_data['tags']
                #what about tags brother
                assignUserTagWeights(newjob.tags, request.user,
                                     settings.CONTRIBUTION_WEIGHT)
                create_message(request, "Successfuly edited your job")
                return HttpResponseRedirect(reverse('displayjoburl'))
            else:
                return render_to_response('jobs/postjob.html', {
                    'form': form,
                    'editmode': True
                }, RequestContext(request))
    else:
        create_message(request, "You are not authorized to edit this job")
        return HttpResponseRedirect(
            reverse('viewjoburl', kwargs={'jobid': job.id}))
コード例 #18
0
def add_job(request):
    form = JobForm(request.POST or None)
    if form.is_valid():
        form.save()
        return redirect('index')
    return render(request, 'job_form.html', {'form': form})
コード例 #19
0
 def test_job_form_valid_function(self):
     form = JobForm(data=self.form_data)
     url = JobFormView.form_valid(JobFormView(), form).url + '/'
     self.assertEqual(reverse('jobs:employer-job-list'), url)
コード例 #20
0
 def test_job_form_is_valid(self):
     form = JobForm(data=self.form_data)
     self.assertTrue(form.is_valid())