Example #1
0
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
Example #2
0
def student_index(request):

    if request.method == 'GET':
        student = StudentContainer(request.user)
        if student.get_student() is None:
            return redirect('student:new')
        return render(request, 'manual/student/index.html', {'nav_student': student.get_student(), 'tab': 'manual'})
    raise Http404
Example #3
0
def save_event(request, pk):

    if request.method == 'GET':
        student = StudentContainer(request.user)

        try:
            with transaction.atomic():
                if student.save_event(pk):
                    return HttpResponse('success', status=200)
                else:
                    raise IntegrityError
        except IntegrityError:
            m = str(student.get_errors())
            return HttpResponse(m, status=400)

    raise Http404
Example #4
0
def privacy_policy(request):

    if request.method == 'GET':
        user = UserUtil(request.user)
        context = {}
        if user.is_logged_in():
            if user.get_user_type() == 'company':
                company = CompanyContainer(user.get_user())
                context['logged'] = 'company'
                context['user_name'] = company.get_company().name
            elif user.get_user_type() == 'student':
                student = StudentContainer(user.get_user())
                context['logged'] = 'student'
                context['user_name'] = student.get_student().name
        return render(request, 'home/privacy_policy.html', context)

    raise Http404
Example #5
0
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
Example #6
0
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
Example #7
0
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
Example #8
0
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
Example #9
0
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')
Example #10
0
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
Example #11
0
def close_notifications(request, u):

    if request.method == 'GET':
        user = None
        if u == 'company':
            user = CompanyContainer(request.user).get_company()
        elif u == 'student':
            user = StudentContainer(request.user).get_student()

        if user:

            try:
                with transaction.atomic():
                    if MessageCenter.close_all_notifications(u, user):
                        return HttpResponse('Notifications closed.', status=200)
                    else:
                        raise IntegrityError
            except IntegrityError:
                return HttpResponse('No notifications found.', status=400)

        return HttpResponse('Invalid user request.', status=400)

    raise Http404
Example #12
0
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
Example #13
0
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
Example #14
0
    def post(self, request, ut):
        user = UserUtil(self.request.user)
        rq = RequestUtil()
        i = rq.get_user_change_info(self.request)
        if ut == 'company':
            self.template_name = 'home/company_change_form.html'
        elif ut == 'student':
            self.template_name = 'home/student_change_form.html'
        if i:

            if user.get_user().check_password(i['old_password']):
                try:
                    with transaction.atomic():
                        if i['email']:
                            if ut == 'student':
                                student = StudentContainer(user.get_user())
                                if user.change_user_email(i, student=student.get_student()):
                                    return redirect('home:verify')
                                else:
                                    raise IntegrityError
                            elif ut == 'company':
                                company = CompanyContainer(user.get_user())
                                if user.change_user_email(i, company=company.get_company()):
                                    if user.log_user_out(request):
                                        return redirect('home:verify')
                                    raise IntegrityError
                                else:
                                    raise IntegrityError
                            else:
                                return render(request, self.template_name, {'error': 'Invalid request.'})
                        elif i['password']:
                            if user.change_user_password(i):
                                if user.log_user_out(self.request):
                                    if user.log_user_in(
                                            self.request,
                                            {
                                                'email': user.get_user().email,
                                                'password': i['password']
                                            }
                                    ):
                                        m = 'Password changed successfully.'
                                        if ut == 'student':
                                            student = StudentContainer(user.get_user())
                                            MessageCenter.new_notification('student', student.get_student(), 100, m)
                                            MessageCenter.new_message('student', student.get_student(), 'success', m)
                                            return redirect('student:index')
                                        elif ut == 'company':
                                            company = CompanyContainer(user.get_user())
                                            MessageCenter.new_notification('company', company.get_company(), 100, m)
                                            MessageCenter.new_message('company', company.get_company(), 'success', m)
                                            return redirect('company:index')
                                        else:
                                            return redirect('home:index')
                            raise IntegrityError

                except IntegrityError:
                    return render(request, self.template_name, {'error': str(user.get_errors())})
            else:
                return render(request, self.template_name, {'error': 'Incorrect password.'})

        else:
            return render(request, self.template_name, {'error': str(rq.get_errors())})
Example #15
0
def student_profile(request):
    if request.method == 'GET':
        student = StudentContainer(request.user)
        return render(request, 'manual/student/profile.html', {'nav_student': student.get_student(), 'tab': 'manual'})
    raise Http404
Example #16
0
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