Ejemplo n.º 1
0
def add(request):
    #########################################################################################
    # 用户操作行为安全保护

    # 计时器
    timer = time.time() - request.session.get('time_stamp', 0)

    # 危险操作次数
    action_times = request.session.get('action_times', 0)

    # 错误次数是否大于最大
    if action_times >= 1:
        if not check_verify(request):
            return render('verify.html',
                          locals(),
                          context_instance=RequestContext(request))
        else:

            # 重置标志位
            reset(request)
    #########################################################################################
    current_page = 'jobs'

    # 检查用户选择的城市是否存在
    if check_city(request.GET.get('city_name', False)):
        request.session['job_city'] = request.GET.get('city_name')
    else:
        return index(request=request)

    # 打印表单
    if request.method == 'GET':
        form = JobForm()
        return render('jobs_add.html',
                      locals(),
                      context_instance=RequestContext(request))

    # 处理提交数据
    form = JobForm(request.POST)
    if form.is_valid():
        data = form.cleaned_data
        new_job = Job()
        new_job.title = data['title']
        new_job.city = request.session.get('job_city', '北京')
        new_job.company = data['company']
        new_job.website = data['website']
        new_job.email = data['email']
        new_job.content = data['content']
        try:
            new_job.save()
        except Exception, e:
            return HttpResponse('保存招聘信息时出现错误:' + str(e))
        else:
            set(request)
            msg = '提交成功,正在等待管理员审核...'
            # 发送信号
            new_job_was_post.send(sender=new_job.__class__, job=new_job)
        return render('posted.html',
                      locals(),
                      context_instance=RequestContext(request))
Ejemplo n.º 2
0
def add(request):
    #########################################################################################
    # 用户操作行为安全保护

    # 计时器
    timer = time.time() - request.session.get('time_stamp',0)

    # 危险操作次数
    action_times = request.session.get('action_times',0)

    # 错误次数是否大于最大
    if action_times >= 1:
        if not check_verify(request):
            return render('verify.html',locals(),context_instance=RequestContext(request))
        else:

            # 重置标志位
            reset(request)
    #########################################################################################
    current_page = 'jobs'

    # 检查用户选择的城市是否存在
    if check_city(request.GET.get('city_name',False)):
        request.session['job_city'] = request.GET.get('city_name')
    else:
        return index(request=request)

    # 打印表单
    if request.method == 'GET':
        form = JobForm()
        return render('jobs_add.html',locals(),context_instance=RequestContext(request))

    # 处理提交数据
    form = JobForm(request.POST)
    if form.is_valid():
        data = form.cleaned_data
        new_job = Job()
        new_job.title = data['title']
        new_job.city = request.session.get('job_city','北京')
        new_job.company = data['company']
        new_job.website = data['website']
        new_job.email = data['email']
        new_job.content = data['content']
        try:
            new_job.save()
        except Exception,e:
            return HttpResponse('保存招聘信息时出现错误:'+str(e))
        else:
            set(request)
            msg = '提交成功,正在等待管理员审核...'
            # 发送信号
            new_job_was_post.send(
                sender = new_job.__class__,
                job = new_job
            )
        return render('posted.html',locals(),context_instance=RequestContext(request))
Ejemplo n.º 3
0
def add(request):
    current_page = 'jobs'
    page_title = u'发布招聘信息'

    # 检查用户选择的城市是否存在
    if check_city(request.GET.get('city_name', False)):
        request.session['job_city'] = request.GET.get('city_name')
    else:
        return index(request=request)

    # 打印表单
    if request.method == 'GET':
        form = JobForm()
        return render('jobs_add.html',
                      locals(),
                      context_instance=RequestContext(request))

    # 处理提交数据
    form = JobForm(request.POST)
    if form.is_valid():
        data = form.cleaned_data
        new_job = Job()
        new_job.title = data['title']
        new_job.city = request.session.get('job_city', '北京')
        new_job.company = data['company']
        new_job.website = data['website']
        new_job.email = data['email']
        new_job.content = data['content']
        try:
            new_job.save()
        except Exception, e:
            return HttpResponse('保存招聘信息时出现错误:' + str(e))
        else:
            msg = '提交成功,正在等待管理员审核...'
            # 发送信号
            new_job_was_post.send(sender=new_job.__class__, job=new_job)
        return render('posted.html',
                      locals(),
                      context_instance=RequestContext(request))
Ejemplo n.º 4
0
def add(request):
    current_page = 'jobs'
    page_title   = u'发布招聘信息'

    # 检查用户选择的城市是否存在
    if check_city(request.GET.get('city_name',False)):
        request.session['job_city'] = request.GET.get('city_name')
    else:
        return index(request=request)

    # 打印表单
    if request.method == 'GET':
        form = JobForm()
        return render('jobs_add.html',locals(),context_instance=RequestContext(request))

    # 处理提交数据
    form = JobForm(request.POST)
    if form.is_valid():
        data = form.cleaned_data
        new_job = Job()
        new_job.title = data['title']
        new_job.city = request.session.get('job_city','北京')
        new_job.company = data['company']
        new_job.website = data['website']
        new_job.email = data['email']
        new_job.content = data['content']
        try:
            new_job.save()
        except Exception,e:
            return HttpResponse('保存招聘信息时出现错误:'+str(e))
        else:
            msg = '提交成功,正在等待管理员审核...'
            # 发送信号
            new_job_was_post.send(
                sender = new_job.__class__,
                job = new_job
            )
        return render('posted.html',locals(),context_instance=RequestContext(request))