HR维护候选人信息,面试官录入面试反馈
候选人的信息和面试反馈的信息前期可以放到一张表中
在django框架中,我们可以不用编写任何页面,只需要把模型类创建出来,然后在admin.py里对模型类字段进行分组即可实现后台的增删改!
1创建应用:
D:\PycharmProjects\meetingroom>python manage.py startapp interview
2添加应用:
INSTALLED_APPS = [
'jobs',
'interview',
]
3编写模型类(interview/models.py)
from django.db import models
#第一轮面试结果
FIRST_INTERVIEW_RESULT_TYPE = ((u'建议复试',u'建议复试'),(u'待定',u'待定'),(u'放弃',u'放弃'))
#复试面试建议
INTERVIEW_RESULT_TYPE = ((u'建议录用',u'建议录用'),(u'待定',u'待定'),(u'放弃',u'放弃'))
#候选人学历
DEGREE_TYPE = ((u'专科',u'专科'),(u'本科',u'本科'),(u'硕士',u'硕士'),(u'博士',u'博士'))
#HR终面结论
HR_SCORE_TYPE = (('S','S'),('A','A'),('B','B'),('C','C'))
class Candidate(models.Model):
#基础信息
userid = models.IntegerField(unique=True,blank=True,null=True,verbose_name= u'应聘者id')
username = models.CharField(max_length=135,verbose_name= u'姓名')
city = models.CharField(max_length=135,verbose_name=u'城市')
phone = models.CharField(max_length=11,verbose_name=u'手机号')
email = models.EmailField(max_length=135,blank=True,verbose_name=u'邮箱')
apply_position = models.CharField(max_length=135,blank=True,verbose_name=u'应聘职位')
born_address = models.CharField(max_length=135,blank=True,verbose_name=u'生源地')
gender = models.CharField(max_length=135,blank=True,verbose_name=u'性别')
candidate_remark = models.CharField(max_length=135,blank=True,verbose_name=u'候选人信息备注')
#学校与学历信息
collage_school = models.CharField(max_length=135,blank=True,verbose_name=u'专科生学校')
bachelor_school = models.CharField(max_length=135, blank=True, verbose_name=u'本科生学校')
bmaster_school = models.CharField(max_length=135, blank=True, verbose_name=u'硕士生学校')
doctor_school = models.CharField(max_length=135, blank=True, verbose_name=u'博士生学校')
major = models.CharField(max_length=135,blank=True,verbose_name=u'专业')
degree = models.CharField(max_length=135,choices=DEGREE_TYPE,blank=True,verbose_name=u'学历')
#综合能力评测成绩,笔试测评成绩
test_score_of_general_ability = models.DecimalField(decimal_places=1,max_digits=3,null=True,blank=True,verbose_name=u'综合能力评测成绩')
paper_score = models.DecimalField(decimal_places=1,max_digits=3,null=True,blank=True,verbose_name=u'笔试成绩')
#第一轮面试
first_score = models.DecimalField(decimal_places=1, max_digits=2,null=True,blank=True,verbose_name=u'初试分')
first_learning_ability = models.DecimalField(decimal_places=1,max_digits=2,null=True,blank=True,verbose_name=u'学习能力得分')
first_professional_competency = models.DecimalField(decimal_places=1,max_digits=2,null=True,blank=True,verbose_name=u'专业能力得分')
first_advantage = models.TextField(max_length=1024,blank=True,verbose_name=u'优势')
first_disadvantage = models.TextField(max_length=1024,blank=True,verbose_name=u'顾虑和不足')
first_result = models.CharField(max_length=256,choices=FIRST_INTERVIEW_RESULT_TYPE, blank=True, verbose_name=u'初试结果')
first_recomment_position = models.CharField(max_length=256, blank=True,verbose_name=u'推荐部门')
first_interviewer = models.CharField(max_length=256, blank=True,verbose_name=u'面试官')
first_remark = models.CharField(max_length=125,blank=True,verbose_name=u'初试备注')
# 第二轮面试
second_score = models.DecimalField(decimal_places=1, max_digits=2, null=True, blank=True, verbose_name=u'专业复试得分')
second_learning_ability = models.DecimalField(decimal_places=1, max_digits=2, null=True, blank=True,
verbose_name=u'学习能力得分')
second_professional_competency = models.DecimalField(decimal_places=1, max_digits=2, null=True, blank=True,
verbose_name=u'专业能力得分')
second_pursue_of_excellence = models.DecimalField(decimal_places=1, max_digits=2, null=True, blank=True,
verbose_name=u'追求卓越得分')
second_communication_ability = models.DecimalField(decimal_places=1, max_digits=2, null=True, blank=True,
verbose_name=u'沟通能力得分')
second_pressure_score = models.DecimalField(decimal_places=1, max_digits=2, null=True, blank=True,
verbose_name=u'抗压能力得分')
second_advantage = models.TextField(max_length=1024, blank=True, verbose_name=u'优势')
sccond_disadvantage = models.TextField(max_length=1024, blank=True, verbose_name=u'顾虑和不足')
second_result = models.CharField(max_length=256, choices=INTERVIEW_RESULT_TYPE, blank=True,
verbose_name=u'专业初试结果')
second_recomment_position = models.CharField(max_length=256, blank=True, verbose_name=u'建议方向或推荐部门')
second_interviewer = models.CharField(max_length=256, blank=True, verbose_name=u'面试官')
second_remark = models.CharField(max_length=125, blank=True, verbose_name=u'专业复试备注')
#HR终面
hr_score= models.CharField(max_length=10,choices=HR_SCORE_TYPE,blank=True,verbose_name=u'HR复试综合等级')
hr_responsibility = models.CharField(max_length=10,choices=HR_SCORE_TYPE,blank=True,verbose_name=u'HR责任心')
hr_communication_ability = models.CharField(max_length=10,choices=HR_SCORE_TYPE,blank=True,verbose_name=u'HR坦诚沟通')
hr_logic_ability = models.CharField(max_length=10,choices=HR_SCORE_TYPE,blank=True,verbose_name=u'HR逻辑思维')
hr_potential = models.CharField(max_length=10,choices=HR_SCORE_TYPE,blank=True,verbose_name=u'HR发展潜力')
hr_stability = models.CharField(max_length=10,choices=HR_SCORE_TYPE,blank=True,verbose_name=u'HR稳定性')
hr_advantage = models.CharField(max_length=1024,blank=True,verbose_name=u'优势')
hr_disadvantage = models.TextField(max_length=1024,blank=True,verbose_name=u'顾虑和不足')
hr_result = models.CharField(max_length=256,choices=INTERVIEW_RESULT_TYPE,blank=True,verbose_name=u'HR复试结果')
hr_interviewer = models.CharField(max_length=256,blank=True,verbose_name=u'HR面试官')
hr_remark = models.CharField(max_length=256,blank=True,verbose_name=u'HR复试备注')
ceator = models.CharField(max_length=256,blank=True,verbose_name=u'候选人数据的创建人')
created_date = models.DateTimeField(auto_now_add=True,verbose_name=u'创建时间')
modified_date = models.DateTimeField(auto_now=True,null=True,blank=True,verbose_name=u'更新时间')
last_editor = models.CharField(max_length=256,blank=True,verbose_name=u'最后编辑者')
class Meta:
db_table = u'candidate'
verbose_name = u'应聘者'
verbose_name_plural = u'应聘者'
#此方法可以将对象转换成字符串(候选人的名字作为对象的展现名字)
def __str__(self):
return
4注册模型类(interview/admin.py)
from interview.models import Candidate
admin.site.register(Candidate)
5同步数据表:
D:\PycharmProjects\meetingroom>python manage.py makemigrations
D:\PycharmProjects\meetingroom>python manage.py migrate
6进入后台添加一条应聘者信息(发现表太长了,需要进行分组展示优化)
http://127.0.0.1:8000/admin
7优化:
1)先在admin.py中定义出我们都要展示哪些字段:
from interview.models import Candidate
class CandidateAdmin(admin.ModelAdmin):
#不展示的字段
exclude = ('creator','created_date','modified_date')
list_display = (
"username","city","bachelor_school","first_score","first_result","first_interviewer",
"second_result","second_interviewer","hr_score","hr_result","last_editor"
)
admin.site.register(Candidate,CandidateAdmin)
2)在admin.py中对模型类里的字段进行分组展示:
第一组:#基础信息 #学校与学历信息 #综合能力平级 #创建者信息
第二组:#第一轮面试
第三组:#第二轮面试
第三组:HR终面
#对模型类字段进行分组:
fieldsets = (
(None,{'fields':()}),
('第一轮面试记录',{'fields':()}),
('第二轮面试记录',{'fields':()}),
('第三轮面试记录',{'fields':()}),
)
from django.contrib import admin
from interview.models import Candidate
# Register your models here.
class CandidateAdmin(admin.ModelAdmin):
#不展示的字段
exclude = ('creator','created_date','modified_date')
list_display = (
"username","city","bachelor_school","first_score","first_result","first_interviewer",
"second_result","second_interviewer","hr_score","hr_result","last_editor"
)
#对模型类字段进行分组(注意在exclude中被隐藏的字段不要在这里显示,否则报错):
fieldsets = (
(None,{'fields':("userid", "username", "city", "phone", "email", "apply_position", "born_address", "gender", "candidate_remark", "collage_school", "bachelor_school", "bmaster_school", "doctor_school", "major", "degree","last_editor", "test_score_of_general_ability", "paper_score")}),
('第一轮面试记录',{'fields':("first_score", "first_learning_ability", "first_professional_competency", "first_advantage", "first_disadvantage", "first_result", "first_recomment_position", "first_interviewer", "first_remark")}),
('第二轮专业复试记录',{'fields':("second_score", "second_learning_ability", "second_professional_competency", "second_pursue_of_excellence", "second_communication_ability", "second_pressure_score", "second_advantage", "sccond_disadvantage", "second_result", "second_recomment_position", "second_interviewer", "second_remark")}),
('HR复试记录',{'fields':("hr_score", "hr_responsibility", "hr_communication_ability", "hr_logic_ability", "hr_potential", "hr_stability", "hr_advantage", "hr_disadvantage", "hr_result", "hr_interviewer", "hr_remark")}),
)
admin.site.register(Candidate,CandidateAdmin)
3)把几个字段合并成一行展示:
在admin.py中将上一步中需要合并在一行的字段用括号括起来即可实现并行
fieldsets = (
(None,{'fields':("userid", ("username", "gender","collage_school" ), ("phone", "apply_position", "bachelor_school"), ("email", "candidate_remark", "bmaster_school"), ("city","born_address" , "doctor_school"), ("major", "degree"), ("test_score_of_general_ability", "paper_score","last_editor"))}),
('第一轮面试记录',{'fields':("first_score", "first_learning_ability", "first_professional_competency", "first_advantage", "first_disadvantage", "first_result", "first_recomment_position", "first_interviewer", "first_remark")}),
('第二轮专业复试记录',{'fields':(("second_score", "second_learning_ability", "second_professional_competency"), ("second_pursue_of_excellence", "second_communication_ability", "second_pressure_score"), ("second_advantage", "sccond_disadvantage"), "second_result", ("second_recomment_position", "second_interviewer", "second_remark"))}),
('HR复试记录',{'fields':(("hr_score", "hr_responsibility", "hr_communication_ability"), ("hr_logic_ability", "hr_potential", "hr_stability"), ("hr_advantage","hr_result"), "hr_interviewer", "hr_remark", "hr_disadvantage",)}),
)