Exemple #1
0
def questionnaire_1(token):

    form = MainForms.Form_1()
    fields = extract_fields(form)

    if request.method == 'GET':
        pass
    else:

        if form.validate_on_submit():
            if not token:
                token = token_hex(16)
                quest = Questionnaire(token=token)
                db.session.add(quest)
                db.session.commit()
            else:
                quest = Questionnaire.query.filter_by(token=token).first()
                if not quest:
                    flash("Désolé, une erreur c'est produite", "danger")
                    return redirect(url_for("main.home"))

            for field in fields:
                setattr(quest, field, getattr(form, field).data)
            db.session.commit()

            return redirect(url_for("main.questionnaire_2", token=token))
        else:
            flash_all_errors(form)

    return render_template('main/questionnaire_1.html',
                           title="Inscription 1/6",
                           form=form,
                           token=token,
                           text=MainText.questionnaire.q1,
                           back=None)
Exemple #2
0
def questionnaire_5(token):

    quest = Questionnaire.query.filter_by(token=token).first()
    if not quest:
        flash("Désolé, une erreur c'est produite", "danger")
        return redirect(url_for("main.home"))
    form = MainForms.Form_5()
    fields = extract_fields(form)

    if request.method == 'GET':
        pass
    else:

        if form.validate_on_submit():
            for field in fields:
                setattr(quest, field, getattr(form, field).data)
            db.session.commit()

            # flash("Super Merci!", "success")
            return redirect(url_for("main.questionnaire_6", token=token))
        else:
            flash_all_errors(form)

    return render_template('main/questionnaire_5.html',
                           title="Inscription 5/6",
                           form=form,
                           token=token,
                           text=MainText.questionnaire.q5,
                           back="4")
Exemple #3
0
def questionnaire_6(token):

    quest = Questionnaire.query.filter_by(token=token).first()
    if not quest:
        flash("Désolé, une erreur c'est produite", "danger")
        return redirect(url_for("main.home"))

    if token != "error":
        form = MainForms.Form_6()
        fields = extract_fields(form)
    else:
        form = None

    if request.method == 'GET':
        pass
    else:
        if form.validate_on_submit():
            # u = User.query.filter_by(email=form.email.data).all()
            # if u:
            #   flash("Vous avez déja un compte!", "success")
            #   return redirect(url_for("main.login_user"))
            # else:
            #   flash("Contact créé!", "success")
            #   quest.email = form.email.data
            #   quest.phone = form.phone.data
            #   quest.hour = form.hour.data
            #   db.session.commit()
            # return redirect(url_for('main.home'))
            # flash("success", "success")
            for field in fields:
                setattr(quest, field, getattr(form, field).data)
            db.session.commit()
            return redirect(url_for('main.bienvenue', token=token))

    return render_template('main/questionnaire_6.html',
                           title="Inscription 6/6",
                           text=MainText.questionnaire.q6,
                           form=form,
                           token=token,
                           back="5")
Exemple #4
0
def corporate_log():

    form = MainForms.Corporate()

    if request.method == 'GET':
        pass

    else:
        if form.validate_on_submit():
            flash("Super Merci!", "success")

            return render_template('main/corporate_data2.html',
                                   title="Corporate",
                                   text=MainText.home,
                                   corpo=MainText.corporate)
        else:
            flash_all_errors(form)

    return render_template('main/corporate_log.html',
                           title="Corporate",
                           text=MainText.corporate,
                           form=form)
Exemple #5
0
def contact():
    form = MainForms.Contact()
    fields = extract_fields(form)

    if request.method == 'GET':
        pass
    else:
        if form.validate_on_submit():
            contact = Contact()
            for field in fields:
                setattr(contact, field, getattr(form, field).data)
            db.session.add(contact)
            db.session.commit()

            flash("Message envoyé !", "success")
            return redirect(url_for("main.home"))
        else:
            flash_all_errors(form)

    return render_template('main/contact.html',
                           title="Contact",
                           form=form,
                           text=MainText.contact)