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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)
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)