Exemplo n.º 1
0
def delete_form():
    """
    Allow a recruiter to remove his company from LBB/LBA.
    """
    form = forms.OfficeRemoveForm(data=request.values)

    if form.validate_on_submit():
        recruiter_message = models.RemoveRecruiterMessage.create_from_form(
            form,
            is_certified_recruiter=peam_recruiter.is_certified_recruiter(),
            uid=peam_recruiter.get_recruiter_uid()
        )
        mail_content = mail.generate_delete_mail(form, recruiter_message)

        try:
            mail.send_mail(mail_content, get_subject())
        except MailNoSendException as e:
            logger.exception(e)
            flash(generate_fail_flash_content(), 'error')

        params = request.args.to_dict()
        params.update({
            'custom_ga_pageview': '/recruteur/delete/success',
        })
        return redirect(url_for('contact_form.success', **params))

    return render_template('contact_form/form.html',
        title='Supprimer mon entreprise',
        form=form,
        params=urlencode(get_office_identification_data()),
        use_lba_template=is_recruiter_from_lba(),
        custom_ga_pageview='/recruteur/delete/delete',
    )
Exemplo n.º 2
0
def other_form():
    """
    Allow a recruiter to make another demand.
    """
    form = forms.OfficeOtherRequestForm(data=request.values)

    if form.validate_on_submit():
        recruiter_message = models.OtherRecruiterMessage.create_from_form(
            form,
            is_certified_recruiter=peam_recruiter.is_certified_recruiter(),
            uid=peam_recruiter.get_recruiter_uid()
        )
        mail_content = mail.generate_other_mail(form, recruiter_message)

        try:
            mail.send_mail(mail_content, get_subject())
        except MailNoSendException as e:
            logger.exception(e)
            flash(generate_fail_flash_content(), 'error')

        params = request.args.to_dict()
        params.update({
            'custom_ga_pageview': '/recruteur/other/success',
        })
        return redirect(url_for('contact_form.success', **params))

    return render_template(
        'contact_form/form.html',
        form=form,
        title='Autre demande',
        params=urlencode(get_office_identification_data()),
        use_lba_template=is_recruiter_from_lba(),
        show_required_disclaimer=True,
        custom_ga_pageview='/recruteur/other/other',
    )
Exemplo n.º 3
0
def other_form():
    """
    Allow a recruiter to make another demand.
    """
    form = forms.OfficeOtherRequestForm(data=request.values)

    if form.validate_on_submit():
        recruiter_message = models.OtherRecruiterMessage.create_from_form(
            form,
            is_certified_recruiter=peam_recruiter.is_certified_recruiter(),
            uid=peam_recruiter.get_recruiter_uid())
        mail_content = mail.generate_other_mail(form, recruiter_message)

        sendMail(mail_content=mail_content, subject=get_subject())

        params = request.args.to_dict()
        return redirect(url_for('contact_form.success', **params))

    return render_template(
        'contact_form/form.html',
        form=form,
        title='Autre demande',
        params=urlencode(get_office_identification_data()),
        use_lba_template=is_recruiter_from_lba(),
        show_required_disclaimer=True,
    )
Exemplo n.º 4
0
def delete_form():
    """
    Allow a recruiter to remove his company from LBB/LBA.
    """
    form = forms.OfficeRemoveForm(data=request.values)

    if form.validate_on_submit():
        recruiter_message = models.RemoveRecruiterMessage.create_from_form(
            form,
            is_certified_recruiter=peam_recruiter.is_certified_recruiter(),
            uid=peam_recruiter.get_recruiter_uid())
        mail_content = mail.generate_delete_mail(form, recruiter_message)

        sendMail(mail_content=mail_content, subject=get_subject())

        params = request.args.to_dict()
        return redirect(url_for('contact_form.success', **params))

    return render_template(
        'contact_form/form.html',
        title='Supprimer mon entreprise',
        form=form,
        params=urlencode(get_office_identification_data()),
        use_lba_template=is_recruiter_from_lba(),
    )
Exemplo n.º 5
0
def common_mail_template(form):

    certified_recruiter = is_certified_recruiter()
    unique_recruiter_id = session.get(SessionKeys.UID.value, '')

    return """
        Un email a été envoyé par le formulaire de contact de la Bonne Boite :<br>
        - Action : {}<br>
        - Siret : {},<br>
        - Prénom : {},<br>
        - Nom : {}, <br>
        - E-mail : {},<br>
        - Téléphone : {},<br><br>

        - Recruteur certifié : <strong>{}</strong> -- Identifiant unique ==> {}
        <hr>
    """.format(
        compute_action_name(form),
        escape(form.siret.data),
        escape(form.first_name.data),
        escape(form.last_name.data),
        escape(form.email.data),
        escape(form.phone.data),
        'oui' if certified_recruiter else 'non',
        unique_recruiter_id,
    )
Exemplo n.º 6
0
def delete_form(form):
    if form.validate_on_submit():
        recruiter_message = models.RemoveRecruiterMessage.create_from_form(
            form,
            is_certified_recruiter=peam_recruiter.is_certified_recruiter(),
            uid=peam_recruiter.get_recruiter_uid())
        mail_content = mail.generate_delete_mail(form, recruiter_message)

        try:
            mail.send_mail(mail_content, get_subject())
        except MailNoSendException as e:
            logger.exception(e)
            flash(generate_fail_flash_content(), 'error')
        else:
            redirect_params = get_success_value()
            return render_template(
                'contact_form/success_message.html',
                title="Merci pour votre message",
                use_lba_template=is_recruiter_from_lba(),
                site_name=redirect_params.get('site_name'),
                email=redirect_params.get('email'),
                home_url=redirect_params.get('home_url'),
                action_form_url=url_for('contact_form.ask_action',
                                        **request.args),
                custom_ga_pageview='/recruteur/delete/success',
            )

    return render_template(
        'contact_form/form.html',
        title='Supprimer mon entreprise',
        form=form,
        params=extract_recruiter_data(),
        use_lba_template=is_recruiter_from_lba(),
        custom_ga_pageview='/recruteur/delete/delete',
    )
Exemplo n.º 7
0
def update_jobs_form(form):
    try:
        office = get_office_from_siret(request.args['siret'])
    except NoResultFound:
        flash(unknown_siret_message(), 'error')
        return redirect(url_for('contact_form.change_info'))

    office_romes = mapping_util.romes_for_naf(office.naf)

    rome_fields = []
    for rome in office_romes:
        # Retrieve old values
        current_values = dict(request.form).get(rome.code, ['lbb', 'lba'])

        rome_fields.append({
            'code': rome.code,
            'name': rome.name,
            'current_values': current_values
        })

    if form.validate_on_submit():
        recruiter_message = models.UpdateJobsRecruiterMessage.create_from_form(
            form,
            is_certified_recruiter=peam_recruiter.is_certified_recruiter(),
            uid=peam_recruiter.get_recruiter_uid())
        mail_content = mail.generate_update_jobs_mail(form, recruiter_message)

        try:
            mail.send_mail(mail_content, get_subject())
        except MailNoSendException as e:
            logger.exception(e)
            flash(generate_fail_flash_content(), 'error')
        else:
            redirect_params = get_success_value()
            return render_template(
                'contact_form/success_message.html',
                title="Merci pour votre message",
                use_lba_template=is_recruiter_from_lba(),
                site_name=redirect_params.get('site_name'),
                email=redirect_params.get('email'),
                home_url=redirect_params.get('home_url'),
                rome_fields=rome_fields,
                suggest_update_coordinates=True,
                params=extract_recruiter_data(),
                action_form_url=url_for('contact_form.ask_action',
                                        **request.args),
                custom_ga_pageview='/recruteur/update_jobs/success',
            )

    return render_template(
        'contact_form/change_job_infos.html',
        title='Demande de modification des métiers',
        form=form,
        params=extract_recruiter_data(),
        use_lba_template=is_recruiter_from_lba(),
        manually_added_jobs=extract_manually_added_jobs(office),
        rome_fields=rome_fields,
        custom_ga_pageview='/recruteur/update_jobs/update_jobs',
    )
Exemplo n.º 8
0
def change_info():
    """
    Let a user fill a form to identify himself/herself in order to request changes
    about an office.
    """
    fix_csrf_session()
    form = forms.OfficeIdentificationForm()

    # Clear session if user comes from 'I don't have recruiter account'
    if request.args.get('no_pe_connect', ''):
        peam_recruiter.clear_pe_connect_recruiter_session()

    # Siret information is present when coming from change_info route.
    # Apply it only if user has not typed anything else yet.
    params = request.args.copy()

    action_name = get_action_name()
    if not action_name:
        flash('Une erreur inattendue est survenue, veuillez sélectionner à nouveau une action', 'error')
        return redirect(url_for('contact_form.ask_action'))

    form.last_name.data = form.last_name.data or session.get(peam_recruiter.SessionKeys.LASTNAME.value)
    form.first_name.data = form.first_name.data or session.get(peam_recruiter.SessionKeys.FIRSTNAME.value)
    form.email.data = form.email.data or session.get(peam_recruiter.SessionKeys.EMAIL.value)

    siret = params.get('siret')
    if siret and not form.data['siret']:
        form.siret.data = siret

    if form.validate_on_submit():
        office = models.Office.query.filter(models.Office.siret == form.siret.data).first()
        if not office:
            flash(unknown_siret_message(), 'error')
        else:
            params = {key: form.data[key] for key in ['siret', 'last_name', 'first_name', 'phone', 'email']}
            if is_recruiter_from_lba():
                params.update({"origin":"labonnealternance"})
            action_form_url = "contact_form.%s_form" % action_name
            url = url_for(action_form_url, **params)
            return redirect(url)

    return render_template('contact_form/form.html',
        title='Identifiez-vous',
        submit_text='suivant',
        extra_submit_class='identification-form',
        form=form,
        is_certified_recruiter=peam_recruiter.is_certified_recruiter(),
        is_recruiter=peam_recruiter.is_recruiter(),
        use_lba_template=is_recruiter_from_lba(),
        show_disclaimer=True,
        hide_return=True,
        custom_ga_pageview='/recruteur/%s/identification' % action_name,
    )
Exemplo n.º 9
0
def update_jobs_form():
    """
    Allow a recruiter to add or delete ROME codes related to his company.
    """
    # Use POST params if available, GET params otherwise.
    form_data = request.form or request.args.copy()

    try:
        office = models.Office.query.filter(models.Office.siret == form_data['siret']).one()
    except NoResultFound:
        flash(unknown_siret_message(), 'error')
        return redirect(url_for('contact_form.change_info'))

    if request.method == 'GET':

        # Prepare form's initial data.
        romes_to_boost = office.romes_codes
        romes_alternance_to_boost = office.romes_codes
        extra_romes_to_add = set()
        extra_romes_alternance_to_add = set()

        office_update = OfficeAdminUpdate.query.filter(OfficeAdminUpdate.sirets == office.siret).first()
        if office_update:
            if office_update.romes_to_boost:
                romes_to_boost = set(OfficeAdminUpdate.as_list(office_update.romes_to_boost))
                extra_romes_to_add = romes_to_boost - office.romes_codes
            if office_update.romes_alternance_to_boost:
                romes_alternance_to_boost = set(OfficeAdminUpdate.as_list(office_update.romes_alternance_to_boost))
                extra_romes_alternance_to_add = romes_alternance_to_boost - office.romes_codes

        form_data['romes_to_keep'] = romes_to_boost
        form_data['romes_alternance_to_keep'] = romes_alternance_to_boost

    else:
        # Those form fields are defined outside of the form class, we use `request.form` to get them.
        extra_romes_to_add = set(request.form.getlist('extra_romes_to_add'))
        extra_romes_alternance_to_add = set(request.form.getlist('extra_romes_alternance_to_add'))

    form = forms.OfficeUpdateJobsForm(data=form_data, office=office)

    if form.validate_on_submit():
        recruiter_message = models.UpdateJobsRecruiterMessage.create_from_form(
            form,
            is_certified_recruiter=peam_recruiter.is_certified_recruiter(),
            uid=peam_recruiter.get_recruiter_uid()
        )
        mail_content = mail.generate_update_jobs_mail(form, recruiter_message)

        try:
            mail.send_mail(mail_content, get_subject())
        except MailNoSendException as e:
            logger.exception(e)
            flash(generate_fail_flash_content(), 'error')

        params = request.args.to_dict()
        params.update({
            'custom_ga_pageview': '/recruteur/update_jobs/success',
            'suggest_update_coordinates': '1',
        })
        return redirect(url_for('contact_form.success', **params))

    extra_added_jobs = [
        {
            'rome_code': rome_code,
            'label': settings.ROME_DESCRIPTIONS[rome_code],
            'lbb': rome_code in extra_romes_to_add,
            'lba': rome_code in extra_romes_alternance_to_add,
        }
        for rome_code in extra_romes_to_add | extra_romes_alternance_to_add
    ]

    return render_template('contact_form/change_job_infos.html',
        title='Demande de modification des métiers',
        form=form,
        params=urlencode(get_office_identification_data()),
        use_lba_template=is_recruiter_from_lba(),
        extra_added_jobs=extra_added_jobs,
        custom_ga_pageview='/recruteur/update_jobs/update_jobs',
    )
Exemplo n.º 10
0
def update_coordinates_form():
    """
    Allow a recruiter to update his company's coordinates.
    """
    form_data = request.values

    try:
        office = models.Office.query.filter(models.Office.siret == form_data['siret']).one()
    except NoResultFound:
        flash(unknown_siret_message(), 'error')
        return redirect(url_for('contact_form.change_info'))

    form = forms.OfficeUpdateCoordinatesForm(data=form_data)

    # Fill form with form value (or office value by default)
    form.new_contact_mode.data = request.form.get(
        'new_contact_mode',
        CONTACT_MODES_LABEL_TO_FORM_VALUE.get(office.contact_mode, '')
    )
    form.new_website.data = request.form.get('new_website', office.website)
    form.new_email.data = request.form.get('new_email', office.email)
    form.new_phone.data = request.form.get('new_phone', office.phone)
    form.social_network.data = request.form.get('social_network', office.social_network)
    form.new_phone_alternance.data = request.form.get('new_phone_alternance', office.phone_alternance)
    form.new_email_alternance.data = request.form.get('new_email_alternance', office.email_alternance)

    if form.validate_on_submit():
        form_valid = True

        # If a recruiter choose a contact_mode, the associated field became required
        contact_mode = form.new_contact_mode.data
        if contact_mode == 'website' and not form.new_website.data:
            flash(ERROR_CONTACT_MODE_MESSAGE.format('Via votre site internet', 'Site Internet'), 'error')
            form_valid = False
        elif contact_mode == 'phone' and not form.new_phone.data:
            flash(ERROR_CONTACT_MODE_MESSAGE.format('Par téléphone', 'Téléphone'), 'error')
            form_valid = False
        elif contact_mode == 'email' and not form.new_email.data:
            flash(ERROR_CONTACT_MODE_MESSAGE.format('Par email', 'Email recruteur'), 'error')
            form_valid = False

        if form_valid:
            recruiter_message = models.UpdateCoordinatesRecruiterMessage.create_from_form(
                form,
                is_certified_recruiter=peam_recruiter.is_certified_recruiter(),
                uid=peam_recruiter.get_recruiter_uid()
            )
            mail_content = mail.generate_update_coordinates_mail(form, recruiter_message)

            try:
                mail.send_mail(mail_content, get_subject())
            except MailNoSendException as e:
                logger.exception(e)
                flash(generate_fail_flash_content(), 'error')

            params = request.args.to_dict()
            params.update({
                'custom_ga_pageview': '/recruteur/update_coordinates/success',
                'suggest_update_jobs': '1',
            })
            return redirect(url_for('contact_form.success', **params))

    return render_template('contact_form/form.html',
        title='Modifier ma fiche entreprise',
        form=form,
        params=urlencode(get_office_identification_data()),
        use_lba_template=is_recruiter_from_lba(),
        show_entreprise_page=True,
        show_coordinates_disclaimer=True,
        custom_ga_pageview='/recruteur/update_coordinates/update_coordinates',
    )
Exemplo n.º 11
0
def update_coordinates_form(form):
    try:
        office = get_office_from_siret(request.args['siret'])
    except NoResultFound:
        flash(unknown_siret_message(), 'error')
        return redirect(url_for('contact_form.change_info'))

    # Fill form with form value (or office value by default)
    form.new_contact_mode.data = request.form.get(
        'new_contact_mode',
        CONTACT_MODES_LABEL_TO_FORM_VALUE.get(office.contact_mode, ''))
    form.new_website.data = request.form.get('new_website', office.website)
    form.new_email.data = request.form.get('new_email', office.email)
    form.new_phone.data = request.form.get('new_phone', office.phone)
    form.social_network.data = request.form.get('social_network',
                                                office.social_network)
    form.new_phone_alternance.data = request.form.get('new_phone_alternance',
                                                      office.phone_alternance)
    form.new_email_alternance.data = request.form.get('new_email_alternance',
                                                      office.email_alternance)

    if form.validate_on_submit():
        form_valid = True

        # If a recruiter choose a contact_mode, the associated field became required
        contact_mode = form.new_contact_mode.data
        if contact_mode == 'website' and not form.new_website.data:
            flash(
                ERROR_CONTACT_MODE_MESSAGE.format('Via votre site internet',
                                                  'Site Internet'), 'error')
            form_valid = False
        elif contact_mode == 'phone' and not form.new_phone.data:
            flash(
                ERROR_CONTACT_MODE_MESSAGE.format('Par téléphone',
                                                  'Téléphone'), 'error')
            form_valid = False
        elif contact_mode == 'email' and not form.new_email.data:
            flash(
                ERROR_CONTACT_MODE_MESSAGE.format('Par email',
                                                  'Email recruteur'), 'error')
            form_valid = False

        if form_valid:
            recruiter_message = models.UpdateCoordinatesRecruiterMessage.create_from_form(
                form,
                is_certified_recruiter=peam_recruiter.is_certified_recruiter(),
                uid=peam_recruiter.get_recruiter_uid())
            mail_content = mail.generate_update_coordinates_mail(
                form, recruiter_message)

            try:
                mail.send_mail(mail_content, get_subject())
            except MailNoSendException as e:
                logger.exception(e)
                flash(generate_fail_flash_content(), 'error')
            else:
                redirect_params = get_success_value()
                return render_template(
                    'contact_form/success_message.html',
                    title="Merci pour votre message",
                    use_lba_template=is_recruiter_from_lba(),
                    site_name=redirect_params.get('site_name'),
                    email=redirect_params.get('email'),
                    home_url=redirect_params.get('home_url'),
                    suggest_update_jobs=True,
                    params=extract_recruiter_data(),
                    action_form_url=url_for('contact_form.ask_action',
                                            **request.args),
                    custom_ga_pageview='/recruteur/update_coordinates/success',
                )

    return render_template(
        'contact_form/form.html',
        title='Modifier ma fiche entreprise',
        form=form,
        params=extract_recruiter_data(),
        use_lba_template=is_recruiter_from_lba(),
        show_entreprise_page=True,
        show_coordinates_disclaimer=True,
        custom_ga_pageview='/recruteur/update_coordinates/update_coordinates',
    )