def POST(self): #Authorization for this api is required try: curr_user = auth_ops.auth_admin_res() except Exception as e: raise web.notfound() try: #Get User data new_user = { "name": web.input(_method='post').name, "username":web.input(_method='post').username, "email":web.input(_method='post').email, "password":web.input(_method='post').password, "priv_lev":web.input(_method='post').priv_lev, "is_default":web.input(_method='post').deft } #get the results result, data = model.addUser(new_user) ret_obj = dict(r=result) ret_obj['data'] = data json_result = self.contents(ret_obj) return json_result except Exception as e: return str(e)
def GET(self): #Authorization for this resource is required try: curr_user = auth.auth_admin_res() except Exception as e: raise err.notfound() try: render = tmpl.render('menus_new') return render.display(web.ctx.lang) except Exception as e: raise StandardError(e)
def POST(self): #Authorization for this api is required try: curr_user = auth.auth_admin_res() except Exception as e: raise web.notfound() try: oid = web.input(_method='post').oid Module.objects(id=oid).delete() json_result = self.contents(dict(r="ok")) return json_result except Exception as e: raise web.notfound()
def POST(self): #Authorization for this api is required try: curr_user = auth_ops.auth_admin_res() except Exception as e: raise web.notfound() try: oid = web.input(_method='post').oid #get the results result, data = model.delUser(oid) ret_obj = dict(r=result) ret_obj['data'] = data json_result = self.contents(ret_obj) return json_result except Exception as e: raise web.notfound()
def GET(self): #Authorization for this resource is required try: curr_user = auth.auth_admin_res() except Exception as e: raise err.notfound() try: # menu_list = [] for menu in Menus.objects: new_menu = {} new_menu['id'] = serializers.SerializeObject(menu.id) new_menu['title'] = serializers.SerializeObject(menu.title) new_menu['descr'] = serializers.SerializeObject(menu.descr) new_menu['path'] = serializers.SerializeObject(menu.path) menu_list.append(new_menu) render = tmpl.render('menus_index') return render.display(web.ctx.lang, menu_list) except Exception as e: raise StandardError(e)
def GET(self, oid): #Authorization for this resource is required try: curr_user = auth.auth_admin_res() except Exception as e: raise err.notfound() try: # single_module = {} for module in Module.objects: if serializers.SerializeObject(module.id) == oid: single_module['id'] = serializers.SerializeObject(module.id) single_module['title'] = serializers.SerializeObject(module.title) single_module['contents'] = serializers.SerializeObject(module.contents) render = tmpl.render('modules_edit') return render.display(web.ctx.lang, single_module) except Exception as e: raise StandardError(e)
def GET(self): #Authorization for this resource is required try: curr_user = auth.auth_admin_res() except Exception as e: raise err.notfound() try: module_list = [] for module in Module.objects: new_mod = {} new_mod['id'] = serializers.SerializeObject(module.id) new_mod['title'] = serializers.SerializeObject(module.title) new_mod['contents'] = serializers.SerializeObject(module.contents) module_list.append(new_mod) render = tmpl.render('modules_index') return render.display(web.ctx.lang, module_list) except Exception as e: raise StandardError(e)
def POST(self): #Authorization for this api is required try: curr_user = auth.auth_admin_res() except Exception as e: raise web.notfound() try: n_title = web.input(_method='post').title n_descr = web.input(_method='post').descr n_path = web.input(_method='post').path #Add new menu Menus( title=n_title, descr=n_descr, path=n_path ).save(force_insert=True) json_result = self.contents(dict(r='ok')) return json_result except Exception as e: raise web.notfound()
def GET(self, oid): #Authorization for this resource is required try: curr_user = auth.auth_admin_res() except Exception as e: raise err.notfound() try: # single_menu = {} for menu in Menus.objects: if serializers.SerializeObject(menu.id) == oid: single_menu['id'] = serializers.SerializeObject(menu.id) single_menu['title'] = serializers.SerializeObject(menu.title) single_menu['descr'] = serializers.SerializeObject(menu.descr) single_menu['path'] = serializers.SerializeObject(menu.path) render = tmpl.render('menus_edit') return render.display(web.ctx.lang, single_menu) except Exception as e: raise StandardError(e)
def POST(self): #Authorization for this api is required try: curr_user = auth.auth_admin_res() except Exception as e: raise web.notfound() try: n_title = web.input(_method='post').title n_content = web.input(_method='post').content #Add new menu Module( title=n_title, contents=n_content ).save(force_insert=True) json_result = self.contents(dict(r='ok')) return json_result except Exception as e: return str(e)
def POST(self): #Authorization for this api is required try: curr_user = auth.auth_admin_res() except Exception as e: raise web.notfound() try: oid = web.input(_method='post').oid n_title = web.input(_method='post').title n_content = web.input(_method='post').content #Update Query Module.objects(id=oid).update( set__title = n_title, set__contents = n_content ) json_result = self.contents(dict(r='ok')) return json_result except Exception as e: raise StandardError(e)
def GET(self): #Authorization for this resource is required try: curr_user = auth.auth_admin_res() except Exception as e: raise err.notfound() try: # users_list = [] for user in Users.objects: user_obj = {} user_obj['id'] = serializers.SerializeObject(user.id) user_obj['name'] = serializers.SerializeObject(user.name) user_obj['username'] = serializers.SerializeObject(user.username) user_obj['email'] = serializers.SerializeObject(user.email) user_obj['priv_lev'] = serializers.SerializeObject(user.priv_lev) user_obj['is_default'] = serializers.SerializeObject(user.isdefault) users_list.append(user_obj) render = tmpl.render('users_index') return render.display(web.ctx.lang, users_list) except Exception as e: raise StandardError(e)
def POST(self): #Authorization for this api is required try: curr_user = auth.auth_admin_res() except Exception as e: raise web.notfound() try: oid = web.input(_method='post').oid n_title = web.input(_method='post').title n_descr = web.input(_method='post').descr n_path = web.input(_method='post').path #Update Query Menus.objects(id=oid).update( set__title = n_title, set__descr = n_descr, set__path = n_path ) json_result = self.contents(dict(r='ok')) return json_result except Exception as e: raise web.notfound()
def GET(self, oid): #Authorization for this resource is required try: curr_user = auth.auth_admin_res() except Exception as e: raise err.notfound() try: # single_user = {} user = Users.objects.get(id=oid) single_user['id'] = serializers.SerializeObject(user.id) single_user['name'] = serializers.SerializeObject(user.name) single_user['username'] = serializers.SerializeObject(user.username) single_user['email'] = serializers.SerializeObject(user.email) single_user['priv_lev'] = serializers.SerializeObject(user.priv_lev) single_user['is_default'] = serializers.SerializeObject(user.isdefault) drop_box = [ { 'key':2,'value':'Super Administrator' }, { 'key':1,'value':'Administrator' }, { 'key':0,'value':'User' } ] render = tmpl.render('users_edit') return render.display(web.ctx.lang, single_user, drop_box) except Exception as e: raise StandardError(e)
def GET(self): try: the_user = auth_ops.auth_admin_res() return self.contents(the_user) except Exception as e: return str(e)