pyl fixed w/ burnettk
This commit is contained in:
parent
92258c6f9a
commit
3e4ab0145e
|
@ -27,7 +27,7 @@ class GroupModel(FlaskBpmnGroupModel):
|
|||
identifier = db.Column(db.String(255))
|
||||
|
||||
user_group_assignments = relationship("UserGroupAssignmentModel", cascade="delete")
|
||||
user_group_assignments_waiting = relationship(
|
||||
user_group_assignments_waiting = relationship( # type: ignore
|
||||
"UserGroupAssignmentWaitingModel", cascade="delete"
|
||||
)
|
||||
users = relationship( # type: ignore
|
||||
|
|
|
@ -8,8 +8,9 @@ from spiffworkflow_backend.models.group import GroupModel
|
|||
|
||||
|
||||
class UserGroupAssignmentWaitingModel(SpiffworkflowBaseDBModel):
|
||||
"""UserGroupAssignmentsWaitingModel - When a user is assinged to a group, but that username does not exist,
|
||||
we cache it here to be applied in the event the user does log into the system.
|
||||
"""When a user is assigned to a group, but that username does not exist.
|
||||
|
||||
We cache it here to be applied in the event the user does log in to the system.
|
||||
"""
|
||||
|
||||
MATCH_ALL_USERS = "*"
|
||||
|
@ -24,9 +25,9 @@ class UserGroupAssignmentWaitingModel(SpiffworkflowBaseDBModel):
|
|||
username = db.Column(db.String(255), nullable=False)
|
||||
group_id = db.Column(ForeignKey(GroupModel.id), nullable=False)
|
||||
|
||||
group = relationship("GroupModel", overlaps="groups,user_group_assignment_waiting,users") # type: ignore
|
||||
group = relationship("GroupModel", overlaps="groups,user_group_assignments_waiting,users") # type: ignore
|
||||
|
||||
def is_match_all(self):
|
||||
def is_match_all(self) -> bool:
|
||||
"""Is_match_all."""
|
||||
if self.username == self.MATCH_ALL_USERS:
|
||||
return True
|
||||
|
|
|
@ -218,12 +218,12 @@ class AuthorizationService:
|
|||
cls.associate_user_with_group(user, default_group)
|
||||
|
||||
@classmethod
|
||||
def find_or_create_permission_target(cls, uri):
|
||||
def find_or_create_permission_target(cls, uri: str) -> PermissionTargetModel:
|
||||
"""Find_or_create_permission_target."""
|
||||
uri_with_percent = re.sub(r"\*", "%", uri)
|
||||
permission_target = PermissionTargetModel.query.filter_by(
|
||||
uri=uri_with_percent
|
||||
).first()
|
||||
permission_target: Optional[
|
||||
PermissionTargetModel
|
||||
] = PermissionTargetModel.query.filter_by(uri=uri_with_percent).first()
|
||||
if permission_target is None:
|
||||
permission_target = PermissionTargetModel(uri=uri_with_percent)
|
||||
db.session.add(permission_target)
|
||||
|
|
|
@ -43,7 +43,7 @@ class TestAddPermission(BaseTest):
|
|||
assert group is None
|
||||
assert permission_target is None
|
||||
|
||||
result = AddPermission().run(
|
||||
AddPermission().run(
|
||||
script_attributes_context, "read", "/test_add_permission/*", "my_test_group"
|
||||
)
|
||||
group = GroupModel.query.filter(
|
||||
|
|
|
@ -35,7 +35,7 @@ class TestAddUserToGroup(BaseTest):
|
|||
process_instance_id=1,
|
||||
process_model_identifier="my_test_user",
|
||||
)
|
||||
result = AddUserToGroup().run(
|
||||
AddUserToGroup().run(
|
||||
script_attributes_context, my_user.username, my_group.identifier
|
||||
)
|
||||
assert my_user in my_group.users
|
||||
|
@ -54,7 +54,7 @@ class TestAddUserToGroup(BaseTest):
|
|||
process_instance_id=1,
|
||||
process_model_identifier="my_test_user",
|
||||
)
|
||||
result = AddUserToGroup().run(
|
||||
AddUserToGroup().run(
|
||||
script_attributes_context, "dan@sartography.com", "competent-joes"
|
||||
)
|
||||
my_group = GroupModel.query.filter(
|
||||
|
|
|
@ -53,7 +53,7 @@ class TestDeletePermissions(BaseTest):
|
|||
process_instance_id=1,
|
||||
process_model_identifier="my_test_user",
|
||||
)
|
||||
result = ClearPermissions().run(script_attributes_context)
|
||||
ClearPermissions().run(script_attributes_context)
|
||||
|
||||
groups = GroupModel.query.all()
|
||||
assert 0 == len(groups)
|
||||
|
|
|
@ -20,10 +20,10 @@ class TestUserService(BaseTest):
|
|||
with_db_and_bpmn_file_cleanup: None,
|
||||
) -> None:
|
||||
"""Test_waiting_group_assignments."""
|
||||
aTestGroup = GroupService.find_or_create_group("aTestGroup")
|
||||
UserService.add_waiting_group_assignment("initiator_user", aTestGroup)
|
||||
a_test_group = GroupService.find_or_create_group("aTestGroup")
|
||||
UserService.add_waiting_group_assignment("initiator_user", a_test_group)
|
||||
initiator_user = self.find_or_create_user("initiator_user")
|
||||
assert initiator_user.groups[0] == aTestGroup
|
||||
assert initiator_user.groups[0] == a_test_group
|
||||
|
||||
def test_assigning_a_group_to_all_users_updates_new_users(
|
||||
self,
|
||||
|
|
Loading…
Reference in New Issue