Exemplo n.º 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]
Exemplo n.º 2
0
def deleteShifts(id):
    db = core.connect()
    userShifts = utils.ids(shift.byUser(id))
    for shiftId in userShifts:
        del db[shiftId]