def GET(self): id = web.input(id=None).id if id.isdigit(): novel_info = self.db.get_novel_info(id, cache=False) novel_info.update(tag=";".join(self.db.get_tags_by_id(id))) form = novel_form() form.fill(novel_info) return render_to_response("admin/edit_novel", {"form": form, "id": id})
def GET(self, id): clip = model.get_clip(int(id), getuser()) if clip: form = index.form() form.fill(clip) return render.edit(clip, form) else: raise web.seeother('/')
def GET(self): id = int(web.ctx.session.user_id) data = user_model.get_user(id, what='id, username, email') if data is None: raise web.notfound() else: form = profile_form() form.fill(data) return render.user_profile(form)
def GET(self): form = novel_form() args = web.input(_method="get", rid=None) if args.rid: info = self.db.get_recommend_info(args.rid) info.update(update_interval=10) form.fill(info) return render_to_response("admin/add_novel", { "form": form, })
def GET(self, id): id = int(id) data = user_model.get_user(id, what='id, username, email, status') if data is None: session.set_flash('没有找到该用户', 'error') raise web.seeother('/user') else: form = user_form() form.fill(data) return render.user_edit(form, id)
def GET(self): id = web.input(id=None).id if id.isdigit(): novel_info = self.db.get_novel_info(id, cache=False) novel_info.update(tag=";".join(self.db.get_tags_by_id(id))) form = novel_form() form.fill(novel_info) return render_to_response("admin/edit_novel", { "form": form, "id": id })
def GET(self, nid): page = self.page node = mod.node.load(nid, raw = True) if node is None: pagenotfound() else: self._checkaccess(node) form = _form_node(node.type, page.user.roles.keys()) form.fill(node) content = '<form method="post">' content += form.render() content += '<button type="submit" value="Edit">Submit</button>' content +='</form>' web.render('generic.html')
def GET(self): search_results = [] search_term = '' entry_id = 0 form = search_form() try: search_term = web.input().phrase form.fill({'phrase':search_term}) search_results = search(prep_phrase(search_term)) except: pass bib_results = map(dict2bibstr,search_results) result_ids = map(lambda x:x['id'],search_results) search_results = zip(bib_results,result_ids) print search_results return render.index(form,search_results)
def GET(self): search_results = [] search_term = '' entry_id = 0 form = search_form() try: search_term = web.input().phrase form.fill({'phrase': search_term}) search_results = search(prep_phrase(search_term)) except: pass bib_results = map(dict2bibstr, search_results) result_ids = map(lambda x: x['id'], search_results) search_results = zip(bib_results, result_ids) print search_results return render.index(form, search_results)
def GET(self, id): post = post_model.get_post(int(id), status=None) if not post: raise web.notfound() categories = post['categories'] tags = post['tags'] if categories: post['category_ids'] = [category['id'] for category in categories] if tags: post['tags'] = ','.join([tag['name'] for tag in tags]) else: post['tags'] = '' form = post_form() form.fill(post) return render.post_edit(form)
def GET(self, id): post = model.get_post(int(id)) form = New.form() form.fill(post) return render.edit(post, form)
def POST(self): userData = web.input() ctx = web.ctx myuri = ctx.realhome form = self.reloadMyForm() form.fill() if id_btn_save in userData: #get all the values and update r = True msg = "" r, msg = self.validate_form(form) if not r: writeMessage(msg) raise web.seeother('/') cm.setValue("cangrid_port", str(form[id_grid_port].value)) cm.setValue("loglevel", str(form[id_loglevel].value)) cm.setValue(id_create_logfile, str(form[id_create_logfile].checked)) cm.setValue(id_logappend, str(form[id_logappend].checked)) cm.setValue("canid", str(form[id_canid].value)) cm.setValue(id_start_event_id, str(form[id_start_event_id].value)) cm.saveFile() writeMessage("Save successful") raise web.seeother('/') if id_btn_update_file in userData: print("Upgrade button pressed") writeMessage("") raise web.seeother('/upload') if id_btn_restart in userData: print("Restart button pressed") writeMessage("") os.system("/etc/init.d/start_canpi.sh restartcanpi") exitcode, out, err = self.get_exitcode_stdout_stderr("ps -ef") msg = "" if "/home/pi/canpiserver/canpiserver" in out: msg = "Service restarted" else: msg = "Restart failed" return render.index(form, "Canpiserver Configuration", msg) if id_btn_stop in userData: print("Stop button pressed") writeMessage("") os.system("/etc/init.d/start_canpi.sh stopcanpi") exitcode, out, err = self.get_exitcode_stdout_stderr("ps -ef") msg = "" if "/home/pi/canpiserver/canpiserver" in out: msg = "Stop failed" else: msg = "Stop successfull" return render.index(form, "Canpiserver Configuration", msg) if id_btn_restart_all in userData: print("Restart all button pressed") writeMessage("") cpid = os.fork() if cpid == 0: restartAll() return render.reboot("Restarting the webpage and canpiserver", myuri) return render.index(form, "Canpiserver Configuration", "")
def POST(self): userData = web.input() ctx=web.ctx myuri = ctx.realhome form = self.reloadMyForm() form.fill() if id_btn_save in userData: #get all the values and update r = True msg = "" r,msg = self.validate_form(form) if not r: writeMessage(msg) raise web.seeother('/') cm.setValue("ap_mode", str(form[id_apmode].checked)) cm.setValue("ap_no_password", str(form[id_apmode_no_passwd].checked)) cm.setValue("ap_ssid", str(form[id_ssid].value)) cm.setValue("ap_password", str(form[id_password].value)) cm.setValue("ap_channel", str(form[id_channel].value)) cm.setValue("router_ssid", str(form[id_router_ssid].value)) cm.setValue("router_password", str(form[id_router_password].value)) cm.setValue("can_grid", str(form[id_grid_enable].checked)) cm.setValue(id_edserver, str(form[id_edserver].checked)) cm.setValue("cangrid_port", str(form[id_grid_port].value)) cm.setValue("service_name", str(form[id_bonjour_name].value)) cm.setValue("tcpport", str(form[id_ed_tcpport].value)) cm.setValue("loglevel", str(form[id_loglevel].value)) cm.setValue(id_create_logfile, str(form[id_create_logfile].checked)) cm.setValue(id_logappend, str(form[id_logappend].checked)) cm.setValue("canid", str(form[id_canid].value)) cm.setValue("fn_momentary", str(form[id_fns_momentary].value)) cm.setValue("turnout_file", str(form[id_turnout_file].value)) cm.setValue(id_start_event_id, str(form[id_start_event_id].value)) cm.setValue(id_orphan_timeout, str(form[id_orphan_timeout].value)) cm.setValue(id_shutdown_code, str(form[id_shutdown_code].value)) cm.saveFile() writeMessage("Save successful") raise web.seeother('/') if id_btn_apply in userData: print("Apply button pressed") writeMessage("") cpid = os.fork() if cpid == 0: configurePi() return render.reboot("Applying changes and rebooting",myuri) if id_btn_update_file in userData: print("Upgrade button pressed") writeMessage("") raise web.seeother('/upload') if id_btn_restart in userData: print("Restart button pressed") writeMessage("") os.system("/etc/init.d/start_canpi.sh restartcanpi") exitcode,out,err = self.get_exitcode_stdout_stderr("ps -ef") msg="" if "/home/pi/canpi/canpi" in out: msg="Service restarted" else: msg="Restart failed" return render.index(form,"Canpi Configuration",msg) if id_btn_stop in userData: print("Stop button pressed") writeMessage("") os.system("/etc/init.d/start_canpi.sh stopcanpi") exitcode,out,err = self.get_exitcode_stdout_stderr("ps -ef") msg="" if "/home/pi/canpi/canpi" in out: msg="Stop failed" else: msg="Stop successfull" return render.index(form,"Canpi Configuration",msg) if id_btn_restart_all in userData: print("Restart all button pressed") writeMessage("") cpid = os.fork() if cpid == 0: restartAll() return render.reboot("Restarting the webpage and canpi",myuri) if id_btn_shutdown in userData: print("Shutdown button pressed") writeMessage("") cpid = os.fork() if cpid == 0: shutdownPi() return render.reboot("Shuting down the pi",myuri) return render.index(form,"Canpi Configuration","")
def GET(self): title = web.input(title='').title form = self.wiki_form() form.fill({'title':title}) return render.new(form=form)
def GET(self, id): post = model.post(int(id)) form = Post_Create.form() form.fill(post) return render.post_update(post, form)