本文整理汇总了Python中model.user.User.mgr方法的典型用法代码示例。如果您正苦于以下问题:Python User.mgr方法的具体用法?Python User.mgr怎么用?Python User.mgr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model.user.User
的用法示例。
在下文中一共展示了User.mgr方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import mgr [as 别名]
def list(self):
id = int(self.get_argument('id',0))
name = self.get_argument('name','')
orgid = int(self.get_argument('orgid',0))
page = int(self.get_argument('pageNum',1))
psize = int(self.get_argument('numPerPage',20))
count = User.mgr().Q().count()
page_count = (count+psize-1)/psize
q = User.mgr().Q()
id and q.filter(id=id)
name and q.extra("name LIKE '%%%s%%'"%name)
if orgid:
org = Orgnization.mgr().one(orgid)
q.extra("orgid in (%s)"%','.join([str(i.id) for i in org.children()]))
users = q[(page-1)*psize:page*psize]
for u in users:
u.full_org_name = '-'.join([o.name for o in u.org_path()])
orgs = Orgnization.mgr().Q()
self.render('user/user_list.html',
name = name,
orgid = orgid,
page = page,
psize=psize,
count=count,
page_count=page_count,
users=users,
orgs = orgs)
示例2: save
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import mgr [as 别名]
def save(self):
id = int(self.get_argument('id',0))
name = self.get_argument('name')
passwd = self.get_argument('password','')
is_root = int(self.get_argument('is_root',0))
is_staff = int(self.get_argument('is_staff',0))
orgid = int(self.get_argument('orgid',0))
email = self.get_argument('email','')
phone = self.get_argument('phone','')
args = self.request.arguments
role_ids = [self.get_argument(i,'') for i in self.request.arguments if i.startswith('role__')]
role_ids = [int(i) for i in role_ids if i]
print role_ids
if id:
u = User.mgr(ismaster=True).Q().filter(id=id)[0]
else:
u = User.new()
u.name,u.passwd,u.is_root,u.is_staff,u.orgid = name,passwd,is_root,is_staff,orgid
u.email,u.phone = email,phone
u = u.save()
id = u.id
cur_roles = [i.role_id for i in UserRole.mgr().Q().filter(uid=id)]
new_roles = [int(i) for i in role_ids]
for i in [i for i in cur_roles if i not in new_roles]:
ur = UserRole.mgr(ismaster=1).Q().filter(uid=id,role_id=i)[0]
ur and ur.delete()
for i in [i for i in new_roles if i not in cur_roles]:
ur = UserRole.new()
ur.uid,ur.role_id = id,i
ur.save()
self.json2dwz('200','closeCurrent','ulist',forwardUrl='user/list')
示例3: get_current_user
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import mgr [as 别名]
def get_current_user(self):
uinfo,u = self.session[SESSION_USER],None
if uinfo:
u = User.mgr().Q().filter(id=uinfo['uid'])[0]
if not u:
self._logout()
return u
示例4: edit
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import mgr [as 别名]
def edit(self):
uid = int(self.get_argument('id'))
user = User.mgr(ismaster=1).Q().filter(id=uid)[0]
orgs = Orgnization.mgr().Q()
cur_roles = [i.role_id for i in UserRole.mgr().Q().filter(uid=uid)]
all_roles = Role.mgr().Q().data()
self.render('user/user_edit.html',
orgs = orgs,
cur_roles = cur_roles,
all_roles = all_roles,
user=user)
示例5: merge_user_role_sql
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import mgr [as 别名]
def merge_user_role_sql():
ext = "id NOT IN (SELECT DISTINCT uid FROM user_role)"
users = User.mgr().Q().extra(ext)
print len(users)
if users:
for i in users:
role_name = i['name'].split('_')[0]+"acc数据查看"
role_id = Role.mgr().Q().filter(name=role_name)
if role_id:
sql = "insert into `logstatv3`.`user_role`(`id`,`uid`,`role_id`,`uptime`) values ( NULL,'%s','%s',CURRENT_TIMESTAMP);"%(i['id'],role_id[0]['id'])
print sql
else:
print "not merge",role_name
示例6: get_current_user
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import mgr [as 别名]
def get_current_user(self):
'''
when request from authsys
get user by auth api of authsys
'''
proxy_source = self.get_argument('x-proxy', '')
if proxy_source:
session_id = self.get_cookie('session_id')
u = self.service.auth.check_login(session_id)
else:
uinfo, u = self.session[SESSION_USER], None
if uinfo:
u = User.mgr().Q().filter(id=uinfo['uid'])[0]
if not u:
self._logout()
return u
示例7: passwd__save
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import mgr [as 别名]
def passwd__save(self):
old_passwd = self.get_argument('old_passwd')
new_passwd = self.get_argument('new_passwd')
msg = ''
if self.current_user:
u = User.mgr(ismaster=True).one(self.current_user.id)
if u and u.check_passwd(u.passwd,old_passwd):
u.passwd = new_passwd
u.save()
else:
msg = 'passwd wrong'
else:
msg = 'not logined'
if not msg:
self.json2dwz('200','closeCurrent','dlist',forwardUrl='user/list',msg=msg)
else:
self.json2dwz('300','closeCurrent','dlist',forwardUrl='user/list',msg=msg)
示例8: login
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import mgr [as 别名]
def login(self):
jump = self.get_argument('jump','/')
if self.request.method == 'GET':
if self.current_user:
self.redirect(jump)
return
self.render('user/login.html',jump=jump,error='')
else:
name = self.get_argument('name','')
passwd = self.get_argument('passwd','')
u = User.mgr().login(name,passwd)
print name,passwd,u
if not u:
self.render('user/login.html',jump=jump)
else:
self._login(u['id'])
self.redirect(jump)
示例9: delete
# 需要导入模块: from model.user import User [as 别名]
# 或者: from model.user.User import mgr [as 别名]
def delete(self):
uid = int(self.get_argument('id'))
user = User.mgr(ismaster=1).Q().filter(id=uid)[0]
user.delete()
self.json2dwz('200','forward','ulist',forwardUrl='user/list')