From 715395335fca8d0be534e8194810709983234032 Mon Sep 17 00:00:00 2001 From: jasquat Date: Wed, 18 May 2022 10:21:44 -0400 Subject: [PATCH] pre-commit is passing w/ burnettk --- src/spiff_workflow_webapp/models/group.py | 11 +++++++---- src/spiff_workflow_webapp/models/process_model.py | 2 +- src/spiff_workflow_webapp/models/user.py | 9 ++++++--- src/spiff_workflow_webapp/routes/user_blueprint.py | 2 ++ .../integration/test_user_blueprint.py | 6 +++--- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/spiff_workflow_webapp/models/group.py b/src/spiff_workflow_webapp/models/group.py index 77f563e8..5547f429 100644 --- a/src/spiff_workflow_webapp/models/group.py +++ b/src/spiff_workflow_webapp/models/group.py @@ -1,4 +1,4 @@ -"""group.""" +"""Group.""" from flask_bpmn.models.db import db from flask_bpmn.models.group import FlaskBpmnGroupModel from sqlalchemy.orm import relationship @@ -10,7 +10,10 @@ class GroupModel(FlaskBpmnGroupModel): __tablename__ = "group" __table_args__ = {"extend_existing": True} new_name_two = db.Column(db.String(255)) - user_group_assignments = relationship( - "UserGroupAssignmentModel", cascade="delete" + user_group_assignments = relationship("UserGroupAssignmentModel", cascade="delete") + users = relationship( + "UserModel", + viewonly=True, + secondary="user_group_assignment", + overlaps="user_group_assignments,users", ) - users = relationship("UserModel", viewonly=True, secondary="user_group_assignment", overlaps="user_group_assignments,users") diff --git a/src/spiff_workflow_webapp/models/process_model.py b/src/spiff_workflow_webapp/models/process_model.py index 94ba1ba2..76084179 100644 --- a/src/spiff_workflow_webapp/models/process_model.py +++ b/src/spiff_workflow_webapp/models/process_model.py @@ -1,4 +1,4 @@ -"""process_model.""" +"""Process_model.""" from flask_bpmn.models.db import db from sqlalchemy.orm import deferred diff --git a/src/spiff_workflow_webapp/models/user.py b/src/spiff_workflow_webapp/models/user.py index b5015011..a1b108f5 100644 --- a/src/spiff_workflow_webapp/models/user.py +++ b/src/spiff_workflow_webapp/models/user.py @@ -11,7 +11,10 @@ class UserModel(db.Model): username = db.Column(db.String(50), nullable=False, unique=True) name = db.Column(db.String(50)) email = db.Column(db.String(50)) - user_group_assignments = relationship( - "UserGroupAssignmentModel", cascade="delete" + user_group_assignments = relationship("UserGroupAssignmentModel", cascade="delete") + groups = relationship( + "GroupModel", + viewonly=True, + secondary="user_group_assignment", + overlaps="user_group_assignments,users", ) - groups = relationship("GroupModel", viewonly=True, secondary="user_group_assignment", overlaps="user_group_assignments,users") diff --git a/src/spiff_workflow_webapp/routes/user_blueprint.py b/src/spiff_workflow_webapp/routes/user_blueprint.py index 1fad279b..c958e01e 100644 --- a/src/spiff_workflow_webapp/routes/user_blueprint.py +++ b/src/spiff_workflow_webapp/routes/user_blueprint.py @@ -156,6 +156,7 @@ def remove_user_from_group(): def get_user_from_request(): + """Get_user_from_request.""" user_id = request.json.get("user_id") if user_id is None: @@ -174,6 +175,7 @@ def get_user_from_request(): def get_group_from_request(): + """Get_group_from_request.""" group_id = request.json.get("group_id") if group_id is None: diff --git a/tests/spiff_workflow_webapp/integration/test_user_blueprint.py b/tests/spiff_workflow_webapp/integration/test_user_blueprint.py index 0d02213f..c6eb8c0f 100644 --- a/tests/spiff_workflow_webapp/integration/test_user_blueprint.py +++ b/tests/spiff_workflow_webapp/integration/test_user_blueprint.py @@ -94,15 +94,15 @@ def test_user_can_be_removed_from_a_group(client): def test_acceptance(client): # Create a user U - user = create_user(client, 'U') + user = create_user(client, "U") # Create a group G - group_g = create_group(client, 'G') + group_g = create_group(client, "G") # Assign user U to group G assign_user_to_group(client, user, group_g) # Delete group G delete_group(client, group_g.name) # Create group H - group_h = create_group(client, 'H') + group_h = create_group(client, "H") # Assign user U to group H assign_user_to_group(client, user, group_h) # Unassign user U from group H