示例#1
0
 def save(self):
     id = int(self.get_argument('id', 0))
     name = self.get_argument('name')
     pid = int(self.get_argument('parent_id', 0))
     parent = Orgnization.mgr().one(pid) if pid else None
     if not parent:
         pid, level = 0, 0
     else:
         level = parent.level + 1
     if id:
         o = Orgnization.mgr(ismaster=True).one(id)
     else:
         o = Orgnization.new()
     o.name, o.level, o.parent = name, level, pid
     try:
         o = o.save()
         self.json2dwz('200',
                       'closeCurrent',
                       'ulist',
                       forwardUrl='org/list')
     except Exception, e:
         self.json2dwz('300',
                       'closeCurrent',
                       'ulist',
                       forwardUrl='org/list',
                       msg=str(e))
示例#2
0
 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)
示例#3
0
 def list(self):
     id = int(self.get_argument('id', 0))
     name = self.get_argument('name', '')
     parent_id = int(self.get_argument('parent_id', 0))
     page = int(self.get_argument('pageNum', 1))
     psize = int(self.get_argument('numPerPage', 20))
     count = Orgnization.mgr().Q().count()
     page_count = (count + psize - 1) / psize
     q = Orgnization.mgr().Q()
     id and q.filter(id=id)
     name and q.filter(name=name)
     parent_id and q.filter(parent=parent_id)
     orgs = q[(page - 1) * psize:page * psize]
     for i in orgs:
         i.parent = Orgnization.mgr().one(i.parent)
     all_orgs = Orgnization.mgr().Q().data()
     self.render('user/org_list.html',
                 name=name,
                 parent_id=parent_id,
                 page=page,
                 psize=psize,
                 count=count,
                 page_count=page_count,
                 orgs=orgs,
                 all_orgs=all_orgs)
示例#4
0
 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)
示例#5
0
 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)
示例#6
0
 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)
示例#7
0
 def add(self):
     orgs = Orgnization.mgr().Q()
     all_roles = Role.mgr().Q().data()
     self.render('user/user_add.html',
                 orgs = orgs,
                 all_roles = all_roles)
示例#8
0
 def delete(self):
     oid = int(self.get_argument('id'))
     org = Orgnization.mgr(ismaster=1).one(oid)
     org.delete()
     self.json2dwz('200', 'forward', 'ulist', forwardUrl='org/list')
示例#9
0
 def edit(self):
     oid = int(self.get_argument('id'))
     org = Orgnization.mgr(ismaster=1).one(oid)
     orgs = Orgnization.mgr().Q().data()
     self.render('user/org_edit.html', org=org, orgs=orgs)
示例#10
0
 def add(self):
     orgs = Orgnization.mgr().Q().data()
     self.render('user/org_add.html', orgs=orgs)
示例#11
0
 def add(self):
     orgs = Orgnization.mgr().Q()
     all_roles = Role.mgr().Q().data()
     self.render('user/user_add.html', orgs=orgs, all_roles=all_roles)