def hoi_dap(): forlder_id = cms.get_folder(request.args(0)) hoi_dap = cms.define_table(tablename ='hoi_dap',migrate=True) hoi_dap.folder.writable=False hoi_dap.folder.readable=False hoi_dap.folder.default=forlder_id hoi_dap.avatar.writable=False hoi_dap.avatar.readable=False hoi_dap.avatar.default=' ' hoi_dap.htmlcontent.writable=False hoi_dap.htmlcontent.readable=False from gluon.tools import Recaptcha public_key='6LdtT_YSAAAAALCH4vbHKl1yjqvhB80JZh1J21Lv' private_key='6LdtT_YSAAAAAI6XnBMNNWwSkJeSYtbP_-kW5HUH' ### provided by recaptcha.net from gluon.tools import Crud crud = Crud(cms.db) crud.settings.captcha = Recaptcha(request,public_key,private_key,options = "lang:'en', theme:'clean'") form=crud.create(hoi_dap) # form[0].insert(-1, TR('', Recaptcha(request,public_key,private_key,options = "lang:'en', theme:'clean'"))) if form.process().accepted: from plugin_process import ProcessModel process = ProcessModel() objects = process.define_objects(True) log = process.define_process_log(True) objects_id =objects.insert(folder=forlder_id ,tablename='hoi_dap',table_id=form.vars.id ,process=2) log.insert(objects=objects_id, process=2) response.flash=T('done!') # scr ='''<script type="text/javascript"> # setInterval("location.reload();",1000); # </script>''' # form.append(XML(scr)) # if form.errors: # response.flash=T('Loi nhap du lieu!') # scr ='''<script type="text/javascript"> # setInterval("location.reload();",1000); # </script>''' # form.append(XML(scr)) div = DIV(_id='hoi_dap') div.append(DIV(H2('Nhập câu hỏi',_class="title_box"),_class="tinlienquan")) div.append(form) response.view = 'layout/hoi_dap_13.html' return dict(content=div)
def add_gian_hang_admin(): template = 'gian_hang.html' if request.vars.template: if request.vars.template == 't1': template = 'gian_hang1.html' elif request.vars.template == 't2': template = 'gian_hang.html' else: template = 'gian_hang2.html' name = request.vars.ten_gian_hang name = name.replace('đ', 'd') name = '%s' % IS_SLUG.urlify(name) folder = cms.define_folder() id = db.folder.insert(parent=241, name=name, label=request.vars.ten_gian_hang, setting="{'TABLES':['tintuc','cong_ty','san_pham']}", layout=template, created_by=auth.user_id) try: from plugin_process import ProcessModel processmodel = ProcessModel() if id: cong_ty = cms.define_table('cong_ty') link = (request.vars.ten_gian_hang).replace('đ', 'd') link = '%s.html' % IS_SLUG.urlify(link) ct_id = db.cong_ty.insert(name=request.vars.ten_gian_hang, link=link, folder=id) if ct_id: objects = processmodel.define_objects() objects_id = objects.insert(folder=id, foldername=name, tablename='cong_ty', table_id=ct_id, auth_group=8, process=3) dcontent = cms.define_dcontent() dcontent.insert(folder=id, dtable='cong_ty', table_id=ct_id, link=link, name=request.vars.ten_gian_hang, publish_on=request.now, expired_on=None) except Exception, e: return e