Ejemplo n.º 1
0
 def post(self, request, *args, **kwargs):
     try:
         candidate = request.user.candidate_profile
         candidate_url = build_candidate_admin_url(candidate.pk)
         message = f'New candidate for identification\n' \
                   f'Candidate: {candidate.full_name} (profile id {candidate.pk}) - {candidate.email}\n' \
                   f'{candidate_url}'
         if candidate.is_identified:
             return Response(
                 {"detail": _('This profile is already identified')},
                 status=status.HTTP_400_BAD_REQUEST)
     except ObjectDoesNotExist:
         candidate = request.user
         if candidate.candidate_cvs.exists():
             document = candidate.candidate_cvs.last()
             document_url = build_candidate_cv_url(document.pk)
         else:
             document_url = None
         message = f'New candidate for identification\n' \
                   f'Candidate: {candidate.email}\n' \
                   f'Document: {document_url}'
     finally:
         send_mail(
             subject='Candidate identification',
             message=message,
             from_email=settings.EMAIL_HOST_USER,
             recipient_list=[settings.IDENTIFICATE_CANDIDATE_EMAIL],
         )
         return Response(status=status.HTTP_204_NO_CONTENT)
Ejemplo n.º 2
0
 def ask_question(self, request, *args, **kwargs):
     serializer = self.get_serializer(data=request.data)
     serializer.is_valid(raise_exception=True)
     question = serializer.data['question']
     candidate_profile = request.user.candidate_profile
     position_url = build_position_admin_url(self.get_object().pk)
     candidate_url = build_candidate_admin_url(candidate_profile.pk)
     full_name = candidate_profile.full_name
     company_name = self.get_object().company.company_name
     contact_persons = self.get_object().company.get_contact_persons_email()
     send_mail(
         subject=_('New candidate question'),
         message='New candidate question\n' +
         f'From: {full_name} - {candidate_profile.user.email}\n{candidate_url}\n\n'
         + f'To: {company_name} - {contact_persons}\n{position_url}\n\n' +
         f'{question}',
         from_email=settings.EMAIL_HOST_USER,
         recipient_list=[settings.ASK_QUESTION_EMAIL],
     )
     return Response({"detail": _("Question has been successfully sent")},
                     status=status.HTTP_200_OK)
Ejemplo n.º 3
0
 def hire(self, request, *args, **kwargs):
     candidate = self.get_object()
     company = request.user.company_profile
     company_profile = request.user.company_profile
     company_url = build_company_admin_url(company.pk)
     candidate_url = build_candidate_admin_url(candidate.pk)
     contact_persons = company_profile.get_contact_persons_email()
     hiring, created = CandidateHiring.objects.get_or_create(
         company=company, candidate=candidate)
     if not created:
         return Response(
             {"detail": _('You have already hired this candidate')},
             status=status.HTTP_400_BAD_REQUEST)
     send_mail(
         subject='Candidate hiring',
         message='New candidate hiring\n' +
         f'Company: {company.company_name} - {contact_persons}\n{company_url}\n\n'
         +
         f'Candidate: {candidate.full_name} - {candidate.email}\n{candidate_url}',
         from_email=settings.EMAIL_HOST_USER,
         recipient_list=[settings.HIRE_CANDIDATE_EMAIL],
     )
     return Response(status=status.HTTP_204_NO_CONTENT)
Ejemplo n.º 4
0
    def apply(self, request, *args, **kwargs):
        position = self.get_object()
        company_name = self.get_object().company.company_name
        contact_persons = self.get_object().company.get_contact_persons_email()
        position_url = build_position_admin_url(position.pk)
        if request.user.user_type == User.USER_TYPE_CANDIDATE:
            candidate_profile = request.user.candidate_profile
            full_name = candidate_profile.full_name
            candidate_url = build_candidate_admin_url(candidate_profile.pk)
            message = f"""New project position application\n
                          Candidate: {full_name} - {candidate_profile.user.email}\n{candidate_url}\n\n
                          Position: {company_name} - {contact_persons}\n{position_url}""",
            application, created = CandidatePositionApplication.objects.get_or_create(
                candidate=request.user.candidate_profile, position=position)
        elif request.user.user_type == User.USER_TYPE_AGENCY:
            agency_profile = request.user.agency_profile
            agency_name = agency_profile.company_name
            agency_contact_persons = agency_profile.get_contact_persons_email()
            agency_url = build_agency_admin_url(agency_profile.pk)
            message = f"""New project position application\n
                          Agency: {agency_name} - {agency_contact_persons}\n{agency_url}\n\n
                          Position: {company_name} - {contact_persons}\n{position_url}""",
            application, created = AgencyPositionApplication.objects.get_or_create(
                agency=request.user.agency_profile, position=position)

        if not created:
            return Response(
                {"detail": _('You have already applied for this position')},
                status=status.HTTP_400_BAD_REQUEST)
        send_mail(
            subject=_('Position application test'),
            message=message[0],
            from_email=settings.EMAIL_HOST_USER,
            recipient_list=[settings.APPLY_POSITION_EMAIL],
        )
        return Response(status=status.HTTP_204_NO_CONTENT)