Break class method for ccpo perms into two methods instead of switching on a kwarg to determine if perms are given or removed
This commit is contained in:
parent
0b2c7f5957
commit
feb24b8e16
@ -88,13 +88,15 @@ class Users(object):
|
||||
return user
|
||||
|
||||
@classmethod
|
||||
def update_ccpo_permissions(cls, user, add_perms=False):
|
||||
if add_perms:
|
||||
permission_sets = PermissionSets.get_all()
|
||||
else:
|
||||
permission_sets = []
|
||||
def give_ccpo_perms(cls, user):
|
||||
user.permission_sets = PermissionSets.get_all()
|
||||
db.session.add(user)
|
||||
db.session.commit()
|
||||
return user
|
||||
|
||||
user.permission_sets = permission_sets
|
||||
@classmethod
|
||||
def revoke_ccpo_perms(cls, user):
|
||||
user.permission_sets = []
|
||||
db.session.add(user)
|
||||
db.session.commit()
|
||||
return user
|
||||
|
@ -53,6 +53,6 @@ def submit_add_new_ccpo_user():
|
||||
@user_can(Permissions.CREATE_CCPO_USER, message="create ccpo user")
|
||||
def confirm_new_ccpo_user():
|
||||
user = Users.get_by_dod_id(request.form["dod_id"])
|
||||
Users.update_ccpo_permissions(user, add_perms=True)
|
||||
Users.give_ccpo_perms(user)
|
||||
flash("ccpo_user_added", user_name=user.full_name)
|
||||
return redirect(url_for("ccpo.ccpo_users"))
|
||||
|
@ -87,13 +87,15 @@ def test_get_ccpo_users():
|
||||
assert rando not in ccpo_users
|
||||
|
||||
|
||||
def test_update_ccpo_permissions():
|
||||
def test_give_ccpo_perms():
|
||||
rando = UserFactory.create()
|
||||
Users.update_ccpo_permissions(rando, add_perms=True)
|
||||
|
||||
ccpo = UserFactory.create_ccpo()
|
||||
Users.update_ccpo_permissions(ccpo)
|
||||
|
||||
Users.give_ccpo_perms(rando)
|
||||
ccpo_users = Users.get_ccpo_users()
|
||||
assert rando in ccpo_users
|
||||
|
||||
|
||||
def test_revoke_ccpo_perms():
|
||||
ccpo = UserFactory.create_ccpo()
|
||||
Users.revoke_ccpo_perms(ccpo)
|
||||
ccpo_users = Users.get_ccpo_users()
|
||||
assert ccpo not in ccpo_users
|
||||
|
Loading…
x
Reference in New Issue
Block a user