Пример #1
0
def oracle_create():

    logger.debug("start oracle_create")
    form = OracleCreateForm()

    if request.method == 'GET':
        logger.debug("start oracle_create GET")
        return render_template(ORACLE_PATH + '/create.html', form=form)

    logger.debug("start oracle_create POST")
    form = OracleCreateForm(request.form)

    if request.method == 'POST' and form.validate():
        session['username'] = request.form['username']
        session['email'] = request.form['email']

        #logger.debug("UT_ENTRYTEMP insert")
        entry = Entry.dict()
        entry['UNAME'] = session['username']
        entry['UKANA'] = mojimoji.zen_to_han(session['username'])
        entry['UEMAIL'] = session['email']

        if Entry.insert(entry):
            flash("登録できました。", "success")
        else:
            flash("登録できませんでした。", "danger")

        return redirect("/sample/oracle/")

    return render_template(ORACLE_PATH + 'create.html', form=form)
Пример #2
0
def oracle_update(id):

    logger.debug("start oracle_update")
    form = OracleUpdateForm()

    if request.method == 'GET':
        entry = Entry.select_id(id)
        #プルダウン/ラジオボタンは最初に設定しないとフォームがクリアされてしまう
        form.status.default = int(entry.USTATUS)
        form.sex.default = int(entry.USEX)
        print(form.status.default)
        form.process()
        form.entryno.data = entry.UENTRYNO
        form.username.data = entry.UNAME
        form.userkana.data = entry.UKANA
        form.email.data = entry.UEMAIL
        return render_template(ORACLE_PATH + 'update.html',
                               form=form,
                               entry=entry)

    logger.debug("start oracle_update POST")
    form = OracleUpdateForm(request.form)

    if request.method == 'POST' and form.validate():

        logger.debug("--- oracle_update POST  ---")
        #logger.debug("UT_ENTRYTEMP insert")
        entry = Entry.dict()
        entry['UENTRYNO'] = id
        entry['UNAME'] = request.form['username']
        entry['UKANA'] = mojimoji.zen_to_han(request.form['username'])
        entry['UEMAIL'] = request.form['email']
        entry['USEX'] = request.form['sex']
        entry['USTATUS'] = request.form['status']
        print(request.form['status'])
        logger.debug("--- oracle_update entry data  ---")

        if Entry.update(entry) and form.validate():
            flash("更新できました。", "success")
        else:
            flash("更新できませんでした。", "danger")

        return redirect("/sample/oracle/")

    return render_template(ORACLE_PATH + 'update.html', form=form)