示例#1
0
文件: whos.py 项目: lbjay/mongogut
 def changeOwnershipOfLibrary(self, currentuser, fqln, newowner, groupmode=False):
     libq=Library.objects(basic__fqin=fqln)
     if groupmode:
         try:
             groupq=Group.objects(basic__fqin=newowner)
             group=groupq.get()
             newowner=group.basic.fqin
         except:
             #make sure target exists.
             doabort('BAD_REQ', "No such group %s" % newowner)
         authorize_context_member(False, self, currentuser, None, group)
     else:
         try:
             userq= User.objects(nick=newowner)
             newowner=userq.get().nick
         except:
             #make sure target exists.
             doabort('BAD_REQ', "No such user %s" % newowner)
     try:
         lib=libq.get()
     except:
         doabort('BAD_REQ', "No such group %s" % fqtn)
     authorize_context_owner(False, self, currentuser, None, lib)
     try:
         oldownernick=lib.owner
         if groupmode:
             lib.update(safe_update=True, set__owner = newowner, push__members=newowner)
         else:
             lib.update(safe_update=True, set__owner = newowner, push__members=newowner, pull__members=oldownernick)
     except:
         doabort('BAD_REQ', "Failed changing owner from %s to %s for lib %s" % (oldownernick, newowner, fqln))
     return newowner
示例#2
0
文件: whos.py 项目: adsabs/adsgut
 def getGroupInfo(self, currentuser, fullyQualifiedGroupName):
     grp=self.getGroup(currentuser, fullyQualifiedGroupName)
     #set useras to something not needed in cases where we dont really have useras
     #we use None as it wont match and currentuser being None is already taken care of
     authorize_context_member(False, self, currentuser, None, grp)
     # permit(self.isOwnerOfGroup(currentuser, grp) or self.isSystemUser(currentuser), "User %s must be owner of group %s or systemuser" % (currentuser.nick, grp.fqin))
     # permit(self.isMemberOfGroup(usertobenewowner, grp) or self.isSystemUser(usertobenewowner), " User %s must be member of grp %s or systemuser" % (currentuser.nick, grp.fqin))
     return grp.info()
示例#3
0
文件: whos.py 项目: adsabs/adsgut
 def usersInGroup(self, currentuser, fullyQualifiedGroupName):
     grp=self.getGroup(currentuser, fullyQualifiedGroupName)
     #print currentuser, grp, 'KKKKKK'
     #all members have access to member list as smaller context
     authorize_context_member(False, self, currentuser, None, grp)
     # permit(self.isMemberOfGroup(currentuser, grp) or self.isSystemUser(currentuser),
     #     "Only member of group %s or systemuser can get users" % grp.fqin)
     users=grp.groupusers
     return [e.info() for e in users]
示例#4
0
文件: whos.py 项目: adsabs/adsgut
 def removeGroupFromApp(self, currentuser, fullyQualifiedAppName, fullyQualifiedGroupName):
     app=self.getApp(currentuser, fullyQualifiedAppName)
     grp=self.getGroup(currentuser, fullyQualifiedGroupName)
     #permit(self.isOwnerOfGroup(currentuser, grp), "User %s must be owner of group %s" % (currentuser.nick, grp.fqin))
     #permit(self.isMemberOfApp(currentuser, app), "User %s must be member of app %s" % (currentuser.nick, app.fqin))
     authorize_context_owner(False, self, currentuser, None, grp)
     authorize_context_member(False, self, currentuser, None, app)
     try:
         grp.applicationsin.remove(app)
         #pubsub depending on what we want to do to delete
     except:
         doabort('BAD_REQ', "Failed removing group %s from app %s" % (grp.fqin, app.fqin))
     return OK
示例#5
0
文件: whos.py 项目: adsabs/adsgut
 def addGroupToApp(self, currentuser, fullyQualifiedAppName, fullyQualifiedGroupName, authspec):
     app=self.getApp(currentuser, fullyQualifiedAppName)
     grp=self.getGroup(currentuser, fullyQualifiedGroupName)
     #You must be owner of the group and member of the app
     #no useras stuff here?
     #permit(self.isOwnerOfGroup(currentuser, grp) or self.isSystemUser(currentuser), "User %s must be owner of group %s or systemuser" % (currentuser.nick, grp.fqin))
     #permit(self.isMemberOfApp(currentuser, app) or self.isSystemUser(currentuser), "User %s must be member of app %s or systemuser" % (currentuser.nick, app.fqin))
     authorize_context_owner(False, self, currentuser, None, grp)
     authorize_context_member(False, self, currentuser, None, app)
     try:
         grp.applicationsin.append(app)
         #pubsub must add the individual users. BUG is that how we want to do it?
     except:
         doabort('BAD_REQ', "Failed adding group %s to app %s" % (grp.fqin, app.fqin))
     return grp
示例#6
0
文件: whos.py 项目: lbjay/mongogut
 def changeOwnershipOfType(self, currentuser, fqtypen, typetype, newowner, groupmode=False):
     if typetype=="itemtype":
         typeo=ItemType
     elif typrtype=="tagtype":
         typeo=TagType
     typq=typeo.objects(basic__fqin=fqtypen)
     if groupmode:
         try:
             groupq=Group.objects(basic__fqin=newowner)
             group=groupq.get()
             newowner=group.basic.fqin
         except:
             #make sure target exists.
             doabort('BAD_REQ', "No such group %s" % newowner)
         authorize_context_member(False, self, currentuser, None, group)
     else:
         try:
             userq= User.objects(nick=newowner)
             newowner=userq.get().nick
         except:
             #make sure target exists.
             doabort('BAD_REQ', "No such user %s" % newowner)
     try:
         typ=typq.get()
     except:
         doabort('BAD_REQ', "No such group %s" % fqtypen)
     authorize_context_owner(False, self, currentuser, None, typ)
     try:
         oldownernick=typ.owner
         if groupmode:
             typ.update(safe_update=True, set__owner = newowner)
         else:
             typ.update(safe_update=True, set__owner = newowner)
     except:
         doabort('BAD_REQ', "Failed changing owner from %s to %s for type %s" % (oldownernick, newowner, fqtypen))
     return newowner
示例#7
0
文件: whos.py 项目: adsabs/adsgut
 def getAppInfo(self, currentuser, fullyQualifiedAppName):
     app=self.getApp(currentuser, fullyQualifiedAppName)
     authorize_context_member(False, self, currentuser, None, app)
     return app.info()
示例#8
0
文件: whos.py 项目: lbjay/mongogut
 def getAppInfo(self, currentuser, fqan):
     app=self.getApp(currentuser, fqan)
     authorize_context_member(False, self, currentuser, None, app)
     return app
示例#9
0
文件: whos.py 项目: lbjay/mongogut
 def usersInGroup(self, currentuser, fqgn):
     grp=self.getGroup(currentuser, fqgn)
     #all members have access to member list as smaller context
     authorize_context_member(False, self, currentuser, None, grp)
     users=grp.members
     return users
示例#10
0
文件: whos.py 项目: lbjay/mongogut
 def getLibraryInfo(self, currentuser, fqln):
     library=self.getLibrary(currentuser, fqln)
     authorize_context_member(False, self, currentuser, None, library)
     return library