def send_signup_emails(business_user, language_code, campaign): if campaign is None: body_filename = 'business_signup_notification_email_body' body_input = 'business_signup_email_body' BusinessUserPendingEmail.add_to_queue( the_objects=business_user, language_code=language_code, body_input=body_input, subject=_('Welcome to PeakU'), email_type=EmailType.objects.get(name='business_welcome')) else: body_filename = 'business_start_signup_notification_email_body' body_input = 'business_start_signup_email_body' messenger.send(objects=campaign, language_code=language_code, body_input=body_input) CampaignPendingEmail.add_to_queue( the_objects=campaign, language_code=language_code, body_input=body_input, subject='Oferta publicada exitosamente - {campaign}', email_type=EmailType.objects.get(name='business_welcome')) email_sender.send_internal(contact=business_user, language_code=language_code, body_filename=body_filename, subject='Business User acaba de registrarse!!!', campaign=campaign)
def add_external_job_exchange_messages(message_filename): # TODO: add English candidates = [c for c in Candidate.objects.filter(Q(created_at__gt=datetime.datetime.today() - datetime.timedelta(days=5)) & Q(state__code='BL') & Q(campaign__state__name='Active') & Q(campaign__tests=None) & ~Q(message__filename=message_filename) & ~Q(campaign_id=beta_cts.DEFAULT_CAMPAIGN_ID))] messenger.send(objects=candidates, language_code='es', body_input=message_filename)
def send_feedback_message_and_mail(business_user, campaign, request): # goes from active to finish, will ask for feedback if campaign.state == CampaignState.objects.get(code='A') and \ int(request.POST.get('state_id')) == CampaignState.objects.get(code='F').id: # TODO: this is really wrong CampaignPendingEmail.add_to_queue(the_objects=campaign, language_code='es', body_input='business_feedback', subject='Publicación terminada {campaign}', email_type=EmailType.objects.get(name='business_feedback')) messenger.send(objects=campaign, language_code='es', body_input='business_feedback')
def start_post(request): """ Args: request: HTTP post request Returns: Renders form.html. """ signup_form = CustomUserCreationForm(request.POST) if signup_form.is_valid(): campaign, prospects = campaign_module.create_campaign(request) business_user = first_sign_in(signup_form, request) business_user.campaigns.add(campaign) business_user.save() send_signup_emails(business_user, request.LANGUAGE_CODE, campaign) #PublicPost.add_to_public_post_queue(campaign) if not business_user.is_peaku(): prospect_module.send_mails(prospects) messenger.send(objects=prospects, language_code='es', body_input='candidate_prospect') return redirect( 'tablero-de-control/{business_user_id}/{campaign_id}/applicants'. format(business_user_id=business_user.pk, campaign_id=campaign.pk)) else: error_message = get_first_error_message(signup_form) return render( request, cts.START_VIEW_PATH, { 'error_message': error_message, 'work_areas': common.translate_list_of_objects(WorkArea.objects.all(), request.LANGUAGE_CODE), 'cities': common.get_cities() })
def send_prospect_messages(segment_code): candidates = Candidate.objects.filter( ~Q(user=None), ~Q(user__phone=None), ~Q(state__in=State.objects.filter(code__in=['STC', 'GTJ']).all()), ~Q(user__work_area__segment=None), removed=False) candidates = [c for c in candidates] new_candidates = candidates_filter(candidates) final_candidates = work_area_with_campaigns_filter(new_candidates) print(len(candidates)) print(len(new_candidates)) print(len(final_candidates)) messenger.send(objects=final_candidates, language_code='es', body_input='prospects_invitation_message_body')
def send_candidates_messages(): candidates = Candidate.objects.filter( user__work_area__code__in=['IT', 'I', 'IC'], user__salary__gte=2000000, user__salary__lte=10000000, user__city__id=2).order_by('-id')[:200000] # City=Bogotá #candidates = list(Candidate.objects.filter(user__pk=1929)) candidates = candidates_filter(candidates) """ for idx, c in enumerate(candidates): print('idx: {}, id: {}, name: {}'.format(idx, c.user_id, c.user.name)) """ candidates = candidates[299:-1] messenger.send(objects=candidates, language_code='en', body_input='comodin') print(len(candidates))
def business_daily_report(): business_users = BusinessUser.objects.all() for business_user in business_users: for campaign in business_user.campaigns.filter(state__code='A'): candidates = Candidate.objects.filter( state__code__in=['STC'], campaign=campaign, removed=False, sent_to_client=False) recipients = [business_user.email, business_user.additional_email, '*****@*****.**', '*****@*****.**'] # Only send if there is something. if len(candidates) > 0: #email_sender.send_report(language_code='es', # body_filename='business_daily_report_email_body', # subject='Reporte de candidatos recomendados', # recipients=recipients, # candidates=candidates) # TODO: this is really wrong CampaignPendingEmail.add_to_queue(the_objects=campaign, language_code='es', body_input='business_daily_report_email_body', subject='Reporte de candidatos recomendados en oferta: {campaign}', email_type=EmailType.objects.get(name='business_daily_report')) messenger.send(objects=campaign, language_code='es', body_input='business_daily_report_message') message = 'Se enviaron: ', len(recipients)-2, 'correos' for c in candidates: c.sent_to_client = True c.save() else: message = 'No se enviaron correos' print(message)
def create_post(request): """ Creates campaign when user is already logged Args: request: HTTP post request Returns: Renders form.html """ business_user = BusinessUser.objects.get(auth_user=request.user) campaign, prospects = campaign_module.create_campaign(request) # starts as inactive campaign, so that free users won't see, if it is not the first campaign if len(business_user.campaigns.all()) > 1: campaign.state = CampaignState.objects.get(code='I') campaign.save() business_user.campaigns.add(campaign) business_user.save() if not business_user.is_peaku(): prospect_module.send_mails(prospects) messenger.send(objects=prospects, language_code='es', body_input='candidate_prospect') send_new_campaign_notification(business_user, request.LANGUAGE_CODE, campaign) #PublicPost.add_to_public_post_queue(campaign) if len(business_user.campaigns.all()) == 2: # This crucial message should sell the service!!! messenger.send(objects=campaign, language_code='es', body_input='business_paisa_sell') return redirect('campañas/{business_user_pk}'.format( business_user_pk=business_user.pk))