コード例 #1
0
def clean_up():
    '''
    Deletes all objects created in the population script, in order to make testing easier.
    :return:
    '''
    print "Deleting..."
    for thing in NEW_OBJECTS:
        print "... and " + str(thing)
        db_session.delete(thing)
    db_session.commit()
    print "... all done!\n"
コード例 #2
0
ファイル: user.py プロジェクト: john-osullivan/groupbot
def delete_user(user_id):
    '''
    INPUT
    User_ID of the account to be deleted.

    OUTPUT
    Removes the user's row from the database, purging all of their memberships.
    '''
    user = User.query.get(int(user_id))
    db_session.delete(user)
    db_session.commit()
    return True
コード例 #3
0
ファイル: role.py プロジェクト: john-osullivan/groupbot
def delete_role(role_id, request):
    '''
    INPUT
    Takes a Role_ID and a request holding a delete form.  If the form says perform the delete,
    it does it and returns True.  If it doesn't say do the delete, it returns False.

    OUTPUT
    Removes the Role's row from the database.  It is therefore no longer associated
    with any members.  If there are any Tasks only approved by that Role, then the
    approval responsibilities move to the people who were last holding said Role.
    '''
    role = Role.query.get(role_id)
    if request.form['delete']:
        db_session.delete(role)
        db_session.commit()
        return True
    else:
        return False