Ejemplo n.º 1
0
 def get(self, request, *args, **kwargs):
     data = ResponseData()
     logs = UsersLog.objects.all().order_by('-created').values()
     users_list = list(logs)
     data.result = users_list
     data.message = "Logs list has been fetched successfully."
     return RecruitResponse.get_success_response(status.HTTP_200_OK, data)
Ejemplo n.º 2
0
    def post(self, request, *args, **kwargs):
        try:
            serializer = self.serializer_class(data=request.data,
                                               context={'request': request})
            if serializer.is_valid():
                user = serializer.validated_data['user']
                token, created = Token.objects.get_or_create(user=user)
                data = ResponseData()

                data.result = {
                    'token': token.key,
                    'user_id': user.id,
                    'email': user.email,
                    'first_name': '',
                    'last_name': ''
                }

                personal_info = PersonalInfoOperations(user).get_by_user()
                if personal_info:
                    data.result['first_name'] = personal_info.first_name
                    data.result['last_name'] = personal_info.last_name

                return RecruitResponse.get_success_response(
                    status.HTTP_200_OK, data)
            return RecruitResponse.get_invalid_serializer_response(
                serializer.errors)
        except Exception as ex:
            return RecruitResponse.get_exception_response(ex)
Ejemplo n.º 3
0
 def put(self, request, *args, **kwargs):
     data = ResponseData()
     co = ContactOperations()
     _candidate = co.create_or_update(request.data)
     data.result = request.data
     data.message = "Client has been created/updated successfully."
     return RecruitResponse.get_success_response(status.HTTP_200_OK, data)
Ejemplo n.º 4
0
def change_password(request):
    try:
        PasswordOperations(request.user).update(request.data)
        data = ResponseData()
        data.message = "Password has been updated successfully."
        return RecruitResponse.get_success_response(status.HTTP_200_OK, data)
    except (Exception, AuthenticationFailed) as ex:
        return RecruitResponse.get_exception_response(ex)
Ejemplo n.º 5
0
 def put(self, request, *args, **kwargs):
     data = ResponseData()
     co = CandidateOperations()
     _candidate = co.create_or_update(request.data)
     data.result = co.get_detail(_candidate.id)
     data.message = "Candidate has been created/updated successfully."
     return RecruitResponse.get_success_response(status.HTTP_201_CREATED,
                                                 data)
Ejemplo n.º 6
0
def AccountManagerAPIView(request):
    try:
        data = ResponseData()
        data.result = AccountManagerOperations().get_as_select_list(detail_required=False)
        data.message = "Account Managers list has been fetched successfully."
        return RecruitResponse.get_success_response(status.HTTP_200_OK, data)
    except Exception as ex:
        return RecruitResponse.get_exception_response(ex)
Ejemplo n.º 7
0
 def post(self, request, *args, **kwargs):
     try:
         data = ResponseData()
         data.result = EmailOperations().send(request.data)
         data.message = "Email has been sent successfully."
         return RecruitResponse.get_success_response(
             status.HTTP_200_OK, data)
     except Exception as ex:
         return RecruitResponse.get_exception_response(ex)
Ejemplo n.º 8
0
 def get_exception_response(ex):
     if type(ex) == InvalidSerializer:
         return RecruitResponse.get_invalid_serializer_response(
             ex.errors, ex.message)
     if type(ex) != RecruitException:
         ex = RecruitException(str(ex))
     data = ResponseData()
     data.message = ex.message
     data.errors = ex.errors
     return Response(status=status.HTTP_200_OK, data=data.to_dict())
Ejemplo n.º 9
0
 def post(self, request, *args, **kwargs):
     data = ResponseData()
     myfile = request.FILES['file']
     extension = os.path.splitext(myfile.name)[1]
     tm = int(time.time())
     fname = str(tm) + str(extension)
     fs = FileSystemStorage(location=settings.MEDIA_ROOT)
     filename = fs.save(fname, myfile)
     uploaded_file_url = fs.url(filename)
     data.result = uploaded_file_url
     data.message = "File uploaded successfully."
     return RecruitResponse.get_success_response(status.HTTP_201_CREATED,
                                                 data)
Ejemplo n.º 10
0
def client(request):
    try:
        data = ResponseData()
        clients = ClientOperations().get_as_select_list()
        jobs = request.query_params.get('jobs', None)
        data.result = clients if not jobs else {
            'clients': clients,
            'jobs': JobOperations().get_as_select_list(),
            'category': JobOperations().get_as_category_list(),
            'skills': JobOperations().get_as_skill_list(),
        }
        data.message = "Client list has been fetched successfully."
        return RecruitResponse.get_success_response(status.HTTP_200_OK, data)
    except Exception as ex:
        return RecruitResponse.get_exception_response(ex)
Ejemplo n.º 11
0
def personal_info(request):
    try:
        data = ResponseData()
        po = PersonalInfoOperations(request.user)

        if request.method == 'POST':
            po.create_or_update(request.data)
            data.message = "User Personal Info has been updated successfully."
            return RecruitResponse.get_success_response(status.HTTP_200_OK, data)

        elif request.method == 'GET':
            data.message = "User Personal Info has been fetched successfully."
            data.result = po.get_data()
            return RecruitResponse.get_success_response(status.HTTP_200_OK, data)

    except (Exception, AuthenticationFailed) as ex:
        return RecruitResponse.get_exception_response(ex)
Ejemplo n.º 12
0
    def get(self, request, *args, **kwargs):
        data = ResponseData()
        co = CandidateOperations()
        data.result = co.get_list(self.kwargs['page'], self.kwargs['name'],
                                  request)
        data.total = co.get_list_total(self.kwargs['page'],
                                       self.kwargs['name'], request)

        data.total_sub = co.get_list_total_sub(self.kwargs['name'], request)
        data.total_inter = co.get_list_total_inter(self.kwargs['name'],
                                                   request)
        data.total_send = co.get_list_total_send(self.kwargs['name'], request)
        data.total_perma = co.get_list_total_perma(self.kwargs['name'],
                                                   request)
        data.total_cont = co.get_list_total_cont(self.kwargs['name'], request)

        data.message = "Candidate list has been fetched successfully."
        return RecruitResponse.get_success_response(status.HTTP_200_OK, data)
Ejemplo n.º 13
0
    def post(self, request, *args, **kwargs):
        data = ResponseData()
        received_json_data = json.loads(request.body)

        id = received_json_data['id']
        cadiastes = received_json_data['candidate']
        rec = received_json_data['rec']
        name = received_json_data['name']

        ulogs = UsersLog()
        ulogs.candidate = get_object_or_404(Candidate, pk=id)
        ulogs.log = cadiastes
        ulogs.rec = rec
        ulogs.name = name
        ulogs.save()

        data.result = received_json_data['id']
        data.message = "Candidate updated successfully."
        return RecruitResponse.get_success_response(status.HTTP_201_CREATED,
                                                    data)
Ejemplo n.º 14
0
 def get_success_response(_status, data=None):
     """
     :param _status: rest_framework.status
     :param data: Type of recruit_api.apps.a_utils.ResponseData
     :return:
     """
     _message = 'Action was successful.'
     if not data:
         data = ResponseData()
         data.message = _message
     if not data.message:
         data.message = _message
     data.successful = True
     return Response(status=_status, data=data.to_dict())
Ejemplo n.º 15
0
 def get_invalid_serializer_response(errors, message=""):
     data = ResponseData()
     data.errors = errors
     data.message = message
     return Response(status=status.HTTP_200_OK, data=data.to_dict())
Ejemplo n.º 16
0
 def get(self, request, *args, **kwargs):
     data = ResponseData()
     co = ContactOperations()
     data.result = co.get_list()
     data.message = "Candidate list has been fetched successfully."
     return RecruitResponse.get_success_response(status.HTTP_200_OK, data)