Пример #1
0
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
def deleteAllStreams():
    streamIds = [astream["_id"] for astream in core.query(schema.allStreams)]
    [stream.delete(streamId) for streamId in streamIds]