def get_form(self, product_name='okash', user_phases='new_user', table_name='table_describe'): data_path = 'templates/{}/{}/'.format(product_name, user_phases) assert os.path.exists(data_path), 'the path of "{}" is error'.format( data_path) table_list = [ i[:-5] for i in os.listdir(data_path) if i.startswith('df_') & i.endswith('.html') ] table_list.sort() sort_dict = {'rules': 10, 'apply': 20, 'loan': 30, 'history': 40} table_list.sort(key=lambda x: sort_dict.get(x.split('_')[1], 100)) form_submit = form.Form( form.Dropdown(name='product_name', args=['okash', 'opesa', 'mhela'], value=product_name), form.Dropdown(name='user_phases', args=['new_user', 'old_user'], value=user_phases), form.GroupedDropdown(name='table_name', args=(('INTRODUCTION', ['table_describe']), ('DATA INFO', table_list)), value=table_name), form.Button("Submit", value="submit", description="data_table")) return form_submit
def defineFormInputs(self, myform): myform.add_input( form.Dropdown("top", Dialog.option_dict['app_options'])) myform.add_input( form.Dropdown("series", Dialog.option_dict['series_options'])) myform.add_input( form.Dropdown("label", Dialog.option_dict['label_options'])) myform.add_input( form.Dropdown("command", Dialog.option_dict['cmd_options'])) myform.add_input(form.Textbox("commandArgument")) myform.add_input(form.Textbox("files")) #myform.add_input(form.Textbox("contents")) #myform.add_input(form.Dropdown("container", ['dialog', 'page', 'all'])) #myform.add_input(form.Checkbox('title', value="Y", checked=True)) myform.add_input( form.Checkbox('commandButton', value="Y", checked=True, disabled=True)) myform.add_input( form.Checkbox('otherComponent', value="Y", checked=False)) myform.add_input(form.Textbox("otherComponentName")) myform.add_input( form.Dropdown("processSize", [5, 10, 50, 100, 'All'], value='All'))
def ArticleUpdateForm(article, categoryDict): """ 文章更新表单""" updateForm = form.Form( form.Hidden("article_id", value=article.key().id()), form.Textbox("article_title", Validation['notnull'], description=u"标题:", value=article.title), form.Textarea("article_content", Validation['notnull'], description=u"内容:", value=article.content), form.Dropdown("article_display", args=[('1', '是'), ('0', '否')], description=u"显示:", value=article.display and "1" or "0"), form.Dropdown("article_commentEnable", args=[('1', '是'), ('0', '否')], description=u"允许评论:", value=article.display and "1" or "0"), form.Dropdown("article_category", args=categoryDict, description=u"分类:", value=article.category.key().id()), form.Button("article_submit", type="submit", html=u'提交'), ) return updateForm
def init_form(self, proj=None, date=None, page=None): years, latest = model.get_dates() if proj == None: search = form.Form( form.Dropdown('proj', config.PROJECTS, description=''), form.Dropdown('year', years, value=latest, description=''), form.Textbox('inputbox', form.notnull, id='ib1', description=''), form.Button('Top')) else: search = form.Form( form.Dropdown('proj', config.PROJECTS, value=proj, description=''), form.Dropdown('year', years, value=date, description=''), form.Textbox('inputbox', form.notnull, value=page, id='ib1', description=''), form.Button('Top')) return search
def defineFormInputs(self, myform): myform.add_input( form.Dropdown("top", Explore.option_dict['app_options'])) myform.add_input( form.Dropdown("series", Explore.option_dict['series_options'])) myform.add_input( form.Dropdown("label", Explore.option_dict['label_options'])) myform.add_input( form.Dropdown("command", Explore.option_dict['cmd_options'])) myform.add_input(form.Textbox("commandArgument")) myform.add_input(form.Textbox("files")) myform.add_input(form.Textbox("contents"))
def make_form(self, pin=None, boards=None): boards = boards or [] boards = [(x.id, x.name) for x in boards] if pin is None: return form.Form(form.Textbox('name'), form.Textarea('description'), form.Dropdown('board', boards), form.Button('repin'))() return form.Form(form.Textbox('name', value=pin.name), form.Textarea('description', value=pin.description), form.Dropdown('board', boards), form.Button('repin'))()
def defineFormInputs(self, myform): myform.add_input(form.Dropdown("top", Icon.option_dict['app_options'])) myform.add_input( form.Dropdown("series", Icon.option_dict['series_options'])) myform.add_input( form.Dropdown("label", Icon.option_dict['label_options'])) myform.add_input( form.Dropdown("command", Icon.option_dict['cmd_options'])) myform.add_input(form.Textbox("commandArgument")) myform.add_input(form.Textbox("files")) myform.add_input(form.Textbox("contents")) myform.add_input( form.Dropdown("processSize", [5, 10, 50, 100, 'All'], value='All'))
def test_dropdown_render(self): result1 = remove_optional_whitespace( form.Dropdown(name='foo', args=['a', 'b', 'c'], value='b').render()) correct1 = '<select class="form-control" id="foo" name="foo"><option value="a">a</option><option selected="selected" value="b">b</option><option value="c">c</option></select>' self.assertEqual(result1, correct1) result2 = remove_optional_whitespace( form.Dropdown(name='foo', args=[('a', 'aa'), ('b', 'bb'), ('c', 'cc')], value='b').render()) correct2 = '<select class="form-control" id="foo" name="foo"><option value="a">aa</option><option selected="selected" value="b">bb</option><option value="c">cc</option></select>' self.assertEqual(result2, correct2)
def defineFormInputs(self, myform): myform.add_input( form.Dropdown("tag_selection", ['All'] + sorted(self.prevForm_dict['tags'].split(',')))) myform.add_input( form.Dropdown("attribute_selection", ['All'] + sorted(self.prevForm_dict['attrs'].split(',')))) myform.add_input(form.Textbox("tag_name")) myform.add_input(form.Textbox("attribute_name")) myform.add_input(form.Textbox("attribute_value")) myform.add_input( form.Dropdown("processSize", [5, 10, 50, 100, 'All'], value='All'))
def __init__(self): self.currentForm = form.Form( form.Textbox("Course_Par"), form.Textbox("Your_Score", form.notnull, form.regexp('\d+', 'Must be a digit')), #form.Validator('Must be more than 5', lambda x:int(x)>5)), form.Checkbox('Pro'), form.Dropdown('Handicap: ', ['0-9', '10-19', '20-29', '30+']), form.Dropdown('Number of putts: ', ['< 25', '26-30', '31-35', '36+']), form.Dropdown('Number of fairways hit: ', ['< 5', '5-10', '> 10']), form.Dropdown('Number of par 3 greens hit: ', ['0', '1-2', ' > 2']), )
def GET(self): if web.ctx.session.login != 1: raise web.seeother('/#login') addCard = form.Form( form.Textbox('card_num', description='Card ID', class_='form-control'), form.Textbox('card_name', description='Name', class_='form-control'), form.Textbox('unit', description='Unit', class_='form-control'), form.Dropdown('type', [('S', 'Student'), ('T', 'Teacher')], description='Identity', class_='form-control'), form.Hidden("optype", value="add"), # form.Button('Create', class_ = "btn btn-primary") ) removeCard = form.Form( form.Textbox('card_num', description="Card ID", class_='form-control'), form.Hidden("optype", value="remove"), # form.Button("Submit", class_ = "btn btn-primary"), ) return render.managecard(addCard, removeCard, web.ctx.session)
def registration_form(self): return form.Form( form.Dropdown('college', [u'==请选择您所在学院=='] + CUMTSchoolList, form.Validator("select college.", lambda i: i in CUMTSchoolList), form.notnull, description=u"* 学院", class_="form-control"), form.Textbox('telephone', form.notnull, description=u"* 手机号码", class_="form-control"), mww.MyRadio('gender', [u'男', u'女'], form.notnull, description=u"* 性别"), form.Textbox('studentid', form.notnull, description=u'* 学号', class_="form-control"), form.Textbox('name', form.notnull, description=u'* 姓名', class_="form-control"), form.Button('submit', submit='submit', class_="btn btn-primary", html=u"保存修改"))
def BlogerUpdateForm(bloger): """ 博主信息更新的表单 """ newForm = form.Form( form.Textbox("bloger_nickname", Validation['notnull'], description=u"昵称:", value=bloger.nickname), form.Textbox("bloger_email", Validation['email'], description=u"邮箱:", value=bloger.email), form.Dropdown("bloger_sex", args=[('1', '男'), ('0', '女')], value=bloger.sex, description=u"性别:"), form.Textbox("bloger_avatar", Validation['url'], description=u"头像:", value=bloger.avatar), form.Textarea("bloger_description", Validation['notnull'], description=u"描述:", value=bloger.description), form.Button("bloger_submit", type="submit", html=u'提交'), ) return newForm
def make_form(self, boards=None): boards = boards or [] boards = [(x.id, x.name) for x in boards] return form.Form(form.Textbox('url', id='input-url'), form.Textarea('description', id='input-desc'), form.Dropdown('board', boards), form.Button('add', id='btn-add'))()
def getDynamicForm(self): dynamic_form = DynamicForm(form.Hidden('placeholder')) #for setting, dict in settings.settings.iteritems(): for setting, dict in sorted(settings.settings.iteritems(), key=lambda (x, y): y['formOrder']): if dict["formNullable"] == 'notnull': nullArg = "form.notnull" else: nullArg = () if dict["formType"] == 'textbox': dynamic_form.add_input( form.Textbox( dict["key"], description=dict[ "description"], #, form.regexp(dict["formRegexp"], dict["formRegexpMessage"]) value=dict["value"])) # , *nullArg elif dict["formType"] == 'radio': dynamic_form.add_input( form.Radio(dict["key"], args=dict["formDropdownValues"], description=dict["description"], value=dict["value"])) elif dict["formType"] == 'dropdown': dynamic_form.add_input( form.Dropdown(dict["key"], args=dict["formDropdownValues"], description=dict["description"], value=dict["value"])) return dynamic_form
def UserSelectForm(users): return form.Form( form.Dropdown('user', [(u.id, "{} {}".format(u.firstname, u.lastname)) for u in users], description="Utilisateur"), form.Button('Envoyer'), )
def user_search_form(self): return form.Form( form.Textbox('uid', class_="form-control"), form.Textbox('name', class_="form-control"), form.Textbox('email', class_="form-control"), form.Dropdown('country', ['All', 'China', 'Other'], class_="form-control"), form.Button('query', type='sbumit', class_="btn btn-primary"))
def AlonePageNewForm(): """ 页面新建表单 """ newForm = form.Form( form.Textbox("page_title", Validation['title'], description="标题:"), form.Textbox("page_link", Validation['link'], description="链接:"), form.Textarea("page_content", description="内容:"), form.Dropdown("page_display", args=[('1', '是'), ('0', '否')], value='1', description="显示:"), form.Dropdown("page_commentEnable", args=[('1', '是'), ('0', '否')], value='1', description="允许评论:"), form.Button("page_submit", type="submit", html=u'提交'), ) return newForm
def init_form(self, proj=None, date=None, page=None): years, latest = model.get_dates() years.reverse() if date == None: date = latest return form.Form( form.Dropdown('proj', config.PROJECTS, value=proj, description=''), form.Dropdown('year', years, value=date, description=''), form.Textbox('inputbox', form.notnull, value=page, id='ib1', description=''), form.Button('Go', type="submit", value="Go"), form.Button('Top'))
def reloadMyForm(self): apmode = True gridenable = True apmode_no_passwd = True create_logfile = True logappend = True if cm.getValueInsert(id_create_logfile, "True").lower() != "true": create_logfile = False if cm.getValueInsert(id_logappend, "True").lower() != "true": logappend = False myform = form.Form( form.Textbox(id_grid_port, description=desc_grid_port, value=cm.getValueInsert("cangrid_port", 4444), id="cangripport"), form.Textbox(id_canid, description=desc_canid, value=cm.getValueInsert("canid", 100)), form.Textbox(id_start_event_id, description=desc_start_event, value=cm.getValueInsert(id_start_event_id, 1)), form.Dropdown(id_loglevel, ['INFO', 'WARN', 'DEBUG'], value=cm.getValueInsert("loglevel", "INFO")), form.Checkbox(id_create_logfile, description=desc_create_logfile, checked=create_logfile, value=id_create_logfile, id="tcreate_logfile"), form.Checkbox(id_logappend, description=desc_logappend, checked=logappend, value=id_logappend, id="tlogappend"), form.Button(desc_btn_save, id=id_btn_save, value="save", html="Save changes"), form.Button(desc_btn_stop, id=id_btn_stop, value="stop", html="Stop throttle service"), form.Button(desc_btn_restart_all, id=id_btn_restart_all, value="stop", html="Restart throttle and configuration page"), form.Button(desc_btn_restart, id=id_btn_restart, value="restart", html="Restart throttle service"), form.Button(desc_btn_update_file, id=id_btn_update_file, value="upgrade", html="Upload upgrade file")) return myform()
def mergeform(): """In manual merges: create a web based UI for the merge html form. This will create the various selection boxes and input texts to allow the user to manually merge branches. Returns: A web.py form representation of the input fields in the manual merge page. """ aform = form.Form( form.Dropdown('merge_from', get_versions()), form.Dropdown('merge_to', get_versions()), form.Textbox('start_rev', form.notnull, post="Start revision to merge"), form.Textbox('end_rev', form.notnull, post="End revision to merge"), form.Textbox('svn_username', form.notnull, post="Your SVN username (we will commit with this)"), form.Password('svn_password', form.notnull, post="your SVN password")) return aform
def BlogUpdateForm(blog): """ 博客信息更新表单""" def getThemesDirDict(relativePath): themesDirDict = [] dirAbsPath = os.path.abspath(os.path.normpath(relativePath)) dirlist = os.listdir(dirAbsPath) for dir in dirlist: path = os.path.join(dirAbsPath, dir) if os.path.isdir(path): themesDirDict.append((dir, dir)) return themesDirDict newForm = form.Form( form.Textbox("blog_name", Validation['notnull'], description=u"名称:", value=blog.name), form.Textbox("blog_title", Validation['notnull'], description=u"标题:", value=blog.title), form.Textbox("blog_subtitle", Validation['notnull'], description=u"子标题:", value=blog.subtitle), form.Textbox("blog_host", Validation['host'], description=u"主机:", value=blog.host), form.Dropdown("blog_theme", args=getThemesDirDict('themes'), description=u"主题:", value=blog.theme), form.Textarea("blog_description", Validation['notnull'], description=u"描述:", value=blog.description), form.Textbox("blog_keywords", Validation['keywords'], description=u"关键字:", value=blog.keywords), form.Textarea("blog_announcement", description=u"公告:", value=blog.announcement), form.Textbox("blog_pageSize", Validation['number'], description=u"每页显示条数:", value=blog.pageSize), form.Textbox("blog_version", readonly="true", description=u"版本:", value=blog.version), form.Button("blog_submit", type="submit", html=u'提交'), ) return newForm
def AlonePageUpdateForm(alonePage): """ 页面更新表单""" updateForm = form.Form( form.Hidden("page_id", value=alonePage.id), form.Textbox("page_title", description="标题:", value=alonePage.title), form.Textbox("page_link", description="链接:", value=alonePage.link), form.Textarea("page_content", description="内容:", value=alonePage.content), form.Dropdown("page_display", args=[('1', '是'), ('0', '否')], description="显示:", value=alonePage.display and "1" or "0"), form.Dropdown("page_commentEnable", args=[('1', '是'), ('0', '否')], description="允许评论:", value=alonePage.commentEnable and "1" or "0"), form.Button("page_submit", type="submit", html=u'提交'), ) return updateForm
def article_select_form(self): return form.Form( form.Dropdown('article', sorted(map(lambda x:x.name,articles.get_all_articles())), form.notnull, form.Validator('This Article Not Exist!', lambda x:articles.name_exist_p(x)), description = "Article ", class_="form-control"), form.Button('submit',type='submit',class_="btn btn-primary") )
def del_article_form(self): return form.Form( form.Dropdown('name', sorted(map(lambda x:x.name,articles.get_all_articles())), form.notnull, form.Validator('This Article Not Exist!', lambda x:articles.name_exist_p(x)), description = "Delte Article Name:", class_="form-control"), form.Button('submit', submit='submit', value='Delete it!',class_="btn btn-primary") )
def validateform(): """In manual merges: create a web based UI for the merge html form. This will create the various selection boxes and input texts to allow the user to manually merge branches. Returns: A web.py form representation of the input fields in the manual merge page. """ aform = form.Form(form.Dropdown('Branch to validate', get_versions()), form.Textbox('SVN username', form.notnull), form.Password('SVN password', form.notnull)) return aform
def get_apply_form(): """ Get the form used to add users to an application and apply :return: A form object """ users = get_users() apply_form = form.Form( form.Dropdown("user_to_add", description="User", args=users), form.Button("add_user", type="submit", description="Add User", value="add_user", html="Add User"), form.Button("apply", type="submit", description="Apply", value="apply", html="Apply") ) return apply_form
def ArticleNewForm(categoryDict): """ 文章新建表单 """ newForm = form.Form( form.Textbox("article_title", Validation['notnull'], description=u"标题:"), form.Textarea("article_content", Validation['notnull'], description=u"内容:"), form.Dropdown("article_display", args=[('1', '是'), ('0', '否')], value='1', description=u"显示:"), form.Dropdown("article_commentEnable", args=[('1', '是'), ('0', '否')], value='1', description=u"允许评论:"), form.Dropdown("article_category", args=categoryDict, description=u"分类:"), form.Textbox("article_tags", description=u"标签:"), form.Button("article_submit", type="submit", html=u'提交'), ) return newForm
def get_form(self): form_submit = form.Form( form.Dropdown(name='from_product', args=['okash', 'opesa', 'mhela'], value=self.from_product), form.Dropdown(name='into_product', args=['okash', 'opesa', 'mhela'], value=self.into_product), form.Dropdown(name='risk_rules', args=['new', 'old'], value=self.risk_rules), form.Input(name='start_time', type="search", min='20170101000000', max='20250101000000', value=self.start_time), form.Input(name='end_time', type="search", min='20170101000000', max='20250101000000', value=self.end_time), form.Button("Submit", value="submit", description="data_table"), form.Button("Refresh", value="submit", description="data_table")) return form_submit
def form(self): return form.Form( form.Dropdown('referee_rating', ('', ('1', '* - Not recommended'), ('2', '** - Has reserve'), ('3', '*** - Average'), ('4', '**** - Strong applicant'), ('5', '***** - Outstanding')), form.notnull, description='How would you score this applicant?'), form.Textarea( 'reference', form.notnull, description= 'Please describe in less than 500 words why you recommmend this applicant.' ), form.Button('submit', type='submit', value='Submit reference'), )