Skip to content

Commit

Permalink
Merge pull request #1477 from TomChapmanGov/1331
Browse files Browse the repository at this point in the history
Make ministry nullable
  • Loading branch information
jadmsaadaot authored Dec 20, 2023
2 parents 8a89297 + c5d1250 commit ce7a22d
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"""make work ministry nullable
Revision ID: 65cb91595d6a
Revises: 925ba8974e38
Create Date: 2023-12-18 14:57:36.523607
"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '65cb91595d6a'
down_revision = '925ba8974e38'
branch_labels = None
depends_on = None


def upgrade():
op.alter_column('works', 'ministry_id', existing_type=sa.INTEGER(), nullable=True)
op.alter_column('works_history', 'ministry_id', existing_type=sa.INTEGER(), nullable=True)


def downgrade():
pass
2 changes: 1 addition & 1 deletion epictrack-api/src/api/models/work.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class Work(BaseModelVersioned):
work_decision_date = Column(DateTime(timezone=True))

project_id = Column(ForeignKey('projects.id'), nullable=False)
ministry_id = Column(ForeignKey('ministries.id'), nullable=False)
ministry_id = Column(ForeignKey('ministries.id'), nullable=True)
ea_act_id = Column(ForeignKey('ea_acts.id'), nullable=False)
eao_team_id = Column(ForeignKey('eao_teams.id'), nullable=False)
federal_involvement_id = Column(ForeignKey('federal_involvements.id'), nullable=False)
Expand Down
2 changes: 1 addition & 1 deletion epictrack-api/src/api/schemas/request/work_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class WorkBodyParameterSchema(RequestBodyParameterSchema):
ministry_id = fields.Int(
metadata={"description": "Ministry id of the work"},
validate=validate.Range(min=1),
required=True,
required=False,
)
federal_involvement_id = fields.Int(
metadata={"description": "Federal involvement id of the work"},
Expand Down
3 changes: 1 addition & 2 deletions epictrack-web/src/components/work/WorkForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const schema = yup.object<Work>().shape({
work_type_id: yup.number().required("Work type is required"),
start_date: yup.date().required("Start date is required"),
project_id: yup.number().required("Project is required"),
ministry_id: yup.number().required("Responsible ministry is required"),
federal_involvement_id: yup
.number()
.required("Federal Involvement is required"),
Expand Down Expand Up @@ -256,7 +255,7 @@ export default function WorkForm({ ...props }) {
></ControlledSelectV2>
</Grid>
<Grid item xs={6}>
<ETFormLabel required>Responsible Ministry</ETFormLabel>
<ETFormLabel>Responsible Ministry</ETFormLabel>
<ControlledSelectV2
placeholder="Select"
helperText={errors?.ministry_id?.message?.toString()}
Expand Down
2 changes: 1 addition & 1 deletion epictrack-web/src/components/work/WorkList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const WorkList = () => {
const codes = works
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
.map((w) => w[key][accessor])
.map((w) => (w[key] ? w[key][accessor] : null))
.filter(
(ele, index, arr) => arr.findIndex((t) => t === ele) === index && ele
);
Expand Down

0 comments on commit ce7a22d

Please sign in to comment.