예제 #1
0
파일: views.py 프로젝트: TheTypoMaster/monk
def add_case(request):
    emp = employee.get_employee_by_user(userid=request.user.id)
    InterviewFormSet = modelformset_factory(
        Interview,
        form=utils.gen_class_with_kwargs(InterviewForm, eid=emp.id),
        extra=MAX_NUM_INTERVIEW)
    if request.method == 'POST':
        form = ApplicationCaseForm(request.POST)
        if form.is_valid():
            try:
                form = form.save()
                iforms = InterviewFormSet(request.POST)
                cnt = 0
                for iform in iforms:
                    iform.data['form-%d-case' % (cnt,)] = form.id
                    cnt += 1
                if iforms.is_valid():
                    iforms = iforms.save()
                    return render(
                        request,
                        'case_detail.html',
                        {'case': form, 'interviews': iforms})
            except Exception as ex:
                print ex
    else:
        form = ApplicationCaseForm()
        iforms = InterviewFormSet(queryset=Interview.objects.none())
    return render(
        request,
        'add_case.html',
        {'eid': emp.id, 'form': form, 'iforms': iforms})
예제 #2
0
파일: views.py 프로젝트: TheTypoMaster/monk
def add_candidates(request):
    eid = employee.get_employee_by_user(request.user.id).id
    if request.method == 'POST':
        form = ApplicantForm(request.POST, request.FILES)
        if form.is_valid():
            try:
                candi = form.save()
                return render(request, 'candidate_detail.html', {'candi': candi})
            except Exception as ex:
                print ex
    else:
        form = ApplicantForm()

    return render(request, 'add_candidates.html', {'form': form, 'eid': eid})
예제 #3
0
파일: views.py 프로젝트: TheTypoMaster/monk
def add_jobs(request):
    emp = employee.get_employee_by_user(userid=request.user.id)
    if request.method == 'POST':
        form = JobForm(request.POST, cid=emp.company.id)
        if form.is_valid():
            try:
                job = form.save()
                return render(request, 'job_detail.html', {'job': job})
            except Exception as ex:
                print ex
    else:
        form = JobForm(cid=emp.company.id)
    return render(
        request,
        'add_job.html',
        {'form': form, 'cid': emp.company.id, 'eid': emp.id})
예제 #4
0
파일: views.py 프로젝트: TheTypoMaster/monk
def list_candidates(request):
    """functions for rendering candidate pages"""
    candidates = []
    try:
        emp = employee.get_employee_by_user(request.user.id)
        for c in applicant.get_applicants_by_creator(employee_id=emp.id):
            candi = model_to_dict(c)
            if not candi['photo']:
                candi['photo'] = 'avartars/avartar_default.jpg'
            candidates.append(candi)
    except Exception as ex:
        print ex
        pass
    return render_to_response(
            'list_candidates.html',
            {'candidates': candidates},
            context_instance=RequestContext(request))
예제 #5
0
파일: views.py 프로젝트: TheTypoMaster/monk
def add_interviewers(request):
    emp = employee.get_employee_by_user(userid=request.user.id)
    if request.method == 'POST':
        form = EmployeeForm(request.POST)
        if form.is_valid():
            try:
                interviewer = form.save()
                return render(
                    request,
                    'interviewer_detail.html',
                    {'interviewer': interviewer})
            except Exception as ex:
                print ex
    else:
        form = EmployeeForm()
    return render(
        request,
        'add_interviewer.html',
        {'form': form, 'cid': emp.company.id})