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 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 #3
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 #4
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 #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 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 #8
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 #9
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