def admin(): args = request.args title = 'administration' if not args: link = UL(*[LI(A(tab,_href=URL(args=tab))) for tab in db.tables]) return dict(items=link,title=title) if not args(1): i = 0 else: i =1 for tab in db.tables: if tab==args(i): tb = db[tab] crud = Crud(db) if args(0)=='edit': form = crud.update(tb, args(2),next=URL(f='admin',args=args(1))) items = None title = 'Edit %s ' % args(i) else: form = crud.create(tb) rows = db().select(tb.ALL) items = SQLTABLE(rows,linkto='edit') title = 'Insert %s ' % args(i) return dict(form=form,items=items,title=title)
def update_attendance(): crud = Crud(globals(), db) db.attendance.patient.default = request.args(0) db.attendance.patient.writable = db.attendance.patient.readable = False db.attendance.treatment.default = request.args(1) db.attendance.treatment.writable = db.attendance.treatment.readable = False form = crud.update(db.attendance, request.args(0), labels={ #'patient':'Paciente', #'treatment':'Tratamento', 'care_date':'Data de atendimento', 'pa_start':'PA Inicial', 'spo2_start':'SPO2 Inicial', 'bpm_start':'BPM Inicial', 'pa_end':'PA Final', 'spo_end':'SPO2 Final', 'bpm_end':'BPM Final', 'patient_owner':'Fisioterapeuta', 'conduct':'Conduta', 'notes':'Observações:' } ) return dict(title='Atualizar tratamento', form=form)
def update_person(): crud = Crud(globals(), db) form = crud.update(db.person, request.args(0), labels={'name':'Nome Completo', 'born':'Data de Nascimento', 'address':'Endereço', 'phone':'Telefone', 'mobile':'Celular', 'other_phone':'Telefone (outro)', 'doc_type':'Tipo de Documento', 'doc_id':'Número do documento', 'type_person':'Tipo Cadastro', 'health_care':'Plano de Saúde', 'doctor':'Médico ', 'doctor_doc':'CRM do Médico', 'name_responsable':'[Responsável] Nome', 'born_responsable':'[Responsável] Data Nascimento', 'phone_responsable':'[Responsável] Telefone', 'mobile_responsable':'[Responsável] Celular', 'email_responsable':'[Responsável] E-mail', 'address_responsable':'[Responsável] Endereço', 'doc_type_responsable':'[Responsável] Tipo documento (N/A se no existir responsável)', 'doc_id_responsable':'[Responsável] Número documento', 'notes':'Anotacoes diversas'} ) return dict(title="Atualizar cadastro", form=form)
def update(): index = request.args(0) report = db.reports(index) if(not report): redirect(URL('default' , 'index')) #if(report.created_by != auth.user_id): #redirect(URL('default' , 'index')) #Initialize the widget add_option = SelectOrAdd(form_title="Add new Category", controller="reports", function="add_category", button_text = "Add New") #assign widget to field db.reports.category.widget = add_option.widget from gluon.tools import Crud crud = Crud(db) form = crud.update(db.reports, report) form.add_button('Delete', URL('delete' , args=request.args) ) if form.process().accepted: report = db.reports(index) if(not report): redirect(URL('default' , 'index')) response.flash = 'form accepted' elif form.errors: response.flash = 'form has errors' return dict(form=form, report=report)
def messages(): db = current.db auth = current.auth request = current.request crud = Crud(db) crud.settings.formstyle = 'table3cols' crud.settings.keepvalues = True crud.messages.submit_button = '送信' crud.messages.delete_label = '削除する' crud.messages.record_created = 'メッセージを作成しました' crud.messages.record_updated = 'メッセージを更新しました' crud.messages.record_deleted = '削除しました' crud.messages.create_log = 'Message Record %(id)s created' crud.messages.update_log = 'Message Record %(id)s updated' crud.settings.create_next = URL('messages') crud.settings.download_url = URL('download') crud.settings.create_onaccept = give_create_message_permission crud.settings.update_ondelete = remove_message_permission button = A(BUTTON('リストへ戻る'), _href=URL('messages')) db.messages.to_group.represent = show_to_group db.messages.to_group.requires = IS_IN_SET(get_to_group_list(), zero=None) db.messages.created_by.label = '作成者' db.messages.created_by.readable = True if (request.args(0) == 'read'): crud.settings.auth = auth if auth.has_permission('update', db.messages, request.args(1)): button += A(BUTTON('編集する'), _href=URL('messages/update', request.args(1))) return dict(form=crud.read(db.messages, request.args(1)), button=button) if (request.args(0) == 'new'): return dict(form=crud.create(db.messages), button=button) if (request.args(0) == 'update'): crud.settings.auth = auth db.messages.to_group.writable = False return dict(form=crud.update(db.messages, request.args(1), deletable=True), button=button) query = auth.accessible_query('read', db.messages, auth.user.id) db.messages.title.represent = lambda title, row: A( title, _href=URL(args=('read', row.id))) db.messages.id.represent = lambda id, row: '' form = crud.select(db.messages, query=query, fields=['title', 'created_by', 'modified_on', 'id'], orderby=~db.messages.modified_on, headers={ 'messages.title': '件名', 'messages.created_by': db.messages.created_by.label, 'messages.modified_on': '更新時刻', 'messages.id': '' }) return dict(form=form, button=A(BUTTON('新規作成'), _href=URL('messages/new')))
def crud(): tablename = request.args(0) action = request.args(1) event_id = request.get_vars['eid'] record_id = request.get_vars['id'] if session.crud and session.crud.return_page: return_page = URL(session.crud.return_page) else: return_page = URL('table/' + tablename) crud = Crud(shotdb) crud.settings.auth = auth # ensures access control via permissions crud.settings.controller = 'staff' crud.settings.create_next = return_page crud.settings.update_next = return_page crud.settings.update_deletable = True crud.settings.showid = True if session.crud and session.crud.fix_ref_id: for ref_table, ref_id in session.crud.fix_ref_id.iteritems(): if ref_id > 0 and ref_table in shotdb[tablename]: shotdb[tablename][ref_table].default = ref_id shotdb[tablename][ref_table].writable = False # add event filter to drop down selectors if event_id != None and event_id > 0: if tablename == 'help': shotdb.help.shift.requires = IS_IN_DB(shotdb(shotdb.shift.event == event_id), 'shift.id', '%(activity)s, %(day)s, %(time)s') elif tablename == 'bring': shotdb.bring.donation.requires = IS_IN_DB(shotdb(shotdb.donation.event == event_id), 'donation.id', '%(item)s') if tablename == 'person': crud.settings.create_onvalidation = __create_person_onvalidation crud.settings.update_onvalidation = __update_person_onvalidation crud.settings.update_onaccept = __update_person_onaccept crud.settings.update_ondelete = __update_person_ondelete shotdb.person.code.writable = False shotdb.person.verified.writable = False crud.messages.record_created = None else: # default flash messages crud.messages.record_created = None crud.messages.record_updated = None crud.messages.record_deleted = 'Der Datenbankeintrag wurde gelöscht.' if(action == 'add'): crud_response = crud.create(tablename) elif(action == 'edit' and record_id != None): crud_response = crud.update(tablename, record_id) else: crud_response = 'Nothing selected!' return dict(crud_response = crud_response)
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 update_treatment(): crud = Crud(globals(), db) db.treatment.patient.writable = db.treatment.patient.readable = False form = crud.update(db.treatment, request.args(0), labels={ #'patient':'Paciente', 'treatment':'Tratamento', 'diagnosis':'Diagnóstico', 'pathologies':'Patologias', 'medications':'Medicamentos', 'start_date':'Data início', } ) return dict(title="Atualizar tratamento", form=form)
def update_profile(): from gluon.tools import Crud crud=Crud(db) x=auth.user.email table=db(db.Profile_for_others_to_see).select() for i in table: if x==i.e_mail: y=i.id break name=auth.user.first_name+" "+auth.user.last_name db.Profile_for_others_to_see.student_name.default=name db.Profile_for_others_to_see.student_name.writable=False update=crud.update(db.Profile_for_others_to_see,y) return locals()
def zuoye(): zuozhe=auth.user_id keshi_id=request.args[0] crud=Crud(db) if db.zuoye((db.zuoye.zuozhe==zuozhe)&(db.zuoye.keshi==keshi_id)): db.zuoye.defen.writable=False zuoye_id=db.zuoye((db.zuoye.zuozhe==zuozhe)&(db.zuoye.keshi==keshi_id)).id form=crud.update(db.zuoye,zuoye_id,deletable=False,next=request.url) db.zuoye.defen.writable=True else: db.zuoye.zuozhe.default=zuozhe db.zuoye.keshi.default=keshi_id db.zuoye.defen.writable=False form=crud.create(db.zuoye,next=request.url) # db.zuoye.zuozhe.default=None db.zuoye.keshi.default=None db.zuoye.defen.writable=True return dict(form=form)
def zuoye(): zuozhe=auth.user_id keshi_id=request.args[0] crud=Crud(db) if db.zuoye((db.zuoye.zuozhe==zuozhe)&(db.zuoye.keshi==keshi_id)): db.zuoye.defen.writable=False zuoye_id=db.zuoye((db.zuoye.zuozhe==zuozhe)&(db.zuoye.keshi==keshi_id)).id form=crud.update(db.zuoye,zuoye_id,deletable=False,next=request.url) db.zuoye.defen.writable=True else: db.zuoye.zuozhe.default=zuozhe db.zuoye.keshi.default=keshi_id db.zuoye.defen.writable=False form=crud.create(db.zuoye,next=request.url) # db.zuoye.zuozhe.default=None db.zuoye.keshi.default=None db.zuoye.defen.writable=True return dict(form=form)
def crudeGeral(): from gluon.tools import Crud crud = Crud(db) form = crud.create(db.client) id=1 form2 = crud.read(db.client, id) form3 = crud.update(db.client, id) form4 = crud.search(db.client) #form5 = SQLFORM(db.client, myrecord).process(onsuccess=auth.archive) #form5 = crud.update(db.mytable, myrecord, onaccept=auth.archive) return dict(form=form,form2=form2,form3=form3,form4=form4)
def crud(): tablename = request.args(0) action = request.args(1) record_id = request.get_vars['id'] crud_ = Crud(shotdb) crud_.settings.controller = 'config' crud_.settings.create_next = URL('config_event') crud_.settings.update_next = URL('config_event') crud_.settings.update_deletable = False crud_.settings.showid = True if(action == 'add'): crud_response = crud_.create(tablename) elif(action == 'edit' and record_id != None): crud_response = crud_.update(tablename, record_id) else: crud_response = 'Nothing selected!' return dict(crud_response = crud_response)
def crud(): tablename = request.args(0) action = request.args(1) id_ = request.args(2) if session.crud and session.crud.return_page: return_page = session.crud.return_page else: return_page = URL('admin_', 'manage_users') crud = Crud(shotdb) crud.settings.controller = 'admin_' crud.settings.create_next = return_page crud.settings.update_next = return_page crud.settings.update_deletable = True crud.settings.showid = True if(action == 'add'): crud_response = crud.create(tablename) elif(action == 'edit' and id_ != None): onaccept = None if tablename == 'auth_user': shotdb['auth_user']['registration_key'].writable = True elif tablename == 'config': crud.settings.update_deletable = False shotdb['config']['name'].writable = False # update the configuration object, drop the passed argument form onaccept = lambda form: config.update(shotdb) crud_response = crud.update(tablename, id_, onaccept = onaccept) else: crud_response = 'Nothing selected!' return dict(crud_response = crud_response)
def update(): index = request.args(0) report = db.reports(index) if(not report): redirect(URL('default' , 'index')) #if(report.created_by != auth.user_id): #redirect(URL('default' , 'index')) from gluon.tools import Crud crud = Crud(db) form = crud.update(db.reports, report) form.add_button('Delete', URL('delete' , args=request.args) ) if form.process().accepted: report = db.reports(index) if(not report): redirect(URL('default' , 'index')) response.flash = 'form accepted' elif form.errors: response.flash = 'form has errors' return dict(form=form, report=report)
def editpage(): this_page = db.page(request.args(0,cast=int)) or redirect(URL('index')) from gluon.tools import Crud crud = Crud(db) form = crud.update(db.page, this_page.id) if auth.user else None return dict(form=form)
def editcomment(): this_comment = db.comment(request.args(0,cast=int)) or redirect(URL('index')) from gluon.tools import Crud crud = Crud(db) form = crud.update(db.comment, this_comment.id) if auth.user else None return dict(form=form)
def update_test(): from gluon.tools import Crud crud = Crud(db) return dict(form=crud.update(db.balise, request.args(0)))