def tao_tin_tim_mua(): from plugin_ckeditor import CKEditor table = cms.define_table('tintuc') for field in table.fields: if field == 'htmlcontent': table[field].label = 'Nội dung tìm mua' if field == 'folder': table[field].default = 248 table[field].readable=False table[field].writable=False row = db(db.dfield.name==field).select().first() if row: if row.ckeditor: table[field].widget=CKEditor(db).widget form=SQLFORM(table) if form.process().accepted: from plugin_process import ProcessModel objects = ProcessModel().define_objects() objects_id = objects.insert(folder=248,foldername='san-pham-tim-mua',tablename='tintuc',table_id=form.vars.id,auth_group=7,process=1) # link = form.vars.name.replace('đ','d') # link = '%s.html'%IS_SLUG.urlify(link) # dcontent = cms.define_dcontent() # dcontent.insert(folder=248,dtable='tintuc',table_id=form.vars.id,link=link,name=form.vars.name,avatar=form.vars.avatar,description=form.vars.description,publish_on=request.now,expired_on=None) # cms.db(tin_tuc_edit.id==form.vars.id).update(link=link) session.flash = T('Gửi thông tin tìm mua thành công') redirect(URL(c='portal',f='folder',args=['san-pham-tim-mua'])) response.view = 'layout/home_dang_tin-tim-mua.html' return dict(content=form)
def edit_cong_ty(): id_folder = request.args(1) name = request.args(0) from plugin_ckeditor import CKEditor div = DIV(_class='col-md-12') div.append( H2(SPAN('Khởi tạo gian hàng', _class='title_name'), _class='title_page')) cong_ty = cms.define_table('cong_ty') cong_ty_id = db(cong_ty.folder == folder_id_gian_hang).select().first() from gluon.tools import Crud crud = Crud(cms.db) cong_ty.folder.default = id_folder cong_ty.folder.writable = False cong_ty.folder.readable = False cong_ty.start_time.writable = False cong_ty.start_time.readable = False cong_ty.danh_gia.writable = False cong_ty.danh_gia.readable = False cong_ty.is_maps.writable = False cong_ty.is_maps.readable = False form = crud.update(cong_ty, cong_ty_id) if form.process().accepted: from plugin_process import ProcessModel objects = ProcessModel().define_objects() objects_id = objects.insert(folder=id_folder, foldername=name, tablename='cong_ty', table_id=form.vars.id, auth_group=8, process=3) link = name.replace('đ', 'd') link = '%s.html' % IS_SLUG.urlify(link) dcontent = cms.define_dcontent() dcontent.insert(folder=id_folder, dtable='cong_ty', table_id=form.vars.id, link=link, name=form.vars.name, avatar=form.vars.avatar, description=form.vars.description, publish_on=request.now, expired_on=None) cms.db(cong_ty.id == form.vars.id).update(link=link) redirect(URL(c='portal', f='folder', args=[name])) pass div.append(form)
def view_new(): tin_tuc_id = request.vars.tin_tuc_id div = DIV(_class='col-md-12') folder_id_ivinh = folder_id_gian_hang.id if auth.has_permission('quan_tri_gian_hang', 'folder', folder_id_ivinh): name = request.args(0) from plugin_ckeditor import CKEditor if not tin_tuc_id: div.append( H2(SPAN('Thêm mới tin tức', _class='title_name'), _id='title_page')) tin_tuc_edit = cms.define_table('tintuc') tin_tuc_edit.folder.default = folder_id_ivinh tin_tuc_edit.folder.writable = False tin_tuc_edit.folder.readable = False tin_tuc_edit.htmlcontent.widget = CKEditor(cms.db).widget form = SQLFORM(tin_tuc_edit, tin_tuc_id) if tin_tuc_id: ajax = "ajax('%s', [''], 'news_detail')" % (URL( c='plugin_app', f='act_delete', args=[request.args(0)], vars=dict(table_name='tintuc', table_id=tin_tuc_id))) form[0][-1] = TR(TD(INPUT(_type='submit', _value=T('Submit')), INPUT(_type='button', _value=T('Xóa bài viết'), _onclick=ajax, _class='btn btn-danger'), _colspan="3"), _class='act_ivinh') if form.process().accepted: dcontent = cms.define_dcontent() if not tin_tuc_id: from plugin_process import ProcessModel objects = ProcessModel().define_objects() objects_id = objects.insert(folder=folder_id_ivinh, foldername=name, tablename='tintuc', table_id=form.vars.id, auth_group=7, process=3) link = form.vars.name.replace('đ', 'd') link = '%s.html' % IS_SLUG.urlify(link) from plugin_cms import CmsPublish link = CmsPublish().get_link('tintuc', link) dcontent.insert(folder=folder_id_ivinh, dtable='tintuc', table_id=form.vars.id, link=link, name=form.vars.name, avatar=form.vars.avatar, description=form.vars.description, publish_on=request.now, expired_on=None) cms.db(tin_tuc_edit.id == form.vars.id).update(link=link) div.append(form) return dict(content=div)