Skip to content

Commit

Permalink
Merge pull request #2653 from HHS/OPS-441-initial-page-and-combobox
Browse files Browse the repository at this point in the history
Ops 441 initial page and combobox
  • Loading branch information
johndeange authored Aug 8, 2024
2 parents 023fdd5 + a2e49ca commit 8cafd0d
Show file tree
Hide file tree
Showing 37 changed files with 908 additions and 148 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2974,7 +2974,12 @@ def upgrade() -> None:
"role",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("name", sa.String(), nullable=False),
sa.Column("permissions", sa.String(), nullable=False),
sa.Column(
"permissions",
postgresql.ARRAY(sa.String()),
server_default="{}",
nullable=False,
),
sa.Column("created_by", sa.Integer(), nullable=True),
sa.Column("updated_by", sa.Integer(), nullable=True),
sa.Column("created_on", sa.DateTime(), nullable=True),
Expand Down
72 changes: 72 additions & 0 deletions backend/data_tools/data/user_data.json5
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,68 @@
permissions: [
"POST_USER",
],
},
{ // 6 Budget Team Member
name: "BUDGET_TEAM",
permissions: [
"GET_AGREEMENT",
"PUT_AGREEMENT",
"PATCH_AGREEMENT",
"POST_AGREEMENT",

"GET_BUDGET_LINE_ITEM",
"PUT_BUDGET_LINE_ITEM",
"PATCH_BUDGET_LINE_ITEM",
"POST_BUDGET_LINE_ITEM",

"GET_SERVICES_COMPONENT",
"PUT_SERVICES_COMPONENT",
"PATCH_SERVICES_COMPONENT",
"POST_SERVICES_COMPONENT",

"GET_BLI_PACKAGE",
"PUT_BLI_PACKAGE",
"PATCH_BLI_PACKAGE",
"POST_BLI_PACKAGE",

"GET_CAN",
"PUT_CAN",
"PATCH_CAN",
"POST_CAN",

"GET_DIVISION",

"GET_NOTIFICATION",
"PUT_NOTIFICATION",
"PATCH_NOTIFICATION",

"GET_PORTFOLIO",
"PUT_PORTFOLIO",
"PATCH_PORTFOLIO",
"POST_PORTFOLIO",

"GET_RESEARCH_PROJECT",
"POST_RESEARCH_PROJECT",
"PUT_RESEARCH_PROJECT",
"POST_RESEARCH_PROJECT",

"GET_USER",

"GET_HISTORY",

"GET_CHANGE_REQUEST",
"PUT_CHANGE_REQUEST",
"PATCH_CHANGE_REQUEST",
"POST_CHANGE_REQUEST",

"GET_CHANGE_REQUEST_REVIEW",
"PUT_CHANGE_REQUEST_REVIEW",
"PATCH_CHANGE_REQUEST_REVIEW",
"POST_CHANGE_REQUEST_REVIEW",

"GET_UPLOAD_DOCUMENT",
"POST_UPLOAD_DOCUMENT"
]
}
],
group: [
Expand Down Expand Up @@ -455,6 +517,16 @@
groups: [{"tablename": "group", "id": 3}],
status: "ACTIVE"
},
{ // 523
first_name: "Budget",
last_name: "Team",
division: 1,
email: "[email protected]",
oidc_id: "00000000-0000-1111-a111-000000000021",
roles: [{"tablename": "role", "id": 5}, {"tablename": "role", "id": 6}],
groups: [],
status: "ACTIVE"
}
],
notification: [
{
Expand Down
1 change: 1 addition & 0 deletions backend/data_tools/initial_data/003-role.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ INSERT INTO ops.role (id, name, permissions, created_on, updated_on) VALUES (2,
INSERT INTO ops.role (id, name, permissions, created_on, updated_on) VALUES (3, 'unassigned', '{GET_USER,POST_USER,PUT_USER,PATCH_USER}', current_timestamp, current_timestamp);
INSERT INTO ops.role (id, name, permissions, created_on, updated_on) VALUES (4, 'division-director', '{GET_AGREEMENT,PUT_AGREEMENT,PATCH_AGREEMENT,POST_AGREEMENT,GET_BUDGET_LINE_ITEM,PUT_BUDGET_LINE_ITEM,PATCH_BUDGET_LINE_ITEM,POST_BUDGET_LINE_ITEM,GET_SERVICES_COMPONENT,PUT_SERVICES_COMPONENT,PATCH_SERVICES_COMPONENT,POST_SERVICES_COMPONENT,GET_BLI_PACKAGE,PUT_BLI_PACKAGE,PATCH_BLI_PACKAGE,POST_BLI_PACKAGE,GET_CAN,GET_DIVISION,GET_NOTIFICATION,PUT_NOTIFICATION,PATCH_NOTIFICATION,GET_PORTFOLIO,GET_RESEARCH_PROJECT,POST_RESEARCH_PROJECT,GET_USER,GET_USERS,GET_HISTORY,GET_WORKFLOW,PUT_WORKFLOW,PATCH_WORKFLOW,POST_WORKFLOW,GET_CHANGE_REQUEST,PATCH_CHANGE_REQUEST,POST_CHANGE_REQUEST,GET_CHANGE_REQUEST_REVIEW,PATCH_CHANGE_REQUEST_REVIEW,POST_CHANGE_REQUEST_REVIEW}', current_timestamp, current_timestamp);
INSERT INTO ops.role (id, name, permissions, created_on, updated_on) VALUES (5, 'USER_ADMIN', '{POST_USER}', current_timestamp, current_timestamp);
INSERT INTO ops.role (id, name, permissions, created_on, updated_on) VALUES (6, 'BUDGET_TEAM', '{GET_AGREEMENT,PUT_AGREEMENT,PATCH_AGREEMENT,POST_AGREEMENT,GET_BUDGET_LINE_ITEM,PUT_BUDGET_LINE_ITEM,PATCH_BUDGET_LINE_ITEM,POST_BUDGET_LINE_ITEM,GET_SERVICES_COMPONENT,PUT_SERVICES_COMPONENT,PATCH_SERVICES_COMPONENT,POST_SERVICES_COMPONENT,GET_BLI_PACKAGE,PUT_BLI_PACKAGE,PATCH_BLI_PACKAGE,POST_BLI_PACKAGE,GET_CAN,PUT_CAN,PATCH_CAN,POST_CAN,GET_DIVISION,GET_NOTIFICATION,PUT_NOTIFICATION,PATCH_NOTIFICATION,GET_PORTFOLIO,PUT_PORTFOLIO,PATCH_PORTFOLIO,POST_PORTFOLIO,GET_RESEARCH_PROJECT,POST_RESEARCH_PROJECT,PUT_RESEARCH_PROJECT,POST_RESEARCH_PROJECT,GET_USER,GET_HISTORY,GET_CHANGE_REQUEST,PUT_CHANGE_REQUEST,PATCH_CHANGE_REQUEST,POST_CHANGE_REQUEST,GET_CHANGE_REQUEST_REVIEW,PUT_CHANGE_REQUEST_REVIEW,PATCH_CHANGE_REQUEST_REVIEW,POST_CHANGE_REQUEST_REVIEW,GET_UPLOAD_DOCUMENT,POST_UPLOAD_DOCUMENT}', current_timestamp, current_timestamp);
1 change: 1 addition & 0 deletions backend/data_tools/initial_data/004-role_version.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ INSERT INTO ops.role_version (id, name, permissions, created_on, updated_on, tra
INSERT INTO ops.role_version (id, name, permissions, created_on, updated_on, transaction_id, end_transaction_id, operation_type) VALUES (4, 'division-director', '{GET_AGREEMENT,PUT_AGREEMENT,PATCH_AGREEMENT,POST_AGREEMENT,GET_BUDGET_LINE_ITEM,PUT_BUDGET_LINE_ITEM,PATCH_BUDGET_LINE_ITEM,POST_BUDGET_LINE_ITEM,GET_SERVICES_COMPONENT,PUT_SERVICES_COMPONENT,PATCH_SERVICES_COMPONENT,POST_SERVICES_COMPONENT,GET_BLI_PACKAGE,PUT_BLI_PACKAGE,PATCH_BLI_PACKAGE,POST_BLI_PACKAGE,GET_CAN,GET_DIVISION,GET_NOTIFICATION,PUT_NOTIFICATION,PATCH_NOTIFICATION,GET_PORTFOLIO,GET_RESEARCH_PROJECT,POST_RESEARCH_PROJECT,GET_USER,GET_USERS,GET_HISTORY,GET_WORKFLOW,PUT_WORKFLOW,PATCH_WORKFLOW,POST_WORKFLOW,GET_CHANGE_REQUEST,PATCH_CHANGE_REQUEST,POST_CHANGE_REQUEST,GET_CHANGE_REQUEST_REVIEW,PATCH_CHANGE_REQUEST_REVIEW,POST_CHANGE_REQUEST_REVIEW}', current_timestamp, current_timestamp, 1, null, 0);
INSERT INTO ops.role_version (id, name, permissions, created_on, updated_on, transaction_id, end_transaction_id, operation_type) VALUES (4, 'division-director', '{GET_AGREEMENT,PUT_AGREEMENT,PATCH_AGREEMENT,POST_AGREEMENT,GET_BUDGET_LINE_ITEM,PUT_BUDGET_LINE_ITEM,PATCH_BUDGET_LINE_ITEM,POST_BUDGET_LINE_ITEM,GET_SERVICES_COMPONENT,PUT_SERVICES_COMPONENT,PATCH_SERVICES_COMPONENT,POST_SERVICES_COMPONENT,GET_BLI_PACKAGE,PUT_BLI_PACKAGE,PATCH_BLI_PACKAGE,POST_BLI_PACKAGE,GET_CAN,GET_DIVISION,GET_NOTIFICATION,PUT_NOTIFICATION,PATCH_NOTIFICATION,GET_PORTFOLIO,GET_RESEARCH_PROJECT,POST_RESEARCH_PROJECT,GET_USER,GET_USERS,GET_HISTORY,GET_WORKFLOW,PUT_WORKFLOW,PATCH_WORKFLOW,POST_WORKFLOW,GET_CHANGE_REQUEST,PATCH_CHANGE_REQUEST,POST_CHANGE_REQUEST,GET_CHANGE_REQUEST_REVIEW,PATCH_CHANGE_REQUEST_REVIEW,POST_CHANGE_REQUEST_REVIEW}', current_timestamp, current_timestamp, 1, null, 0);
INSERT INTO ops.role_version (id, name, permissions, created_on, updated_on, transaction_id, end_transaction_id, operation_type) VALUES (5, 'USER_ADMIN', '{POST_USER}', current_timestamp, current_timestamp, 1, null, 0);
INSERT INTO ops.role_version (id, name, permissions, created_on, updated_on, transaction_id, end_transaction_id, operation_type) VALUES (6, 'BUDGET_TEAM', '{GET_AGREEMENT,PUT_AGREEMENT,PATCH_AGREEMENT,POST_AGREEMENT,GET_BUDGET_LINE_ITEM,PUT_BUDGET_LINE_ITEM,PATCH_BUDGET_LINE_ITEM,POST_BUDGET_LINE_ITEM,GET_SERVICES_COMPONENT,PUT_SERVICES_COMPONENT,PATCH_SERVICES_COMPONENT,POST_SERVICES_COMPONENT,GET_BLI_PACKAGE,PUT_BLI_PACKAGE,PATCH_BLI_PACKAGE,POST_BLI_PACKAGE,GET_CAN,PUT_CAN,PATCH_CAN,POST_CAN,GET_DIVISION,GET_NOTIFICATION,PUT_NOTIFICATION,PATCH_NOTIFICATION,GET_PORTFOLIO,PUT_PORTFOLIO,PATCH_PORTFOLIO,POST_PORTFOLIO,GET_RESEARCH_PROJECT,POST_RESEARCH_PROJECT,PUT_RESEARCH_PROJECT,POST_RESEARCH_PROJECT,GET_USER,GET_HISTORY,GET_CHANGE_REQUEST,PUT_CHANGE_REQUEST,PATCH_CHANGE_REQUEST,POST_CHANGE_REQUEST,GET_CHANGE_REQUEST_REVIEW,PUT_CHANGE_REQUEST_REVIEW,PATCH_CHANGE_REQUEST_REVIEW,POST_CHANGE_REQUEST_REVIEW,GET_UPLOAD_DOCUMENT,POST_UPLOAD_DOCUMENT}', current_timestamp, current_timestamp, 1, null, 0);
1 change: 1 addition & 0 deletions backend/data_tools/initial_data/015-ops_user.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
INSERT INTO ops.ops_user (id, oidc_id, hhs_id, email, first_name, last_name, division, status, created_on, updated_on) VALUES (520, '00000000-0000-1111-a111-000000000018', null, '[email protected]', 'Admin', 'Demo', 3, 'ACTIVE', current_timestamp, current_timestamp);
INSERT INTO ops.ops_user (id, oidc_id, hhs_id, email, first_name, last_name, division, status, created_on, updated_on) VALUES (521, '00000000-0000-1111-a111-000000000019', null, '[email protected]', 'User', 'Demo', 3, 'ACTIVE', current_timestamp, current_timestamp);
INSERT INTO ops.ops_user (id, oidc_id, hhs_id, email, first_name, last_name, division, status, created_on, updated_on) VALUES (523, '00000000-0000-1111-a111-000000000021', null, '[email protected]', 'Budget', 'Team', 1, 'ACTIVE', current_timestamp, current_timestamp);
1 change: 1 addition & 0 deletions backend/data_tools/initial_data/016-ops_user_version.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
INSERT INTO ops.ops_user_version (id, oidc_id, hhs_id, email, first_name, last_name, division, status, created_on, updated_on, transaction_id, end_transaction_id, operation_type) VALUES (520, '00000000-0000-1111-a111-000000000018', null, '[email protected]', 'Admin', 'Demo', 3, 'ACTIVE', current_timestamp, current_timestamp, 1, null, 0);
INSERT INTO ops.ops_user_version (id, oidc_id, hhs_id, email, first_name, last_name, division, status, created_on, updated_on, transaction_id, end_transaction_id, operation_type) VALUES (521, '00000000-0000-1111-a111-000000000019', null, '[email protected]', 'User', 'Demo', 3, 'ACTIVE', current_timestamp, current_timestamp, 1, null, 0);
INSERT INTO ops.ops_user_version (id, oidc_id, hhs_id, email, first_name, last_name, division, status, created_on, updated_on, transaction_id, end_transaction_id, operation_type) VALUES (523, '00000000-0000-1111-a111-000000000021', null, '[email protected]', 'Budget', 'Team', 1, 'ACTIVE', current_timestamp, current_timestamp, 1, null, 0);
2 changes: 2 additions & 0 deletions backend/data_tools/initial_data/017-user_role.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
INSERT INTO ops.user_role (user_id, role_id, created_on, updated_on) VALUES (521, 2, current_timestamp, current_timestamp);
INSERT INTO ops.user_role (user_id, role_id, created_on, updated_on) VALUES (520, 1, current_timestamp, current_timestamp);
INSERT INTO ops.user_role (user_id, role_id, created_on, updated_on) VALUES (520, 5, current_timestamp, current_timestamp);
INSERT INTO ops.user_role (user_id, role_id, created_on, updated_on) VALUES (523, 5, current_timestamp, current_timestamp);
INSERT INTO ops.user_role (user_id, role_id, created_on, updated_on) VALUES (523, 6, current_timestamp, current_timestamp);
2 changes: 2 additions & 0 deletions backend/data_tools/initial_data/018-user_role_version.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
INSERT INTO ops.user_role_version (user_id, role_id, created_on, updated_on, transaction_id, end_transaction_id, operation_type) VALUES (520, 1, current_timestamp, current_timestamp, 1, null, 0);
INSERT INTO ops.user_role_version (user_id, role_id, created_on, updated_on, transaction_id, end_transaction_id, operation_type) VALUES (521, 2, current_timestamp, current_timestamp, 1, null, 0);
INSERT INTO ops.user_role_version (user_id, role_id, created_on, updated_on, transaction_id, end_transaction_id, operation_type) VALUES (520, 5, current_timestamp, current_timestamp, 1, null, 0);
INSERT INTO ops.user_role_version (user_id, role_id, created_on, updated_on, transaction_id, end_transaction_id, operation_type) VALUES (523, 5, current_timestamp, current_timestamp, 1, null, 0);
INSERT INTO ops.user_role_version (user_id, role_id, created_on, updated_on, transaction_id, end_transaction_id, operation_type) VALUES (523, 6, current_timestamp, current_timestamp, 1, null, 0);
7 changes: 4 additions & 3 deletions backend/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ class Meta(object):
)

# handle list of enums
if isinstance(column.type, sqlalchemy.types.ARRAY) and isinstance(
column.type.item_type.enum_class, enum.EnumMeta
):
if (isinstance(column.type, sqlalchemy.types.ARRAY) and
hasattr(column.type.item_type, "enum_class") and
isinstance(column.type.item_type.enum_class, enum.EnumMeta
)):
schema_class._declared_fields[column.key] = fields.List(
EnumField(column.type.item_type.enum_class),
default=[],
Expand Down
8 changes: 5 additions & 3 deletions backend/models/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from enum import Enum, auto
from typing import List, Optional

from sqlalchemy import Column, ForeignKey, Integer, Sequence
from sqlalchemy.dialects.postgresql import ENUM, UUID
from sqlalchemy import Column, ForeignKey, Integer, Sequence, String
from sqlalchemy.dialects.postgresql import ARRAY, ENUM, UUID
from sqlalchemy.orm import Mapped, column_property, mapped_column, relationship

from models import BaseModel
Expand Down Expand Up @@ -138,7 +138,9 @@ class Role(BaseModel):
)

name: Mapped[str] = mapped_column(index=True)
permissions: Mapped[str]
permissions: Mapped[List[str]] = mapped_column(
ARRAY(String()), server_default="{}", default=[]
)

users: Mapped[List["User"]] = relationship(
"User",
Expand Down
Loading

0 comments on commit 8cafd0d

Please sign in to comment.