def edit_reference(request, pk): if request.method == 'POST': student = StudentContainer(request.user) rq = RequestUtil() i = rq.get_reference_info(request) if i: try: with transaction.atomic(): if student.edit_reference(pk, i): m = 'Reference edited successfully.' MessageCenter.new_message('student', student.get_student(), 'success', m) return HttpResponse(m, status=200) else: raise IntegrityError except IntegrityError: m = str(student.get_errors()) return HttpResponse(m, status=400) else: m = str(rq.get_errors()) return HttpResponse(m, status=400) raise Http404
def new_resume(request): if request.method == 'POST': student = StudentContainer(request.user) rq = RequestUtil() i = rq.get_resume_info(request) if i: try: with transaction.atomic(): if student.new_resume(i): r = student.get_resume() if r.is_complete: m = 'New resume created successfully.' MessageCenter.new_message('student', student.get_student(), 'success', m) m = 'resume complete' return HttpResponse(m, status=200) else: m = r.id return HttpResponse(m, status=200) else: raise IntegrityError except IntegrityError: return HttpResponse(str(student.get_errors()), status=400) else: return HttpResponse(str(rq.get_errors()), status=400) raise Http404
def post(self, request): company = CompanyContainer(request.user) rq = RequestUtil() i = rq.get_company_info(request) context = { 'company': company.get_company(), 'countries': HomeUtil.get_countries(), 'states': HomeUtil.get_states(), 'tab': 'profile', } if i: try: with transaction.atomic(): if company.edit_company(i): m = 'Company profile edited successfully.' MessageCenter.new_message('company', company.get_company(), 'success', m) return redirect('company:index') else: raise IntegrityError except IntegrityError: i['pk'] = '0' context['company'] = i context['errors'] = company.get_form().errors else: info = rq.get_info() info['pk'] = '0' context['company'] = info context['errors'] = rq.get_errors() return render(request, self.template_name, context)
def resume_detail(request, pk): if request.method == 'GET': student = StudentContainer(request.user) msgs = MessageCenter.get_messages('student', student.get_student()) resume = student.get_display_resume(pk) if not resume: MessageCenter.new_message('student', student.get_student(), 'warning', str(student.get_errors())) return redirect('resume:index') context = { 'student': student.get_student(), 'resume': resume, 'messages': msgs, 'other_schools': student.get_other_schools(), 'other_languages': student.get_other_languages(), 'other_experience': student.get_other_experience(), 'other_awards': student.get_other_awards(), 'other_skills': student.get_other_skills(), 'other_references': student.get_other_references(), 'tab': 'resume', } MessageCenter.clear_msgs(msgs) return render(request, 'resume/details.html', context) raise Http404
def post(self, request): student = StudentContainer(request.user) rq = RequestUtil() i = rq.get_student_info(request) context = { 'countries': HomeUtil.get_countries(), 'states': HomeUtil.get_states(), 'programs': HomeUtil.get_student_programs(), 'majors': HomeUtil.get_majors(), } if i: try: with transaction.atomic(): if student.new_student(i, request.user): m = 'Student profile created successfully.' MessageCenter.new_message('student', student.get_student(), 'success', m) return redirect('student:index') else: raise IntegrityError except IntegrityError: context['student'] = i context['errors'] = student.get_form().errors else: context['errors'] = rq.get_errors() return render(request, self.template_name, context)
def history_view(request): if request.method == 'GET': app_page = request.GET.get('ap', 1) e_page = request.GET.get('ep', 1) n_page = request.GET.get('np', 1) student = StudentContainer(request.user) if student.get_student() is None: return redirect('student:new') ap = Pagination(student.get_all_applications(), 10) ep = Pagination(student.get_all_saved_events(), 10) np = Pagination( list( MessageCenter.get_all_notifications('student', student.get_student())), 10) context = { 'student': student.get_student(), 'all_notifications': np.get_page(n_page), 'applications': ap.get_page(app_page), 'events': ep.get_page(e_page), 'tab': 'history', } return render(request, 'student/history.html', context) raise Http404
def delete_resume(request, pk): if request.method == 'GET': student = StudentContainer(request.user) try: with transaction.atomic(): if student.delete_resume(pk): m = 'Resume deleted successfully.' MessageCenter.new_message('student', student.get_student(), 'success', m) else: raise IntegrityError except IntegrityError: m = str(student.get_errors()) MessageCenter.new_message('student', student.get_errors(), 'danger', m) return redirect('resume:index')
def change_active_resume(request, pk): if request.method == 'GET': student = StudentContainer(request.user) try: with transaction.atomic(): if student.make_active_resume(pk): m = 'Active resume changed successfully.' MessageCenter.new_message('student', student.get_student(), 'success', m) return HttpResponse('success', status=200) else: raise IntegrityError except IntegrityError: m = str(student.get_errors()) return HttpResponse(m, status=400) raise Http404
def add_file_resume(request, pk): if request.method == 'POST': student = StudentContainer(request.user) try: with transaction.atomic(): if student.add_file_resume(pk, request.POST, request.FILES): m = 'File uploaded successfully.' MessageCenter.new_message('student', student.get_student(), 'success', m) data = {'is_valid': True} return JsonResponse(data) else: raise IntegrityError except IntegrityError: data = {'is_valid': False, 'error': str(student.get_errors())} return JsonResponse(data) raise Http404
def add_reference(request, pk, rk): if request.method == 'GET': student = StudentContainer(request.user) try: with transaction.atomic(): if student.add_reference(rk, pk): m = 'Reference added successfully.' MessageCenter.new_message('student', student.get_student(), 'success', m) else: raise IntegrityError except IntegrityError: m = str(student.get_errors()) MessageCenter.new_message('student', student.get_student(), 'danger', m) return redirect('resume:details', pk=rk) raise Http404
def remove_saved_event(request, pk): if request.method == 'GET': student = StudentContainer(request.user) try: with transaction.atomic(): if student.remove_saved_event(pk): m = 'Event successfully removed.' MessageCenter.new_message('student', student.get_student(), 'success', m) return HttpResponse('success', status=200) else: raise IntegrityError except IntegrityError: m = str(student.get_errors()) return HttpResponse(m, status=400) raise Http404
def suggestions_view(request): if request.method == 'GET': page = request.GET.get('page', 1) company = CompanyContainer(request.user) if company.get_company() is None: return redirect('company:new') suggestions = Pagination(company.get_suggestions(), 10) msgs = MessageCenter.get_messages('company', company.get_company()) context = { 'suggestions': suggestions.get_page(page), 'company': company.get_company(), 'messages': msgs, 'tab': 'suggestions', } MessageCenter.clear_msgs(msgs) return render(request, 'company/suggestions.html', context) raise Http404
def delete_logo(request): if request.method == 'GET': company = CompanyContainer(request.user) try: with transaction.atomic(): if company.delete_logo(): m = 'Logo delete successfully.' MessageCenter.new_message('company', company.get_company(), 'success', m) else: raise IntegrityError except IntegrityError: m = str(company.get_errors()) MessageCenter.new_message('company', company.get_company(), 'danger', m) return redirect('company:index') raise Http404
def upload_logo(request): if request.method == 'POST': company = CompanyContainer(request.user) try: with transaction.atomic(): if company.upload_logo(request.POST, request.FILES): m = 'Logo uploaded successfully.' MessageCenter.new_message('company', company.get_company(), 'success', m) data = {'is_valid': True} return JsonResponse(data) else: raise IntegrityError except IntegrityError: data = {'is_valid': False, 'error': str(company.get_errors())} return JsonResponse(data) raise Http404
def comment_suggestion(request, pk): if request.method == 'POST': company = CompanyContainer(request.user) comment = request.POST.get('suggestion_comment') if comment: try: with transaction.atomic(): if company.comment_suggestion(pk, comment): m = 'Comment successfully added.' MessageCenter.new_message('company', company.get_company(), 'success', m) return HttpResponse(status=200) else: raise IntegrityError except IntegrityError: return HttpResponse(str(company.get_errors()), status=400) else: return HttpResponse('Comment field cannot be empty', status=400)
def company_index(request): if request.method == 'GET': event_page = request.GET.get('ep', 1) ex_event_page = request.GET.get('xep', 1) company = CompanyContainer(request.user) if company.get_company() is None: return redirect('company:new') msgs = MessageCenter.get_messages('company', company.get_company()) events = Pagination(company.get_events(), 10) ex_events = Pagination(company.get_expired_events(), 10) context = { 'company': company.get_company(), 'events': events.get_page(event_page), 'expired_events': ex_events.get_page(ex_event_page), 'messages': msgs, 'tab': 'events', } MessageCenter.clear_msgs(msgs) return render(request, 'event/company_index.html', context) raise Http404
def student_index(request, pk): if request.method == 'GET': student = StudentContainer(request.user) if student.get_student() is None: return redirect('student:new') msgs = MessageCenter.get_messages('student', student.get_student()) notes = MessageCenter.get_notifications('student', student.get_student()) events = student.get_events(pk) context = { 'student': student.get_student(), 'events': events, 'count': len(events), 'messages': msgs, 'notifications': notes, 'tab': 'events', } return render(request, 'event/student_index.html', context) raise Http404
def resume_index(request): if request.method == 'GET': page = request.GET.get('page', 1) student = StudentContainer(request.user) if student.get_student() is None: return redirect('student:new') msgs = MessageCenter.get_messages('student', student.get_student()) notes = MessageCenter.get_notifications('student', student.get_student()) resumes = Pagination(student.get_resumes(), 20) context = { 'student': student.get_student(), 'resumes': resumes.get_page(page), 'messages': msgs, 'first': 'false' if resumes.count > 0 else 'true', 'notifications': notes, 'tab': 'resume', } MessageCenter.clear_msgs(msgs) return render(request, 'resume/index.html', context) raise Http404
def index_view(request): if request.method == 'GET': app_page = request.GET.get('ap', 1) e_page = request.GET.get('ep', 1) p_page = request.GET.get('pp', 1) student = StudentContainer(request.user) if student.get_student() is None: return redirect('student:new') msgs = MessageCenter.get_messages('student', student.get_student()) a = student.get_applications() apps = Pagination(a if a else [], 15) events = Pagination(student.get_saved_events(), 15) posts = Pagination(student.get_newest_posts(), 5) context = { 'student': student.get_student(), 'applications': apps.get_page(app_page), 'old_apps': student.get_old_applications(), 'events': events.get_page(e_page), 'posts': posts.get_page(p_page), 'resumes': student.get_resumes(), 'messages': msgs, 'notifications': MessageCenter.get_notifications('student', student.get_student()), 'tab': 'home', } MessageCenter.clear_msgs(msgs) return render(request, 'student/index.html', context) raise Http404
def new_suggestion(request): if request.method == 'POST': company = CompanyContainer(request.user) rq = RequestUtil() i = rq.get_suggestion_info(request) if i: try: with transaction.atomic(): if company.new_suggestion(i): m = 'Suggestion successfully submitted.' MessageCenter.new_message('company', company.get_company(), 'success', m) return HttpResponse(status=200) else: raise IntegrityError except IntegrityError: return HttpResponse(str(company.get_errors()), status=400) else: return HttpResponse(str(rq.get_errors()), status=400) raise Http404
def index_view(request): if request.method == 'GET': post_page = request.GET.get('pp', 1) event_page = request.GET.get('ep', 1) company = CompanyContainer(request.user) if company.get_company() is None: return redirect('company:new') msgs = MessageCenter.get_messages('company', company.get_company()) posts = Pagination(company.get_home_posts(), 15) events = Pagination(company.get_events(), 15) context = { 'company': company.get_company(), 'posts': posts.get_page(post_page), 'events': events.get_page(event_page), 'messages': msgs, 'notifications': MessageCenter.get_notifications('company', company.get_company()), 'tab': 'home', } MessageCenter.clear_msgs(msgs) return render(request, 'company/index.html', context) raise Http404
def profile_view(request): if request.method == 'GET': student = StudentContainer(request.user) if student.get_student() is None: return redirect('student:new') else: s = student.get_student() context = { 'student': s, 'user': student.get_user(), 'notifications': MessageCenter.get_notifications('student', s), 'tab': 'profile' } return render(request, 'student/profile.html', context) raise Http404