Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make ministry nullable #1477

Merged
merged 2 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading