예제 #1
0
파일: user.py 프로젝트: ljxia/shiftserver
def delete(userName):
    """
    Delete a user.
    """
    db = core.connect()
    id = idForName(userName)
    # delete all the user's events
    userEvents = utils.ids(event.eventsForUser(id))
    for eventId in userEvents:
        del db[eventId]
    # delete the user's public and message streams
    userStreams = utils.ids(stream.streamsForObjectRef(ref(id)))
    for streamId in userStreams:
        del db[streamId]
    # delete all of the remaining user's streams which have no events
    streamIds = utils.ids(stream.streamsByCreator(id))
    [stream.delete(streamId) for streamId in streamIds
     if len(event.eventsForStream(streamId)) == 0]
    # delete all the user's shifts
    deleteShifts(id)
    # delete all the user's permission
    userPerms = utils.ids(permission.permissionsForUser(id))
    for permId in userPerms:
        del db[permId]
    # delete the user
    del db[id]
예제 #2
0
파일: shift.py 프로젝트: ljxia/shiftserver
 def join(shift):
     id = shift["_id"]
     if userId:
         shift["favorite"] = isFavorited(id, userId)
     shift["favoriteCount"] = favoriteCount(id)
     streamId = commentStream(id)
     if streamId:
         shift["commentCount"] = len(event.eventsForStream(streamId))
     creator = user.readById(shift["createdBy"])
     gravatar = creator.get("gravatar")
     if gravatar != None:
         shift["gravatar"] = gravatar
     return shift
예제 #3
0
파일: user.py 프로젝트: ljxia/shiftserver
def feeds(id, page=0, count=25):
    """
    Return all events for all streams that a user is subscribed to.
    Parameters:
        id - a user id.
        page - an integer representing the starting page.
        count - how many results to return.
    """
    db = core.connect()
    theUser = db[id]
    streams = theUser["streams"]
    allEvents = []
    for astream in streams:
        allEvents.extend(event.eventsForStream(astream))
    return allEvents