def profile(request): session = request.session role_id = int(session['role_id']) ent_id = int(session['user_id']) context = {} menu = daoapp.getMenu(role_id=role_id) username = daoapp.getUsername(role_id, ent_id) profile = daoapp.getProfile(role_id=role_id, user_id=ent_id) context = profile.copy() context['menu'] = menu context['username'] = username context['role_name'] = 'enterprise' if request.method == 'GET': return render(request, 'practice/profileenterprise.html', context) elif request.method == 'POST': password = request.POST['password'] enterprise = Enterprise.objects.get(ent_id=ent_id) ent_pwd = enterprise.ent_pwd # 判断是否有权限修改,(密码是否正确) if password != ent_pwd: context['error_message'] = '密码错误' return render(request, 'practice/profileenterprise.html', context) enterprise.ent_name = request.POST['ent_name'] enterprise.introduction = request.POST['introduction'] enterprise.ent_address = request.POST['address'] enterprise.ent_phone = request.POST['phone'] enterprise.ent_email = request.POST['email'] enterprise.principal = request.POST['principal'] enterprise.save() return redirect('practice.enterprise:index')
def profile(request): session = request.session role_id = int(session['role_id']) tea_id = int(session['user_id']) context = {} menu = daoapp.getMenu(role_id=role_id) username = daoapp.getUsername(role_id, tea_id) profile = daoapp.getProfile(role_id=role_id, user_id=tea_id) context = profile.copy() context['menu'] = menu context['username'] = username if request.method == 'GET': return render(request, 'practice/profileteacher.html', context) elif request.method == 'POST': password = request.POST['password'] teacher = Teacher.objects.get(tea_id=tea_id) tea_pwd = teacher.tea_pwd # 判断是否有权限修改,(密码是否正确) if password != tea_pwd: context['error_message'] = '密码错误' return render(request, 'practice/profileteacher.html', context) teacher.tea_phone = request.POST['phone'] teacher.tea_email = request.POST['email'] teacher.college = request.POST['college'] teacher.tea_post = request.POST['post'] teacher.save() return redirect('practice.teacher:index')
def informationstudent(request, stu_id): session = request.session role_id = int(session['role_id']) tea_id = int(session['user_id']) menu = daoapp.getMenu(role_id=role_id) username = daoapp.getUsername(role_id, tea_id) information = daoapp.getInformations(role_id=4, user_id=stu_id) # 企业的详细信息 return render(request, 'practice/index.html', {'menu': menu, 'information': information, 'username': username, 'role_name': 'teacher'})
def newreport(request): session = request.session role_id = int(session['role_id']) stu_id = int(session['user_id']) context = {} context['menu'] = daoapp.getMenu(role_id=role_id) context['username'] = daoapp.getUsername(role_id, stu_id) context['role_name'] = 'student' return render(request, 'practice/newreport.html', context)
def applied(request): session = request.session role_id = int(session['role_id']) stu_id = int(session['user_id']) context = {} context['menu'] = daoapp.getMenu(role_id=role_id) context['username'] = daoapp.getUsername(role_id, stu_id) choices = Choice.objects.filter(stu_id=stu_id) context['choices'] = choices context['role_name'] = 'student' return render(request, 'practice/applied.html', context)
def browsejobs(request): session = request.session role_id = int(session['role_id']) tea_id = int(session['user_id']) context = {} context['menu'] = daoapp.getMenu(role_id=role_id) context['username'] = daoapp.getUsername(role_id, tea_id) jobs = Job.objects.all() context['jobs'] = jobs context['role_name'] = 'teacher' return render(request, 'practice/browsejobs.html', context)
def index(request): session = request.session if 'role_id' in session.keys() and 'user_id' in session.keys(): role_id = int(session['role_id']) tea_id = int(session['user_id']) menu = daoapp.getMenu(role_id=role_id) informations = daoapp.getInformations(role_id=role_id, user_id=tea_id) username = daoapp.getUsername(role_id, tea_id) return render(request, 'practice/index.html', {'menu': menu, 'information': informations, 'username': username, 'role_name': 'teacher'}) else: return redirect(reverse('practice:login'))
def profile(request): session = request.session role_id = int(session['role_id']) stu_id = int(session['user_id']) context = {} menu = daoapp.getMenu(role_id=role_id) username = daoapp.getUsername(role_id, stu_id) profile = daoapp.getProfile(role_id=role_id, user_id=stu_id) context = profile.copy() context['menu'] = menu context['username'] = username context['role_name'] = 'student' if request.method == 'GET': return render(request, 'practice/profilestudent.html', context) elif request.method == 'POST': password = request.POST['password'] student = Student.objects.get(stu_id=stu_id) stu_pwd = student.stu_pwd # 判断是否有权限修改,(密码是否正确) if password != stu_pwd: context['error_message'] = '密码错误' return render(request, 'practice/profilestudent.html', context) student.stu_age = request.POST['age'] student.phone_num = request.POST['phone'] student.e_mail = request.POST['email'] if request.POST.get('tripartite') == 'on': student.tripartite_agreement = True elif not request.POST.get('tripartite'): student.tripartite_agreement = False if request.POST.get('practice') == 'on': student.practice_agreement = True elif not request.POST.get('tripartite'): student.practice_agreement = False if request.POST.get('employment') == 'on': student.employment_agreement = True elif not request.POST.get('tripartite'): student.employment_agreement = False student.stu_class = request.POST['class'] student.major = request.POST['major'] student.address = request.POST['address'] student.political_status = request.POST['politicalstatus'] student.target_post = request.POST['targetpost'] student.intention_area = request.POST['intentionarea'] resumefile = request.FILES.get("resume", None) if resumefile: if __handle_uploaded_file( resumefile, 'media{}practice{}{}{}{}'.format(os.sep, os.sep, stu_id, os.sep, str(resumefile))): resume = 'practice/{}/{}'.format(stu_id, str(resumefile)) student.resume = resume student.save() return redirect('practice.student:index')
def reporthistory(request): session = request.session role_id = int(session['role_id']) stu_id = int(session['user_id']) context = {} context['menu'] = daoapp.getMenu(role_id=role_id) context['username'] = daoapp.getUsername(role_id, stu_id) context['role_name'] = 'student' student = Student.objects.get(stu_id=stu_id) weekRecords = WeekRecord.objects.filter(stu_id=student) context['weekRecords'] = weekRecords return render(request, 'practice/reportlist.html', context)
def postjobs(request): session = request.session role_id = int(session['role_id']) ent_id = int(session['user_id']) context = {} menu = daoapp.getMenu(role_id=role_id) username = daoapp.getUsername(role_id, ent_id) jobs = daoapp.getJobs(ent_id) context['menu'] = menu context['username'] = username context['role_name'] = 'enterprise' context['jobs'] = jobs return render(request, 'practice/jobslist.html', context)
def selected(request): role_id = request.session['role_id'] ent_id = request.session['user_id'] enterprise = Enterprise.objects.get(ent_id=ent_id) jobs = Job.objects.filter(ent_id=enterprise) choices = [] for job in jobs: choices += Choice.objects.filter(job_id=job, result=True) context = {} context['choices'] = choices context['menu'] = daoapp.getMenu(role_id=role_id) context['username'] = daoapp.getUsername(role_id, ent_id) context['role_name'] = 'enterprise' return render(request, 'practice/received.html', context)
def information(request, stu_id): session = request.session role_id = int(session['role_id']) ent_id = int(session['user_id']) menu = daoapp.getMenu(role_id=role_id) username = daoapp.getUsername(role_id, ent_id) information = daoapp.getInformations(role_id=4, user_id=stu_id) # 学生的详细信息 return render( request, 'practice/index.html', { 'menu': menu, 'information': information, 'username': username, 'role_name': 'enterprise' })
def browsejobs(request): session = request.session role_id = int(session['role_id']) stu_id = int(session['user_id']) context = {} context['menu'] = daoapp.getMenu(role_id=role_id) context['username'] = daoapp.getUsername(role_id, stu_id) jobs = list(Job.objects.all()) choice = Choice.objects.filter(stu_id=stu_id) for c in choice: jobs.remove(c.job_id) context['jobs'] = jobs context['role_name'] = 'student' return render(request, 'practice/browsejobs.html', context)
def index(request): session = request.session # if 'role_id' in session.keys() and 'user_id' in session.keys(): role_id = int(session['role_id']) stu_id = int(session['user_id']) menu = daoapp.getMenu(role_id=role_id) username = daoapp.getUsername(role_id, stu_id) information = daoapp.getInformations(role_id=role_id, user_id=stu_id) return render( request, 'practice/index.html', { 'menu': menu, 'information': information, 'username': username, 'role_name': 'student' })
def editreport(request, weekRecord_id): session = request.session role_id = int(session['role_id']) stu_id = int(session['user_id']) context = {} context['menu'] = daoapp.getMenu(role_id=role_id) context['username'] = daoapp.getUsername(role_id, stu_id) context['role_name'] = 'student' weekRecord = WeekRecord.objects.get(weekRecord_id=weekRecord_id) if weekRecord.weekRecord_id != weekRecord_id: return render(request, 'practice/error.html', {'error_message': '您没有更新的权限!'}) context['weekRecord'] = weekRecord context['update'] = True return render(request, 'practice/newreport.html', context)
def internmanage(request): session = request.session role_id = int(session['role_id']) ent_id = int(session['user_id']) context = {} context['menu'] = daoapp.getMenu(role_id=role_id) context['username'] = daoapp.getUsername(role_id, ent_id) enterprise = Enterprise.objects.get(ent_id=ent_id) jobs = Job.objects.filter(ent_id=enterprise) choices = [] for job in jobs: choices += Choice.objects.filter(job_id=job) context['choices'] = choices context['role_name'] = 'enterprise' return render(request, 'practice/studentlist.html', context)
def studentmanage(request): session = request.session role_id = int(session['role_id']) tea_id = int(session['user_id']) context = {} context['menu'] = daoapp.getMenu(role_id=role_id) context['username'] = daoapp.getUsername(role_id, tea_id) teacher = Teacher.objects.get(tea_id=tea_id) # 获取本teacher对象 students = Student.objects.filter(tea_id=teacher) # 获取本teacher的所有学生 choices = [] for s in students: choices += list(Choice.objects.filter(stu_id=s)) context['choices'] = choices context['role_name'] = 'teacher' return render(request, 'practice/studentlist.html', context)
def unread(request): session = request.session role_id = int(session['role_id']) tea_id = int(session['user_id']) context = {} context['menu'] = daoapp.getMenu(role_id=role_id) context['username'] = daoapp.getUsername(role_id, tea_id) context['role_name'] = 'teacher' teacher = Teacher.objects.get(tea_id=tea_id) students = Student.objects.filter(tea_id=teacher) weekRecords = [] for s in students: weekRecords += list(WeekRecord.objects.filter(stu_id=s, readed=False)) context['weekRecords'] = weekRecords return render(request, 'practice/reportlist.html', context)