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

TRACK-5: eac_signed and eac_expires #2396

Merged
merged 2 commits into from
Sep 3, 2024
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,40 @@
"""add eac signed and expires fields to project

Revision ID: 08209ce361c2
Revises: 19227722dffc
Create Date: 2024-08-29 08:45:46.100404

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '08209ce361c2'
down_revision = '19227722dffc'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('projects', schema=None) as batch_op:
batch_op.add_column(sa.Column('eac_signed', sa.Date(), nullable=True))
batch_op.add_column(sa.Column('eac_expires', sa.Date(), nullable=True))

with op.batch_alter_table('projects_history', schema=None) as batch_op:
batch_op.add_column(sa.Column('eac_signed', sa.Date(), autoincrement=False, nullable=True))
batch_op.add_column(sa.Column('eac_expires', sa.Date(), autoincrement=False, nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('projects_history', schema=None) as batch_op:
batch_op.drop_column('eac_expires')
batch_op.drop_column('eac_signed')

with op.batch_alter_table('projects', schema=None) as batch_op:
batch_op.drop_column('eac_expires')
batch_op.drop_column('eac_signed')
# ### end Alembic commands ###
4 changes: 3 additions & 1 deletion epictrack-api/src/api/models/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"""Model to manage Project."""
import enum

from sqlalchemy import Boolean, Column, Enum, Float, ForeignKey, Integer, String, Text, func
from sqlalchemy import Boolean, Column, Date, Enum, Float, ForeignKey, Integer, String, Text, func
from sqlalchemy.orm import relationship

from .base_model import BaseModelVersioned
Expand Down Expand Up @@ -64,6 +64,8 @@ class Project(BaseModelVersioned):
region_id_env = Column(ForeignKey("regions.id"), nullable=True)
region_id_flnro = Column(ForeignKey("regions.id"), nullable=True)
abbreviation = Column(String(10), nullable=True, unique=True)
eac_signed = Column(Date(), nullable=True)
eac_expires = Column(Date(), nullable=True)
sub_type = relationship("SubType", foreign_keys=[sub_type_id], lazy="select")
type = relationship("Type", foreign_keys=[type_id], lazy="select")
proponent = relationship("Proponent", foreign_keys=[proponent_id], lazy="select")
Expand Down
12 changes: 12 additions & 0 deletions epictrack-api/src/api/schemas/request/project_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ class ProjectBodyParameterSchema(RequestBodyParameterSchema):
load_default=None
)

eac_signed = fields.Date(
metadata={"description": "Date the EAC was signed on"},
allow_none=True,
load_default=None
)

eac_expires = fields.Date(
metadata={"description": "Date the EAC expires on"},
allow_none=True,
load_default=None
)

is_active = fields.Bool(metadata={"description": "Active state of the project"})
is_project_closed = fields.Bool(metadata={"description": "Closed state of the project"}, default=False)

Expand Down
6 changes: 6 additions & 0 deletions epictrack-web/src/components/project/Dialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ export const ProjectDialog = ({
};

const saveProject = async (data: any) => {
if (data.eac_signed) {
data.eac_signed = new Date(data.eac_signed).toISOString().split("T")[0];
}
if (data.eac_expires) {
data.eac_expires = new Date(data.eac_expires).toISOString().split("T")[0];
}
if (projectId) {
await editProject(data);
} else {
Expand Down
15 changes: 15 additions & 0 deletions epictrack-web/src/components/project/ProjectForm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import typeService from "services/typeService";
import proponentService from "services/proponentService/proponentService";
import { useAppSelector } from "hooks";
import { sort } from "utils";
import ControlledDatePicker from "components/shared/controlledInputComponents/ControlledDatePicker";

const schema = yup.object().shape({
name: yup
Expand Down Expand Up @@ -449,6 +450,20 @@ export default function ProjectForm({
/>
</Restricted>
</Grid>
<Grid item xs={6}>
<ETFormLabel>EAC Signed</ETFormLabel>
<ControlledDatePicker
name="eac_signed"
disabled={shouldDisableFormField}
/>
</Grid>
<Grid item xs={6}>
<ETFormLabel>EAC Expires</ETFormLabel>
<ControlledDatePicker
name="eac_expires"
disabled={shouldDisableFormField}
/>
</Grid>
<Grid
item
xs={3}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const useRouterLocationStateForHelpPage = (

navigate(`${location.pathname}${location.search}`, {
state: { helpPageTags: newtags },
replace: true, // modify current entry in history stack rather than adding duplicate
});
}, dependencies);
};
Expand Down
Loading