Example #1
0
def index():
    form = TableForm()
    if form.validate_on_submit():
        return render_template('index.html',
                               form=form,
                               result=spider(form.name.data))
    return render_template('index.html', form=form, result="请输入要查询的物品")
Example #2
0
def adminPost():
    table_form = TableForm(formdata=request.form)
    if table_form.validate_on_submit():
        rows = [dict(name=dic['nickname'], role=(
            str(1) if dic['check'] else str(0))) for dic in table_form.rows.data]
        User.updateUser(rows)
        flash('Actualización correcta')
    return redirect(url_for('admin'))
Example #3
0
def account_createtable():
    tableform = TableForm(request.form)
    if tableform.validate():
        tableName = tableform.tableID.data
        tableID = DB.add_table(tableName, current_user.get_id())
        # new_URL = BH.shorten_url(config.base_url + "newrequest/" + str(tableID))
        new_URL = config.base_url + "newrequest/" + str(tableID)
        DB.update_table(tableID, new_URL)
        return redirect(url_for('account'))
    return render_template("account.html",
                           tableform=tableform,
                           tables=DB.get_tables(current_user.get_id()))
Example #4
0
def admin():
    users = User.getUsers()
    form_users = TableForm()
    for row in users:
        _row = RowForm()
        _row.nickname = row['name']
        _row.check = bool(int(row['role']))
        form_users.rows.append_entry(_row)
    context = dict(users=users, form_user=form_users)
    return render_template('admin.html', **context)
Example #5
0
def index():
    form = TableForm()
    if form.validate_on_submit():
        img = Image.open(os.path.join(STATIC_DIR,
                                      "template.jpg")).convert("RGB")
        #download font.ttf to static file, and use different font will be better
        font1 = ImageFont.truetype(os.path.join(STATIC_DIR, "jmt.ttf"), 30)
        font2 = ImageFont.truetype(os.path.join(STATIC_DIR, "jmt.ttf"), 30)
        font3 = ImageFont.truetype(os.path.join(STATIC_DIR, "jmt.ttf"), 28)

        draw = ImageDraw.Draw(img)
        color = (0, 0, 0)
        draw.text((100, 70), form.name.data, color, font=font1)
        draw.text((300, 65), form.department.data, color, font=font1)
        draw.text((600, 65), form.days.data, color, font=font1)
        draw.text((100, 120), form.reason.data, color, font=font1)

        draw.text((430, 35), form.year.data, color, font=font1)
        draw.text((520, 35), form.month.data, color, font=font1)
        draw.text((560, 35), form.day.data, color, font=font1)

        date_str = form.year.data + "-" + form.month.data + "-" + form.day.data
        date = datetime.datetime.strptime(date_str, "%Y-%m-%d")
        new_date = date + datetime.timedelta(days=int(form.days.data))
        new_month = re.findall('-(\d+)-', str(new_date))[0]
        new_day = re.findall('-(\d+) ', str(new_date))[0]

        draw.text((120, 210), form.month.data, color, font=font1)
        draw.text((170, 210), form.day.data, color, font=font1)
        draw.text((240, 210), new_month, color, font=font1)
        draw.text((280, 210), new_day, color, font=font1)
        draw.text((480, 210), form.destination.data, color, font=font1)
        draw.text((120, 250), form.manager.data, color, font=font2)
        draw.text((440, 250), u"同意", color, font=font3)
        draw.text((520, 250), form.boss.data, color, font=font3)

        img.save(os.path.join(STATIC_DIR, "test.jpg"))
        #add time to prevent browser cache result
        return render_template('index.html',
                               form=form,
                               image_name='test.jpg',
                               time=datetime.datetime.now())
    return render_template('index.html', form=form, image_name='template.jpg')
Example #6
0
def choose():
    form_date = TableForm()
    return render_template('choose.html', title='choose', formdate=form_date)
Example #7
0
def account():
    tables = DB.get_tables(current_user.get_id())
    return render_template("account.html",
                           tables=tables,
                           tableform=TableForm())