Skip to content

Commit

Permalink
Work modal (#1079)
Browse files Browse the repository at this point in the history
* work modal WIP

* work modal updates

* merging dev in

* added migration

* removed print statement

* truncate tables before changing

---------

Co-authored-by: Tom Chapman <tchapman000@gmail.com>
  • Loading branch information
TomChapmanGov and tom0827 authored Oct 24, 2023
1 parent 048007b commit 9ea4c28
Show file tree
Hide file tree
Showing 11 changed files with 11,324 additions and 5,434 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""rename work columns
Revision ID: 2257493941e7
Revises: 7deec389ae56
Create Date: 2023-10-23 16:12:30.470016
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '2257493941e7'
down_revision = '7deec389ae56'
branch_labels = None
depends_on = None


def upgrade():
op.execute("TRUNCATE works CASCADE")
op.execute("TRUNCATE works_history CASCADE")
with op.batch_alter_table('works', schema=None) as batch_op:
batch_op.alter_column('short_description', new_column_name='report_description')
batch_op.alter_column('long_description', new_column_name='epic_description')
batch_op.alter_column('is_watched', new_column_name='is_high_priority')
batch_op.drop_column('is_pecp_required')
with op.batch_alter_table('works_history', schema=None) as batch_op:
batch_op.add_column(sa.Column('report_description', sa.String(length=2000), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('epic_description', sa.Text(), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('is_high_priority', sa.Boolean(), autoincrement=False, nullable=False))
batch_op.drop_column('is_watched')
batch_op.drop_column('short_description')
batch_op.drop_column('is_pecp_required')
batch_op.drop_column('long_description')


def downgrade():
with op.batch_alter_table('works', schema=None) as batch_op:
batch_op.alter_column('epic_description', new_column_name='long_description')
batch_op.alter_column('report_description', new_column_name='short_description')
batch_op.alter_column('is_high_priority', new_column_name='is_watched')
batch_op.add_column(sa.Column('is_pecp_required', sa.Boolean(), nullable=False, default=False))
with op.batch_alter_table('works_history', schema=None) as batch_op:
batch_op.add_column(sa.Column('long_description', sa.TEXT(), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('is_pecp_required', sa.BOOLEAN(), autoincrement=False, nullable=False))
batch_op.add_column(sa.Column('short_description', sa.VARCHAR(length=2000), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('is_watched', sa.BOOLEAN(), autoincrement=False, nullable=False))
batch_op.drop_column('is_high_priority')
batch_op.drop_column('epic_description')
batch_op.drop_column('report_description')
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
"""make columns not nullable
Revision ID: eed10a65e3c3
Revises: 2257493941e7
Create Date: 2023-10-23 16:17:27.132349
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'eed10a65e3c3'
down_revision = '2257493941e7'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.execute("TRUNCATE works CASCADE")
op.execute("TRUNCATE works_history CASCADE")
with op.batch_alter_table('works', schema=None) as batch_op:
batch_op.alter_column('eao_team_id',
existing_type=sa.INTEGER(),
nullable=False)
batch_op.alter_column('responsible_epd_id',
existing_type=sa.INTEGER(),
nullable=False)
batch_op.alter_column('work_lead_id',
existing_type=sa.INTEGER(),
nullable=False)
batch_op.alter_column('decision_by_id',
existing_type=sa.INTEGER(),
nullable=False)

with op.batch_alter_table('works_history', schema=None) as batch_op:
batch_op.alter_column('eao_team_id',
existing_type=sa.INTEGER(),
nullable=False,
autoincrement=False)
batch_op.alter_column('responsible_epd_id',
existing_type=sa.INTEGER(),
nullable=False,
autoincrement=False)
batch_op.alter_column('work_lead_id',
existing_type=sa.INTEGER(),
nullable=False,
autoincrement=False)
batch_op.alter_column('decision_by_id',
existing_type=sa.INTEGER(),
nullable=False,
autoincrement=False)

# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('works_history', schema=None) as batch_op:
batch_op.alter_column('decision_by_id',
existing_type=sa.INTEGER(),
nullable=True,
autoincrement=False)
batch_op.alter_column('work_lead_id',
existing_type=sa.INTEGER(),
nullable=True,
autoincrement=False)
batch_op.alter_column('responsible_epd_id',
existing_type=sa.INTEGER(),
nullable=True,
autoincrement=False)
batch_op.alter_column('eao_team_id',
existing_type=sa.INTEGER(),
nullable=True,
autoincrement=False)

with op.batch_alter_table('works', schema=None) as batch_op:
batch_op.alter_column('decision_by_id',
existing_type=sa.INTEGER(),
nullable=True)
batch_op.alter_column('work_lead_id',
existing_type=sa.INTEGER(),
nullable=True)
batch_op.alter_column('responsible_epd_id',
existing_type=sa.INTEGER(),
nullable=True)
batch_op.alter_column('eao_team_id',
existing_type=sa.INTEGER(),
nullable=True)

# ### end Alembic commands ###
6 changes: 6 additions & 0 deletions epictrack-api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 7 additions & 8 deletions epictrack-api/src/api/models/work.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ class Work(BaseModelVersioned):

id = Column(Integer, primary_key=True, autoincrement=True)
title = Column(String(80), nullable=False)
short_description = Column(String(2000))
long_description = Column(Text)
is_pecp_required = Column(Boolean, default=False, nullable=False)
report_description = Column(String(2000))
epic_description = Column(Text)
is_cac_recommended = Column(Boolean, default=False, nullable=False)
is_active = Column(Boolean, default=True, nullable=False)
is_completed = Column(Boolean, default=False, nullable=False)
is_watched = Column(Boolean, default=False, nullable=False)
is_high_priority = Column(Boolean, default=False, nullable=False)
work_status_stoplight = Column(String(6))
is_deleted = Column(Boolean(), default=False, nullable=False)
project_tracking_number = Column(String(255), nullable=True, default=None)
Expand All @@ -46,15 +45,15 @@ class Work(BaseModelVersioned):
project_id = Column(ForeignKey('projects.id'), nullable=False)
ministry_id = Column(ForeignKey('ministries.id'), nullable=False)
ea_act_id = Column(ForeignKey('ea_acts.id'), nullable=False)
eao_team_id = Column(ForeignKey('eao_teams.id'), nullable=True)
eao_team_id = Column(ForeignKey('eao_teams.id'), nullable=False)
federal_involvement_id = Column(ForeignKey('federal_involvements.id'), nullable=False)
responsible_epd_id = Column(ForeignKey('staffs.id'), nullable=True)
work_lead_id = Column(ForeignKey('staffs.id'), nullable=True)
responsible_epd_id = Column(ForeignKey('staffs.id'), nullable=False)
work_lead_id = Column(ForeignKey('staffs.id'), nullable=False)
work_type_id = Column(ForeignKey('work_types.id'), nullable=False)
current_phase_id = Column(ForeignKey('phase_codes.id'), nullable=True, default=None)
substitution_act_id = Column(ForeignKey('substitution_acts.id'), nullable=True, default=None)
eac_decision_by_id = Column(ForeignKey('staffs.id'), nullable=True)
decision_by_id = Column(ForeignKey('staffs.id'), nullable=True)
decision_by_id = Column(ForeignKey('staffs.id'), nullable=False)
start_date_locked = Column(Boolean(), default=False)
decision_maker_position_id = Column(ForeignKey('positions.id'), nullable=True)

Expand Down
15 changes: 6 additions & 9 deletions epictrack-api/src/api/schemas/request/work_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ class WorkBodyParameterSchema(RequestBodyParameterSchema):
required=True,
)

short_description = fields.Str(
metadata={"description": "Short description of work"},
report_description = fields.Str(
metadata={"description": "Report description of work"},
validate=validate.Length(max=500),
required=True,
)
long_description = fields.Str(
metadata={"description": "Long description of work"},
epic_description = fields.Str(
metadata={"description": "EPIC description of work"},
validate=validate.Length(max=2000),
allow_none=True,
load_default=None,
Expand Down Expand Up @@ -101,15 +101,12 @@ class WorkBodyParameterSchema(RequestBodyParameterSchema):
)

is_active = fields.Bool(metadata={"description": "Active state of the work"})
is_watched = fields.Bool(
metadata={"description": "Watched state of the work"}, default=False
is_high_priority = fields.Bool(
metadata={"description": "Is a high priority work"}, default=False
)
is_cac_recommended = fields.Bool(
metadata={"description": "Is CAC recommended for the work"}, default=False
)
is_pecp_required = fields.Bool(
metadata={"description": "Is PCP recommended for the work"}, default=False
)


class WorkExistenceQueryParamSchema(RequestQueryParameterSchema):
Expand Down
Loading

0 comments on commit 9ea4c28

Please sign in to comment.