本文整理汇总了Python中server.models.group.Group.read方法的典型用法代码示例。如果您正苦于以下问题:Python Group.read方法的具体用法?Python Group.read怎么用?Python Group.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类server.models.group.Group
的用法示例。
在下文中一共展示了Group.read方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update
# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
def update(self, fields, updateDbs=True):
from server.models.ssuser import SSUser
if fields.get("content"):
self.content = fields.get("content")
if fields.get("summary"):
self.summary = self.content["summary"] = fields.get("summary")
if fields.get("broken"):
self.broken = fields.get("broken")
if fields.get("dbs"):
self.dbs = list(set(self.dbs.extend(fields.get("dbs"))))
self.modified = datetime.now()
# update the correct user db
if self.publishData.private:
db = SSUser.privateDb(self.createdBy)
else:
db = SSUser.publicDb(self.createdBy)
self.store(core.connect(db))
core.replicate(db, "shiftspace/shared")
# update followers and groups
if updateDbs:
for db in self.publishData.dbs:
dbtype, dbid = db.split("/")
if dbtype == "group":
from server.models.group import Group
Group.read(dbid).updateShift(self)
return Shift.joinData(self, self.createdBy)
示例2: create
# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
def create(cls, userId, groupId, otherId, level):
from server.models.ssuser import SSUser
from server.models.group import Group
db = core.connect()
if not groupId:
raise MissingGroupError
if not userId:
raise MissingCreatorError
if Permission.readByUserAndGroup(otherId, groupId):
raise PermissionAlreadyExistsError
adminable = [row.value for row in Permission.by_adminable(db, key=userId).rows]
allowed = groupId in adminable
if not allowed:
theUser = SSUser.read(userId)
allowed = theUser.isAdmin()
if not allowed:
theGroup = Group.read(groupId)
allowed = theUser.isOwnerOf(theGroup)
if not allowed:
raise CreateEventPermissionError
json = {
"createdBy": userId,
"userId": otherId,
"groupId": groupId,
"level": level
}
newPermission = Permission(**utils.clean(json))
newPermission.store(db)
return newPermission
示例3: addToGroups
# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
def addToGroups(self, groupDbs):
from server.models.group import Group
# NOTE - do we need to delete from user/private? - David 11/12/09
for db in groupDbs:
dbtype, dbid = db.split("/")
theGroup = Group.read(dbid)
theGroup.addShift(self)
示例4: members
# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
def members(self, id):
from server.models.ssuser import SSUser
theGroup = Group.read(id)
loggedInUser = helper.getLoggedInUser()
theUser = SSUser.read(loggedInUser)
if theUser.isAdminOf(theGroup):
return data(theGroup.members())
else:
return error("You don't have permission to view this groups members", PermissionError)
示例5: join
# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
def join(self, id):
from server.models.ssuser import SSUser
theGroup = Group.read(id)
loggedInUser = helper.getLoggedInUser()
theUser = SSUser.read(loggedInUser)
if theUser.canJoin(theGroup):
theUser.join(theGroup)
return data(theGroup)
else:
return error("Operation not permitted. You don't have permission to join this group.", PermissionError)
示例6: makeAdmin
# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
def makeAdmin(self, id, userId):
from server.models.ssuser import SSUser
theGroup = Group.read(id)
theUser = SSUser.read(helper.getLoggedInUser())
if theUser.isAdminOf(theGroup):
otherUser = SSUser.read(userId)
theGroup.setPrivilege(otherUser, 3)
return ack
else:
return error("You don't have permission to promote members of this group to admin.", PermissionError)
示例7: inviteUsers
# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
def inviteUsers(self, id, users):
from server.models.ssuser import SSUser
loggedInUser = helper.getLoggedInUser()
groupAdmin = SSUser.read(loggedInUser)
theGroup = Group.read(id)
if groupAdmin.isAdminOf(theGroup):
db = core.connect()
users = SSUser.all(db, keys=json.loads(users))
for user in users:
groupAdmin.inviteUser(theGroup, user)
return data(theGroup)
else:
return error("Operation not permitted. You don't have permission to modify this group", PermissionError)
示例8: update
# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
def update(self, id):
from server.models.ssuser import SSUser
loggedInUser = helper.getLoggedInUser()
theUser = SSUser.read(loggedInUser)
theGroup = Group.read(id)
jsonData = helper.getRequestBody()
if jsonData != "":
if theUser.isAdminOf(theGroup):
groupData = json.loads(jsonData)
return data(theGroup.update(groupData))
else:
return error("You don't have permission to update this group", PermissionError)
else:
return error("No data for group.", NoDataError)
示例9: info
# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
def info(self, id):
from server.models.ssuser import SSUser
# TODO: bulk call - David 12/13/2009
theGroup = Group.read(id)
memberCount = theGroup.memberCount()
adminCount = theGroup.adminCount()
shiftCount = theGroup.shiftCount()
info = {
"memberCount": memberCount,
"adminCount": adminCount,
"shiftCount": shiftCount
}
theUser = SSUser.read(helper.getLoggedInUser())
info["isAdmin"] = theUser.isAdminOf(theGroup)
return data(info)
示例10: updateInGroups
# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
def updateInGroups(self, groupDbs):
from server.models.group import Group
for db in groupDbs:
dbtype, dbid = db.split("/")
theGroup = Group.read(dbid)
theGroup.updateShift(self)
示例11: read
# 需要导入模块: from server.models.group import Group [as 别名]
# 或者: from server.models.group.Group import read [as 别名]
def read(self, id):
# return only public groups
theGroup = Group.read(id)
return data(theGroup)